diff --git a/Dockerfile b/Dockerfile index 8cd88a3..249974e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,11 +19,14 @@ FROM python:3.11-slim WORKDIR /app -# Install runtime dependencies only +# Install runtime dependencies (libgomp for OpenMP parallelism) RUN apt-get update && apt-get install -y --no-install-recommends \ libgomp1 \ && rm -rf /var/lib/apt/lists/* +# FAISS uses OpenMP for parallel search - set threads for Xeon +ENV OMP_NUM_THREADS=8 + # Copy installed packages from builder COPY --from=builder /root/.local /root/.local ENV PATH=/root/.local/bin:$PATH @@ -34,10 +37,12 @@ COPY config.py . COPY reverse_icon_search.py . COPY run_api_server.py . -# Copy pre-built index and filenames (must be provided at build time or mounted) -# These files are large and should be mounted as volumes in production -# COPY index.faiss . -# COPY filenames.pkl . +# Copy pre-built index and filenames for inference +# Option 1: Bundle in image (~530 MB) +COPY index.faiss . +COPY filenames.pkl . + +# Option 2: Mount as volume at runtime (uncomment above, use docker run -v) # Create necessary directories RUN mkdir -p uploads logs diff --git a/requirements.txt b/requirements.txt index 4eb0217..7c9abb3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ # Core ML/DL -tensorflow-macos -tensorflow-metal +tensorflow-macos; platform_system == "Darwin" and platform_machine == "arm64" +tensorflow-metal; platform_system == "Darwin" and platform_machine == "arm64" +tensorflow~=2.14.0; platform_system != "Darwin" keras~=2.14.0 numpy~=1.26.2 scikit-learn~=1.3.2