Update Dockerfile
Browse files- Dockerfile +36 -4
Dockerfile
CHANGED
|
@@ -1,16 +1,48 @@
|
|
| 1 |
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
-
|
| 3 |
|
| 4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
RUN useradd -m -u 1000 user
|
| 7 |
USER user
|
| 8 |
-
ENV PATH="/home/user/.local/bin:$PATH"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
WORKDIR /app
|
| 11 |
|
|
|
|
| 12 |
COPY --chown=user ./requirements.txt requirements.txt
|
| 13 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 14 |
|
|
|
|
| 15 |
COPY --chown=user . /app
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
FROM python:3.11-slim
|
| 3 |
|
| 4 |
+
# Install ffmpeg + system deps as ROOT (prima di switchare utente)
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
ffmpeg \
|
| 7 |
+
curl \
|
| 8 |
+
ca-certificates \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
|
| 11 |
+
# Verifica ffmpeg installato
|
| 12 |
+
RUN ffmpeg -version && ffprobe -version
|
| 13 |
+
|
| 14 |
+
# Crea utente non-root (richiesto da HF Spaces)
|
| 15 |
RUN useradd -m -u 1000 user
|
| 16 |
USER user
|
| 17 |
+
ENV PATH="/home/user/.local/bin:$PATH" \
|
| 18 |
+
PYTHONUNBUFFERED=1 \
|
| 19 |
+
PYTHONDONTWRITEBYTECODE=1 \
|
| 20 |
+
PIP_NO_CACHE_DIR=1 \
|
| 21 |
+
PIP_DISABLE_PIP_VERSION_CHECK=1
|
| 22 |
|
| 23 |
WORKDIR /app
|
| 24 |
|
| 25 |
+
# Copia e installa requirements
|
| 26 |
COPY --chown=user ./requirements.txt requirements.txt
|
| 27 |
RUN pip install --no-cache-dir --upgrade -r requirements.txt
|
| 28 |
|
| 29 |
+
# Copia codice
|
| 30 |
COPY --chown=user . /app
|
| 31 |
+
|
| 32 |
+
# Crea cartelle necessarie con permessi corretti
|
| 33 |
+
RUN mkdir -p /tmp/public && chmod 777 /tmp/public
|
| 34 |
+
|
| 35 |
+
EXPOSE 7860
|
| 36 |
+
|
| 37 |
+
# Healthcheck opzionale
|
| 38 |
+
HEALTHCHECK --interval=30s --timeout=10s --start-period=20s --retries=3 \
|
| 39 |
+
CMD curl -f http://localhost:7860/health || exit 1
|
| 40 |
+
|
| 41 |
+
# Avvio: 1 worker (per condividere JOBS dict in memoria), no reload
|
| 42 |
+
CMD ["uvicorn", "app:app", \
|
| 43 |
+
"--host", "0.0.0.0", \
|
| 44 |
+
"--port", "7860", \
|
| 45 |
+
"--workers", "1", \
|
| 46 |
+
"--log-level", "info", \
|
| 47 |
+
"--timeout-keep-alive", "120", \
|
| 48 |
+
"--limit-concurrency", "100"]
|