| # Use official Python image | |
| FROM python:3.10-slim | |
| # Set working directory | |
| WORKDIR /app | |
| # Create a non-root user (Hugging Face standard) | |
| RUN useradd -m -u 1000 user | |
| USER user | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| # Set working directory to app and ensure ownership | |
| WORKDIR $HOME/app | |
| # Copy requirements and install | |
| COPY --chown=user requirements.txt . | |
| RUN pip install --no-cache-dir --upgrade -r requirements.txt | |
| # Copy the rest of the application | |
| COPY --chown=user . . | |
| # Hugging Face Spaces standard port | |
| EXPOSE 7860 | |
| # Set environment variables for Gradio to run on 0.0.0.0:7860 | |
| ENV GRADIO_SERVER_NAME="0.0.0.0" \ | |
| GRADIO_SERVER_PORT=7860 | |
| # Command to run the application | |
| CMD ["python", "app.py"] | |