| # Base image | |
| FROM python:3.10 | |
| # Add user for HF Spaces | |
| RUN useradd -m -u 1000 user | |
| # Set working directory and change ownership | |
| WORKDIR /app | |
| RUN chown -R user:user /app | |
| USER user | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| # Port config: | |
| # 7860 = HuggingFace Spaces (default) | |
| ENV PORT=7860 | |
| EXPOSE 7860 | |
| # Install dependencies | |
| COPY --chown=user backend/requirements.txt /app/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade -r /app/requirements.txt | |
| # Copy all files | |
| COPY --chown=user . /app | |
| ENV PYTHONPATH=/app/backend | |
| # Run FastAPI (serves frontend as static files too) | |
| CMD uvicorn backend.main:app --host 0.0.0.0 --port $PORT | |