ServerX commited on
Commit
387c403
·
verified ·
1 Parent(s): 64a69cd

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +19 -5
Dockerfile CHANGED
@@ -2,16 +2,30 @@ FROM python:3.9-slim
2
 
3
  WORKDIR /app
4
 
 
5
  RUN apt-get update && apt-get install -y --no-install-recommends \
6
  gcc \
7
  python3-dev \
8
  && rm -rf /var/lib/apt/lists/*
9
 
10
- RUN pip install --no-cache-dir gunicorn==20.1.0
 
 
 
11
 
12
- COPY requirements.txt .
13
- RUN pip install --no-cache-dir -r requirements.txt
 
 
 
 
14
 
15
- COPY . .
 
 
16
 
17
- CMD ["gunicorn", "--bind", "0.0.0.0:7860", "--timeout", "300", "app:app"]
 
 
 
 
 
2
 
3
  WORKDIR /app
4
 
5
+ # Installazione dipendenze di sistema
6
  RUN apt-get update && apt-get install -y --no-install-recommends \
7
  gcc \
8
  python3-dev \
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
+ # Configurazione utente sicura
12
+ RUN useradd -m -u 1000 user && \
13
+ chown -R user:user /app
14
+ USER user
15
 
16
+ # Variabili d'ambiente
17
+ ENV PYTHONUNBUFFERED=1 \
18
+ PYTHONDONTWRITEBYTECODE=1 \
19
+ PORT=7860 \
20
+ TIMEOUT=600 \
21
+ PATH="/home/user/.local/bin:${PATH}"
22
 
23
+ # Installazione dipendenze
24
+ COPY --chown=user requirements.txt .
25
+ RUN pip install --no-cache-dir --user -r requirements.txt
26
 
27
+ # Copia codice
28
+ COPY --chown=user . .
29
+
30
+ # Comando di avvio ottimizzato
31
+ CMD ["gunicorn", "--bind", "0.0.0.0:${PORT}", "--timeout", "${TIMEOUT}", "--preload", "--workers", "2", "app:app"]