Spaces:
Sleeping
Sleeping
| FROM python:3.11-slim | |
| # Set up environment paths | |
| ENV HOME=/home/user \ | |
| PATH=/home/user/.local/bin:$PATH | |
| WORKDIR /app | |
| # Install system utilities needed for building packages | |
| RUN apt-get update && apt-get install -y \ | |
| build-essential \ | |
| curl \ | |
| git \ | |
| && rm -rf /var/lib/apt/lists/* | |
| # Copy the requirements file into the root working directory | |
| COPY requirements.txt /app/requirements.txt | |
| # FIX: Run pip install while still under root privileges to prevent permission errors | |
| RUN pip install --no-cache-dir --upgrade pip && \ | |
| pip install --no-cache-dir -r /app/requirements.txt | |
| # Set up secure, non-root user execution required by Hugging Face | |
| RUN useradd -m -u 1000 user | |
| WORKDIR $HOME/app | |
| # Copy all project files and change ownership to the non-root user | |
| COPY --chown=user . $HOME/app | |
| # Switch to the non-root user account for final runtime execution | |
| USER user | |
| # Expose the mandatory Hugging Face traffic proxy port | |
| EXPOSE 7860 | |
| # Add container stability health check on the assigned port | |
| HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ | |
| CMD curl --fail http://localhost:7860/_stcore/health || exit 1 | |
| # Execute app.py directly from the application folder on port 7860 | |
| ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--client.showErrorDetails=false", "--server.enableCORS=false", "--server.enableXsrfProtection=false"] | |