broadfield-dev commited on
Commit
b53d446
·
verified ·
1 Parent(s): 0cbf0ad

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +6 -13
Dockerfile CHANGED
@@ -21,23 +21,16 @@ RUN pip install --no-cache-dir -r requirements.txt
21
  # Copy the app code and templates
22
  COPY app.py .
23
  COPY templates /app/templates/
24
- # If you add a static folder in the future for CSS/JS:
25
- # COPY static /app/static/
26
 
27
  # Switch to non-root user
28
  USER appuser
29
 
30
- # Expose the port the app runs on (for documentation, HF handles actual mapping)
31
- # Gunicorn will bind to this port. Hugging Face Spaces typically expect apps on 7860.
32
  EXPOSE 7860
33
 
34
- # Set environment variables
35
  ENV PYTHONUNBUFFERED=1
36
- ENV FLASK_APP=app.py
37
- # Recommended: Set FLASK_ENV to production for real deployments,
38
- # but gunicorn handles this role better than Flask dev server.
39
- # ENV FLASK_ENV=production
40
-
41
- # Run the Flask app with Gunicorn
42
- # The 'app:app' means Gunicorn should look for an object named 'app' in a file named 'app.py'.
43
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "2", "--timeout", "120", "app:app"]
 
21
  # Copy the app code and templates
22
  COPY app.py .
23
  COPY templates /app/templates/
 
 
24
 
25
  # Switch to non-root user
26
  USER appuser
27
 
 
 
28
  EXPOSE 7860
29
 
 
30
  ENV PYTHONUNBUFFERED=1
31
+ ENV FLASK_APP=app.py
32
+
33
+ # Gunicorn with increased timeout and gevent workers for better handling of I/O bound tasks (like network/file ops)
34
+ # Adjust workers based on your Space's CPU cores.
35
+ # Timeout is for a single request/response cycle. Streaming should keep this alive.
36
+ CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--workers", "1", "--worker-class", "gevent", "--timeout", "300", "app:app"]