Spaces:
Runtime error
Runtime error
Update Dockerfile
Browse files123456789101112131415161718192021222324252627282930313233343536373839404142434445464748# Use PythonFROM python:3.12# Set working directoryWORKDIR /app# Install curl for healthcheck (slim images don't include it)RUN apt-get update && apt-get install -y --no-install-recommends \curl \&& rm -rf /var/lib/apt/lists/*# Copy requirements and install dependencies first (better caching)COPY requirements.txt .RUN pip install --no-cache-dir -r requirements.txt# Create non-root user for security (HF Spaces best practice)RUN useradd -m -u 1000 user# Set user environment variablesENV HOME=/home/user \PATH=/home/user/.local/bin:$PATH# Set working directory to user's app directoryWORKDIR $HOME/app# Copy application files with correct ownershipCOPY --chown=user . $HOME/app# Switch to non-root userUSER user# Expose Hugging Face Spaces standard portEXPOSE 7860# Health check for container monitoringHEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \CMD curl --fail http://localhost:7860/_stcore/health || exit 1# Run Streamlit on port 7860 with production settingsCMD ["streamlit", "run", "app.py", \"--server.port=7860", \"--server.address=0.0.0.0", \"--server.headless=true", \"--server.fileWatcherType=none", \"--browser.gatherUsageStats=false", \"--server.enableCORS=false", \"--server.enableXsrfProtection=false"]1234567891011121314151617181920212223242526# Use Python 3.12FROM python:3.12# Set the working directory inside the container to /appWORKDIR /app# Copy all files from the current directory on the host to the container's /app directoryCOPY . .# Install Python dependencies listed in requirements.txtRUN pip3 install -r requirements.txt# Create non-root userRUN useradd -m -u 1000 userUSER user# Set user environment variablesENV HOME=/home/user \PATH=/home/user/.local/bin:$PATHWORKDIR $HOME/appCOPY --chown=user . $HOME/app# Run Streamlit on port 7860 (HF Spaces default, not 8501)CMD ["streamlit", "run", "app.py", "--server.port=7860", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
Dockerfile+10-32