AshenClock commited on
Commit
d2bdf67
·
verified ·
1 Parent(s): fee6ba9

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +13 -13
Dockerfile CHANGED
@@ -1,26 +1,26 @@
1
- FROM python:3.12-slim
 
2
 
3
- # Installa distutils (e setuptools se vuoi)
4
- RUN apt-get update && \
5
- apt-get install -y --no-install-recommends \
6
- python3-distutils \
7
- python3-setuptools \
8
- && rm -rf /var/lib/apt/lists/*
9
-
10
- # Crea utente non privilegiato
11
  RUN useradd -m -u 1000 user
12
  USER user
 
13
  ENV PATH="/home/user/.local/bin:$PATH"
14
 
 
15
  WORKDIR /app
16
 
17
- # Copia il file requirements.txt e installa i pacchetti
18
  COPY --chown=user: ./requirements.txt requirements.txt
19
- RUN pip install --upgrade pip
 
20
  RUN pip install --no-cache-dir -r requirements.txt
21
 
22
- # Copia il resto del codice
23
  COPY --chown=user: . /app
24
 
 
25
  EXPOSE 7860
26
- CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
 
 
 
1
+ # Usa un'immagine Python 3.11, più stabile e compatibile con molte librerie ML
2
+ FROM python:3.11-slim
3
 
4
+ # Crea un utente non-root per sicurezza
 
 
 
 
 
 
 
5
  RUN useradd -m -u 1000 user
6
  USER user
7
+ # Aggiungi la directory dei binari dell'utente al PATH
8
  ENV PATH="/home/user/.local/bin:$PATH"
9
 
10
+ # Imposta la directory di lavoro
11
  WORKDIR /app
12
 
13
+ # Copia solo il file dei requisiti prima, per sfruttare la cache di Docker
14
  COPY --chown=user: ./requirements.txt requirements.txt
15
+
16
+ # Installa i pacchetti Python
17
  RUN pip install --no-cache-dir -r requirements.txt
18
 
19
+ # Copia tutto il resto del codice dell'applicazione
20
  COPY --chown=user: . /app
21
 
22
+ # Esponi la porta che Hugging Face Spaces si aspetta (o la tua porta)
23
  EXPOSE 7860
24
+
25
+ # Comando per avviare l'applicazione
26
+ CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]