Spaces:
Build error
Build error
Create Dockerfile
Browse files- Dockerfile +53 -0
Dockerfile
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# ==========================================
|
| 2 |
+
# Etapa 1: Compilaci贸n de llama.cpp
|
| 3 |
+
# ==========================================
|
| 4 |
+
FROM ubuntu:22.04 AS builder
|
| 5 |
+
|
| 6 |
+
RUN apt-get update && apt-get install -y \
|
| 7 |
+
build-essential \
|
| 8 |
+
git \
|
| 9 |
+
cmake \
|
| 10 |
+
curl \
|
| 11 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 12 |
+
|
| 13 |
+
WORKDIR /build
|
| 14 |
+
|
| 15 |
+
# Clonar y compilar llama.cpp optimizado para CPU gen茅rica vCPU (Hugging Face)
|
| 16 |
+
RUN git clone https://github.com/ggerganov/llama.cpp.git && \
|
| 17 |
+
cd llama.cpp && \
|
| 18 |
+
cmake -B build -DGGML_NATIVE=OFF -DCMAKE_BUILD_TYPE=Release && \
|
| 19 |
+
cmake --build build --config Release -j $(nproc)
|
| 20 |
+
|
| 21 |
+
# ==========================================
|
| 22 |
+
# Etapa 2: Entorno de Ejecuci贸n Ligero
|
| 23 |
+
# ==========================================
|
| 24 |
+
FROM ubuntu:22.04 AS runtime
|
| 25 |
+
|
| 26 |
+
RUN apt-get update && apt-get install -y \
|
| 27 |
+
curl \
|
| 28 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 29 |
+
|
| 30 |
+
# Requisito estricto de HF Spaces: Crear un usuario no-root con UID 1000
|
| 31 |
+
RUN useradd -m -u 1000 user
|
| 32 |
+
USER user
|
| 33 |
+
ENV HOME=/home/user \
|
| 34 |
+
PATH=/home/user/.local/bin:$PATH
|
| 35 |
+
|
| 36 |
+
WORKDIR /home/user/app
|
| 37 |
+
|
| 38 |
+
# Copiar exclusivamente el binario del servidor desde la etapa de compilaci贸n
|
| 39 |
+
COPY --chown=user:user --from=builder /build/llama.cpp/build/bin/llama-server ./llama-server
|
| 40 |
+
|
| 41 |
+
# Descargar el modelo optimizado en formato GGUF durante el Build Time
|
| 42 |
+
# Nota: Usamos Qwen2.5-1.5B-Instruct (o 0.5B) por su brutal capacidad multiling眉e y velocidad instant谩nea en CPU.
|
| 43 |
+
# Puedes sustituir esta URL por cualquier modelo .gguf compatible (como las conversiones de Liquid LFM si est谩n mapeadas).
|
| 44 |
+
RUN curl -L -o model.gguf "https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF/resolve/main/qwen2.5-1.5b-instruct-q4_k_m.gguf"
|
| 45 |
+
|
| 46 |
+
# Requisito estricto de HF Spaces: Exponer obligatoriamente el puerto 7860
|
| 47 |
+
EXPOSE 7860
|
| 48 |
+
|
| 49 |
+
# Configuraci贸n del motor de inferencia
|
| 50 |
+
# --host 0.0.0.0: Escuchar en todas las interfaces de red del contenedor
|
| 51 |
+
# --port 7860: Puerto requerido por Hugging Face
|
| 52 |
+
# -c 2048: Tama帽o de contexto optimizado (ahorra memoria y acelera el procesamiento del prompt)
|
| 53 |
+
CMD ["./llama-server", "--host", "0.0.0.0", "--port", "7860", "-m", "model.gguf", "-c", "2048"]
|