FROM python:3.11-slim WORKDIR /app RUN useradd -m -u 1000 appuser RUN mkdir -p /app/saved_models && chown -R appuser:appuser /app COPY requirements.txt . # Install build dependencies, including Python development tools and gflags RUN apt-get update && apt-get install -y \ build-essential \ libatlas-base-dev \ gfortran \ swig \ git \ cmake \ python3-dev \ libgflags-dev \ && rm -rf /var/lib/apt/lists/* # Install NumPy before building FAISS RUN pip install --no-cache-dir numpy # Build and install FAISS RUN git clone https://github.com/facebookresearch/faiss.git /faiss \ && cd /faiss \ && mkdir build && cd build \ && cmake -DFAISS_ENABLE_GPU=OFF -DBUILD_SHARED_LIBS=ON -DCMAKE_INSTALL_PREFIX=/usr/local .. \ && make -j$(nproc) \ && make install # Install remaining Python dependencies RUN pip install --no-cache-dir -r requirements.txt COPY . . USER appuser CMD ["python", "app.py"]