proofly / Dockerfile
Pragthedon's picture
Optimize: Add --preload to gunicorn for stable startup
30fe4b3
raw
history blame contribute delete
956 Bytes
FROM python:3.10-slim
# Install system dependencies (required for OCR and image/video processing)
RUN apt-get update && apt-get install -y \
ffmpeg \
libsm6 \
libxext6 \
git \
&& rm -rf /var/lib/apt/lists/*
# Set up a new user named "user" with user ID 1000
RUN useradd -m -u 1000 user
USER user
ENV PATH="/home/user/.local/bin:$PATH"
WORKDIR /app
# Copy requirement and install
COPY --chown=user requirements.txt requirements.txt
RUN pip install --no-cache-dir --upgrade pip && \
pip install --no-cache-dir -r requirements.txt
# Copy the rest of the app
COPY --chown=user . .
# Expose port (HF Spaces routes traffic to 7860 by default)
EXPOSE 7860
# Start Flask — 2 workers with --preload is best for 16GB RAM; 300s timeout for heavy peaks
CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "300", "--preload", "--keep-alive", "5", "--max-requests", "500", "--max-requests-jitter", "50", "app:app"]