Spaces:
Runtime error
Runtime error
| # Use a lightweight Python 3.9-slim image | |
| FROM python:3.9-slim | |
| # Set environment variables for Python and Hugging Face cache | |
| ENV PYTHONUNBUFFERED=1 | |
| ENV HF_HOME="/tmp/cache/huggingface" | |
| # Accept HF_TOKEN as a build argument and set it as an environment variable | |
| ARG HF_TOKEN | |
| ENV HF_TOKEN=${HF_TOKEN} | |
| # Create a non-root user and switch to that user | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set the working directory | |
| WORKDIR /app | |
| # Copy the requirements file and install dependencies | |
| COPY --chown=user ./requirements.txt /app/requirements.txt | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r /app/requirements.txt | |
| # Copy the rest of the application code | |
| COPY --chown=user . /app | |
| # Expose port 7860 (required by Hugging Face Spaces) | |
| EXPOSE 7860 | |
| # Optional: Add a label so that Spaces knows which port to use for embedding | |
| LABEL HF_SPACE_PORT=7860 | |
| # Start the FastAPI app using uvicorn via python -m | |
| CMD ["python", "-m", "uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |