Spaces:
Sleeping
Sleeping
| # Use Python 3.9 slim image for efficiency | |
| FROM python:3.9-slim | |
| # Create a non-root user for security | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| # Set environment variables | |
| ENV PATH="/home/user/.local/bin:$PATH" | |
| ENV PYTHONPATH="/app:$PYTHONPATH" | |
| # Set working directory | |
| WORKDIR /app | |
| # Copy requirements file with proper ownership | |
| COPY --chown=user requirements.txt requirements.txt | |
| # Install Python dependencies | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy application code | |
| COPY --chown=user app.py /app/ | |
| COPY --chown=user . /app/ | |
| # Expose port 7860 for Hugging Face Spaces | |
| EXPOSE 7860 | |
| # Command to run the application | |
| CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"] | |