| FROM python:3.12-slim | |
| # Install system dependencies for WeasyPrint and fonts | |
| RUN apt-get update && apt-get install -y --no-install-recommends \ | |
| build-essential \ | |
| python3-dev \ | |
| libffi-dev \ | |
| shared-mime-info \ | |
| libcairo2 \ | |
| libpango-1.0-0 \ | |
| libpangocairo-1.0-0 \ | |
| libgdk-pixbuf-2.0-0 \ | |
| fonts-dejavu-core \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Set up a new user named "user" with UID 1000 | |
| RUN useradd -m -u 1000 user | |
| # Set environment home variables | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR $HOME/app | |
| # Install Python requirements | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy source code | |
| COPY --chown=user . . | |
| # Switch to non-root user | |
| USER user | |
| # Expose FastAPI port | |
| EXPOSE 7860 | |
| # Start command | |
| CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "7860"] | |