mirror-1 / Dockerfile
Juanoto2012's picture
Update Dockerfile
0a7ca9e verified
Raw
History Blame Contribute Delete
975 Bytes
# Usamos una imagen de Python ligera y estable
FROM python:3.10-slim
# 1. Instalar herramientas base
RUN apt-get update && apt-get install -y \
build-essential \
gcc \
g++ \
&& rm -rf /var/lib/apt/lists/*
# 2. Configurar un usuario sin privilegios (Requisito estricto de Hugging Face Spaces)
RUN useradd -m -u 1000 user
USER user
ENV HOME=/home/user \
PATH=/home/user/.local/bin:$PATH
WORKDIR $HOME/app
# 3. Copiar dependencias
COPY --chown=user requirements.txt .
# 4. TRUCO ANTI-TIMEOUT: Instalar llama-cpp-python pre-compilado para CPU
RUN pip install --no-cache-dir llama-cpp-python --extra-index-url https://abetlen.github.io/llama-cpp-python/whl/cpu
# 5. Instalar el resto de dependencias rápidamente
RUN pip install --no-cache-dir --prefer-binary -r requirements.txt
# 6. Copiar el resto de tu código
COPY --chown=user . .
# 7. Exponer puerto y arrancar Uvicorn
EXPOSE 7860
CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "7860"]