File size: 2,437 Bytes
c41af55
 
4b90830
c41af55
 
4b90830
 
c41af55
 
 
 
 
 
 
2df2093
c41af55
 
4b90830
c41af55
 
 
2df2093
c41af55
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b90830
 
 
 
2df2093
 
c41af55
2df2093
32d4dff
aa11c99
2df2093
32d4dff
2df2093
c41af55
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
FROM ubuntu:24.04

# โ”€โ”€ System dependencies โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
        build-essential \
        cmake \
        curl \
        wget \
        ca-certificates \
        python3 \
        python3-pip \
        python3-dev \
        python3-venv \
        git \
    && rm -rf /var/lib/apt/lists/*

# โ”€โ”€ Python env โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"

# PyTorch CPU (conversion only โ€” no GPU needed)
RUN pip install --upgrade pip && \
    pip install --no-cache-dir \
        torch==2.5.1+cpu \
        --index-url https://download.pytorch.org/whl/cpu

# HF ecosystem + conversion deps
RUN pip install --no-cache-dir \
        transformers \
        huggingface_hub[cli] \
        safetensors \
        sentencepiece \
        tiktoken \
        gguf \
        numpy \
        tqdm

# โ”€โ”€ Clone llama.cpp (fast โ€” no compile here, that happens at container start) โ”€
# We need the source for two things:
#   1. convert_hf_to_gguf.py (Python, runs immediately)
#   2. llama-quantize source (compiled at runtime to avoid build timeout)
RUN git clone --depth 1 https://github.com/ggml-org/llama.cpp.git /opt/llama.cpp
RUN pip install --no-cache-dir -r /opt/llama.cpp/requirements.txt || true

# โ”€โ”€ Runtime secrets โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
ENV HF_TOKEN=""
ENV HF_DATASET_REPO=""
ENV LLAMA_CPP_DIR="/opt/llama.cpp"

# โ”€โ”€ Working directories โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
RUN mkdir -p /workspace/model-fp8 \
             /workspace/model-bf16 \
             /workspace/model-gguf \
             /workspace/output

WORKDIR /workspace

COPY scripts/ /workspace/scripts/
RUN chmod +x /workspace/scripts/*.sh

ENTRYPOINT ["/bin/bash", "/workspace/scripts/entrypoint.sh"]