Spaces:
Build error
Build error
- Dockerfile +9 -5
Dockerfile
CHANGED
|
@@ -1,17 +1,21 @@
|
|
| 1 |
# --- 1. Use the official Ollama pre-built image ---
|
| 2 |
FROM ollama/ollama
|
| 3 |
|
| 4 |
-
# --- 2. Install Python
|
| 5 |
# The base image is Debian, so we can use apt-get
|
| 6 |
-
RUN apt-get update && apt-get install -y python3 python3-pip
|
| 7 |
-
RUN pip install huggingface_hub
|
| 8 |
|
| 9 |
-
# --- 3. Download the GGUF model ---
|
| 10 |
WORKDIR /app
|
| 11 |
COPY download_model.py .
|
| 12 |
ARG HF_TOKEN
|
|
|
|
|
|
|
| 13 |
RUN --mount=type=secret,id=HF_TOKEN \
|
| 14 |
-
python3
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
# --- 4. Create the Ollama "Modelfile" ---
|
| 17 |
# This file tells Ollama to use our downloaded GGUF
|
|
|
|
| 1 |
# --- 1. Use the official Ollama pre-built image ---
|
| 2 |
FROM ollama/ollama
|
| 3 |
|
| 4 |
+
# --- 2. Install Python, pip, and the venv package ---
|
| 5 |
# The base image is Debian, so we can use apt-get
|
| 6 |
+
RUN apt-get update && apt-get install -y python3 python3-pip python3-venv
|
|
|
|
| 7 |
|
| 8 |
+
# --- 3. Download the GGUF model using a safe venv ---
|
| 9 |
WORKDIR /app
|
| 10 |
COPY download_model.py .
|
| 11 |
ARG HF_TOKEN
|
| 12 |
+
# This command creates a venv, installs hf_hub, downloads the model,
|
| 13 |
+
# and then the venv is discarded, keeping the system clean.
|
| 14 |
RUN --mount=type=secret,id=HF_TOKEN \
|
| 15 |
+
sh -c 'python3 -m venv /tmp/downloader-venv && \
|
| 16 |
+
. /tmp/downloader-venv/bin/activate && \
|
| 17 |
+
pip install huggingface_hub && \
|
| 18 |
+
python3 download_model.py'
|
| 19 |
|
| 20 |
# --- 4. Create the Ollama "Modelfile" ---
|
| 21 |
# This file tells Ollama to use our downloaded GGUF
|