FROM python:3.11-slim # Create a non-root user RUN useradd -m -u 1000 user # Install system dependencies as root RUN apt-get update && \ apt-get install -y --no-install-recommends \ libgl1-mesa-glx \ libglib2.0-0 && \ rm -rf /var/lib/apt/lists/* # Switch to the non-root user USER user ENV PATH="/home/user/.local/bin:$PATH" WORKDIR /app COPY --chown=user ./pyproject.toml ./poetry.lock ./ COPY --chown=user ./app /app COPY --chown=user ./embed_model_weights.pth ./ COPY --chown=user ./requirements.txt ./ # Copy the packages.txt file into the Docker image COPY --chown=user ./packages.txt ./ # Install Python dependencies using pip RUN pip install --no-cache-dir -r requirements.txt ENTRYPOINT ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"]