Spaces:
Sleeping
Sleeping
Panacea ICONO
commited on
Commit
·
0f25a65
1
Parent(s):
92ef857
Add application file
Browse files- Dockerfile +40 -0
- requirements.txt +7 -0
Dockerfile
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Read the doc: https://huggingface.co/docs/hub/spaces-sdks-docker
|
| 2 |
+
# you will also find guides on how best to write your Dockerfile
|
| 3 |
+
|
| 4 |
+
FROM python:3.11-slim AS builder
|
| 5 |
+
|
| 6 |
+
# Instalar herramientas necesarias solo en el stage de build
|
| 7 |
+
RUN apt-get update \
|
| 8 |
+
&& apt-get install -y --no-install-recommends build-essential gcc libffi-dev \
|
| 9 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 10 |
+
|
| 11 |
+
WORKDIR /app
|
| 12 |
+
|
| 13 |
+
# Copiar requirements e instalar en un prefijo temporal (/install)
|
| 14 |
+
COPY requirements.txt ./requirements.txt
|
| 15 |
+
RUN python -m pip install --upgrade pip setuptools wheel \
|
| 16 |
+
&& python -m pip install --no-cache-dir --prefix=/install -r requirements.txt
|
| 17 |
+
|
| 18 |
+
# --- Final minimal image ---
|
| 19 |
+
FROM python:3.11-slim
|
| 20 |
+
|
| 21 |
+
# Crear user no-root recomendado por Spaces
|
| 22 |
+
RUN useradd -m -u 1000 user
|
| 23 |
+
|
| 24 |
+
ENV PATH="/home/user/.local/bin:$PATH"
|
| 25 |
+
ENV PYTHONDONTWRITEBYTECODE=1
|
| 26 |
+
ENV PYTHONUNBUFFERED=1
|
| 27 |
+
|
| 28 |
+
WORKDIR /app
|
| 29 |
+
|
| 30 |
+
# Copiar los paquetes instalados desde el builder al entorno de runtime
|
| 31 |
+
COPY --from=builder /install /usr/local
|
| 32 |
+
|
| 33 |
+
# Copiar código y asignar al user no-root
|
| 34 |
+
COPY --chown=user:user . /app
|
| 35 |
+
|
| 36 |
+
USER user
|
| 37 |
+
|
| 38 |
+
EXPOSE 7860
|
| 39 |
+
|
| 40 |
+
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]
|
requirements.txt
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fastapi>=0.95.0
|
| 2 |
+
uvicorn[standard]>=0.22.0
|
| 3 |
+
huggingface_hub>=0.18.0
|
| 4 |
+
gradio>=4.8.0
|
| 5 |
+
python-dotenv>=1.0.0
|
| 6 |
+
requests>=2.28.0
|
| 7 |
+
gunicorn>=20.1.0
|