andevs commited on
Commit
1cb2a2c
·
verified ·
1 Parent(s): f232acf

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +20 -1
Dockerfile CHANGED
@@ -2,11 +2,30 @@ FROM python:3.11-slim
2
 
3
  WORKDIR /app
4
 
 
 
 
 
 
 
 
 
5
  COPY requirements.txt .
6
  RUN pip install --no-cache-dir -r requirements.txt
7
 
 
8
  COPY . .
9
 
 
 
 
 
 
 
 
 
 
10
  EXPOSE 7860
11
 
12
- CMD ["gunicorn", "app:app", "--workers", "2", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:7860"]
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Install system dependencies
6
+ RUN apt-get update && apt-get install -y \
7
+ gcc \
8
+ g++ \
9
+ curl \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy requirements first for better caching
13
  COPY requirements.txt .
14
  RUN pip install --no-cache-dir -r requirements.txt
15
 
16
+ # Copy application
17
  COPY . .
18
 
19
+ # Create non-root user
20
+ RUN useradd -m -u 1000 appuser && chown -R appuser:appuser /app
21
+ USER appuser
22
+
23
+ # Health check
24
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
25
+ CMD python -c "import requests; r = requests.get('http://localhost:7860/health', timeout=2); exit(0 if r.status_code == 200 else 1)"
26
+
27
+ # Expose port
28
  EXPOSE 7860
29
 
30
+ # Run with gunicorn for production
31
+ CMD ["gunicorn", "app:app", "--workers", "4", "--worker-class", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:7860", "--timeout", "120", "--keep-alive", "5"]