FROM python:3.11-slim # Create a non-root user (Required by Hugging Face Spaces) RUN useradd -m -u 1000 user # Switch to the new user USER user ENV PATH="/home/user/.local/bin:$PATH" # Set the working directory WORKDIR /home/user/app # Copy requirements first to leverage Docker cache COPY --chown=user requirements.txt . # Install dependencies RUN pip install --no-cache-dir -r requirements.txt # Copy the rest of the application files COPY --chown=user . . # Ensure the static/avatars directory exists for photo uploads RUN mkdir -p static/avatars # Expose port 7860 (Hugging Face Spaces default) EXPOSE 7860 # Run the app using gunicorn on port 7860 CMD ["gunicorn", "-b", "0.0.0.0:7860", "--timeout", "120", "app:app"]