Spaces:
Sleeping
Sleeping
| # Use an official Python runtime as the base image | |
| FROM python:3.9-slim | |
| # Create a non-root user | |
| RUN useradd -m -u 1000 appuser | |
| # Set working directory | |
| WORKDIR /app | |
| # Create a cache directory and set permissions | |
| RUN mkdir -p /app/cache/huggingface && chown -R appuser:appuser /app | |
| # Set environment variable for Hugging Face cache | |
| ENV HF_HOME=/app/cache/huggingface | |
| # Copy requirements file | |
| COPY --chown=appuser:appuser requirements.txt . | |
| # Install dependencies | |
| RUN pip install --no-cache-dir -r requirements.txt | |
| # Copy the FastAPI application code | |
| COPY --chown=appuser:appuser main.py . | |
| # Switch to non-root user | |
| USER appuser | |
| # Expose port 7860 for the FastAPI app | |
| EXPOSE 7860 | |
| # Command to run the application with Uvicorn | |
| CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "7860"] |