mike23415 commited on
Commit
29c1018
·
verified ·
1 Parent(s): 9d13a5a

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +8 -8
Dockerfile CHANGED
@@ -19,20 +19,20 @@ WORKDIR /app
19
 
20
  # Set environment variables
21
  ENV HF_HOME=/app/.cache \
22
- XDG_CACHE_HOME=/app/.cache
 
 
23
 
24
- # Install requirements
25
  COPY requirements.txt .
26
  RUN pip install --no-cache-dir -r requirements.txt
27
 
28
- # Download model as root then fix permissions
29
- RUN python -c "from transformers import GPT2LMHeadModel; \
30
- GPT2LMHeadModel.from_pretrained('gpt2-medium', use_safetensors=True)" && \
31
- chown -R appuser:appuser /app/.cache
32
-
33
  COPY --chown=appuser:appuser . .
34
 
35
  # Run as non-root user
36
  USER appuser
37
 
38
- CMD ["gunicorn", "--bind", "0.0.0.0:5000", "--timeout", "600", "app:app"]
 
 
 
19
 
20
  # Set environment variables
21
  ENV HF_HOME=/app/.cache \
22
+ XDG_CACHE_HOME=/app/.cache \
23
+ PYTHONUNBUFFERED=1 \
24
+ PYTHONFAULTHANDLER=1
25
 
26
+ # Install requirements first for caching
27
  COPY requirements.txt .
28
  RUN pip install --no-cache-dir -r requirements.txt
29
 
30
+ # Application code
 
 
 
 
31
  COPY --chown=appuser:appuser . .
32
 
33
  # Run as non-root user
34
  USER appuser
35
 
36
+ # Startup script with health check
37
+ CMD ["sh", "-c", \
38
+ "gunicorn --bind 0.0.0.0:5000 --timeout 600 --preload app:app"]