# Use an official PyTorch image as a base FROM pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime # Set the working directory inside the container WORKDIR /app # Install system dependencies RUN apt-get update && apt-get install -y \ build-essential \ git \ && rm -rf /var/lib/apt/lists/* # Create a non-root user RUN useradd -m -u 1000 appuser # Create cache directories and set permissions RUN mkdir -p /app/models/sentence_transformer && \ mkdir -p /app/models/qwen && \ mkdir -p /.cache/huggingface && \ mkdir -p /.cache/torch && \ mkdir -p /.cache/sentence_transformers # Set environment variables for cache and model locations ENV HF_HOME="/.cache/huggingface" ENV TORCH_HOME="/.cache/torch" ENV SENTENCE_TRANSFORMERS_HOME="/app/models/sentence_transformer" # Install Python dependencies RUN pip install --no-cache-dir \ pandas \ torch \ sentence-transformers \ transformers \ numpy \ faiss-cpu \ fastapi \ uvicorn[standard] \ pydantic \ python-multipart \ huggingface_hub \ accelerate>=0.26.0 # Create a script to download models COPY <