Spaces:
No application file
No application file
| # Use official Python runtime as a parent image | |
| FROM python:3.9-slim | |
| # Install system dependencies | |
| RUN apt-get update && apt-get install -y \ | |
| gcc \ | |
| libpq-dev \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Hugging Face Spaces REQUIRE processes to run as a non-root user (uid 1000) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Set working directory in the container | |
| WORKDIR /home/user/app | |
| # Copy requirements file first to leverage Docker cache | |
| COPY --chown=user requirements.txt . | |
| # Install dependencies statically | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the rest of the application code | |
| COPY --chown=user . /home/user/app | |
| # Expose port that FastAPI runs on internally (HF uses 7860) | |
| EXPOSE 7860 | |
| # Start Uvicorn process binding to 0.0.0.0 and dynamically port 7860 | |
| CMD uvicorn backend.main:app --host 0.0.0.0 --port 7860 | |