# Use Python base image FROM python:3.9 # Create non-root user RUN useradd -m -u 1000 user USER user ENV PATH="/home/user/.local/bin:$PATH" # Working directory WORKDIR /app # Install requirements first (to use Docker cache) COPY --chown=user ./requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade -r requirements.txt # Copy the rest of the app COPY --chown=user . /app # Run FastAPI with uvicorn (port 7860 is required by Hugging Face Spaces) CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]