# Use a slim base image for smaller footprint FROM python:3.9-slim # Create a non-root user RUN useradd -m -u 1000 user USER user # Set environment path ENV PATH="/home/user/.local/bin:$PATH" # Set working directory WORKDIR /app # Copy and install dependencies COPY --chown=user requirements.txt requirements.txt RUN pip install --no-cache-dir --upgrade pip \ && pip install --no-cache-dir -r requirements.txt # Optional: download SpaCy model in one layer RUN python -m spacy download en_core_web_sm # Copy the full project COPY --chown=user . . # Expose the port (optional for clarity) EXPOSE 7860 # Run the app CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]