mfoud444 commited on
Commit
5485b94
·
verified ·
1 Parent(s): fb59ea2

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -11
Dockerfile CHANGED
@@ -12,27 +12,36 @@ RUN apt-get update && \
12
  RUN useradd -m -u 1000 user
13
  USER user
14
  ENV PATH="/home/user/.local/bin:$PATH"
15
- ENV PYTHONPATH=/app
16
- ENV GUNICORN_CMD_ARGS="--workers 2 --timeout 300 --keep-alive 60"
 
17
 
18
  # Set up working directory
19
  WORKDIR /app
20
 
21
- # Install Python dependencies with precise versions
22
  COPY --chown=user requirements.txt .
23
  RUN pip install --no-cache-dir --upgrade pip && \
24
- pip install --no-cache-dir --upgrade -r requirements.txt && \
25
- pip install --no-cache-dir --upgrade "g4f>=0.2.0" psutil
26
-
27
- # Explicitly install gevent if you want to use it
28
- # RUN pip install gevent>=1.4
29
 
30
  # Copy application code
31
  COPY --chown=user . .
32
 
 
 
 
33
  # Health check
34
- HEALTHCHECK --interval=30s --timeout=3s \
35
  CMD curl -f http://localhost:7860/ || exit 1
36
 
37
- # Run the application (using sync worker for now)
38
- CMD ["gunicorn", "app:app"]
 
 
 
 
 
 
 
 
 
12
  RUN useradd -m -u 1000 user
13
  USER user
14
  ENV PATH="/home/user/.local/bin:$PATH"
15
+ ENV PYTHONPATH=/app \
16
+ PYTHONUNBUFFERED=1 \
17
+ PYTHONDONTWRITEBYTECODE=1
18
 
19
  # Set up working directory
20
  WORKDIR /app
21
 
22
+ # Install Python dependencies first (to leverage Docker cache)
23
  COPY --chown=user requirements.txt .
24
  RUN pip install --no-cache-dir --upgrade pip && \
25
+ pip install --no-cache-dir --user -r requirements.txt && \
26
+ pip install --no-cache-dir --user g4f[all]
 
 
 
27
 
28
  # Copy application code
29
  COPY --chown=user . .
30
 
31
+ # Expose port
32
+ EXPOSE 7860
33
+
34
  # Health check
35
+ HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \
36
  CMD curl -f http://localhost:7860/ || exit 1
37
 
38
+ # Run the application with better gunicorn settings
39
+ CMD ["gunicorn", "--workers", "3", \
40
+ "--timeout", "600", \
41
+ "--bind", "0.0.0.0:7860", \
42
+ "--worker-class", "gevent", \
43
+ "--worker-connections", "1000", \
44
+ "--max-requests", "1000", \
45
+ "--max-requests-jitter", "50", \
46
+ "--preload", \
47
+ "app:app"]