# Use official python slim image FROM python:3.10-slim # Set environment and python variables ENV PYTHONUNBUFFERED=1 \ PYTHONDONTWRITEBYTECODE=1 \ PORT=7860 WORKDIR /code # Install system dependencies (curl for healthchecks) RUN apt-get update && apt-get install -y --no-install-recommends \ curl \ && rm -rf /var/lib/apt/lists/* # Copy requirements and install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy all application files COPY . . # Set up writable directory for uploads and fallback sqlite databases RUN mkdir -p /code/uploads && chmod -R 777 /code/uploads # Hugging Face Spaces runs as user UID 1000 by default. # We create a user and set home permissions. RUN useradd -m -u 1000 user RUN chown -R user:user /code USER user # Set Flask environment variables ENV FLASK_APP=app.py # Expose Hugging Face standard port EXPOSE 7860 # Run the Flask app with Gunicorn production server CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"]