Repository navigation
Expand file tree
/
Copy pathDockerfile.base
More file actions
74 lines (61 loc) · 2.92 KB
/
Copy pathDockerfile.base
File metadata and controls
74 lines (61 loc) · 2.92 KB
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
64
65
66
67
68
69
70
71
72
73
74
# base image that holds everything heavy and slow-changing (node-llama-cpp, the model, scc)
# pushed to GHCR by hand, the thin Dockerfile builds the action code on top of it
# see "Rebuilding the base image" in CONTRIBUTING.md for when and how
ARG MODEL_REPO=unsloth/gemma-4-E2B-it-GGUF
ARG MODEL_FILE=gemma-4-E2B-it-Q4_K_M.gguf
ARG MODEL_REVISION=0314792d7f1f7e229411f620751375812bb9faf2
ARG MODEL_SHA256=740185b21d22ceb83a11c3aa62ad5842ef32c70f6096d756bbee85a1e4ec34b8
# must match the version package-lock.json resolves, the thin Dockerfile checks this
ARG NODE_LLAMA_CPP_VERSION=3.21.1
# stage 1: model
# download the model GGUF and cache
FROM debian:bookworm-slim AS model
ARG MODEL_REPO
ARG MODEL_FILE
ARG MODEL_REVISION
ARG MODEL_SHA256
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
RUN mkdir -p /opt/models \
&& curl -fSL --retry 3 \
"https://huggingface.co/${MODEL_REPO}/resolve/${MODEL_REVISION}/${MODEL_FILE}?download=true" \
-o /opt/models/model.gguf \
&& echo "${MODEL_SHA256} /opt/models/model.gguf" | sha256sum -c -
# stage 2: base
FROM node:20-bookworm-slim AS base
ARG MODEL_FILE
ARG MODEL_REVISION
ARG NODE_LLAMA_CPP_VERSION
LABEL org.opencontainers.image.source=https://github.com/DSACMS/automated-codejson-generator \
org.opencontainers.image.description="Base image for automated-codejson-generator: node-llama-cpp, the model and scc" \
gov.cms.acg.node-llama-cpp.version="${NODE_LLAMA_CPP_VERSION}" \
gov.cms.acg.model.file="${MODEL_FILE}" \
gov.cms.acg.model.revision="${MODEL_REVISION}"
RUN apt-get update && apt-get install -y --no-install-recommends \
git \
ca-certificates \
curl \
&& rm -rf /var/lib/apt/lists/*
# scc used for the laborHours estimate
RUN curl -fSL --retry 3 \
"https://github.com/boyter/scc/releases/download/v3.4.0/scc_Linux_x86_64.tar.gz" \
-o /tmp/scc.tar.gz \
&& echo "8f812d25c237112ea74a4285f0699b7a2c448d70c5e63e370d2d199d38b13eda /tmp/scc.tar.gz" | sha256sum -c - \
&& tar -xzf /tmp/scc.tar.gz -C /usr/local/bin scc \
&& rm /tmp/scc.tar.gz \
&& chmod +x /usr/local/bin/scc \
&& scc --version
WORKDIR /app
# node-llama-cpp is the only runtime dependency rollup leaves out of dist/index.js
# the prebuilt linux-x64 binaries come in as optional deps, so skip the source download
# the thin image copies its own package.json over this placeholder one
ENV NODE_LLAMA_CPP_SKIP_DOWNLOAD=true
RUN echo '{"private": true}' > package.json \
&& npm install --omit=dev --no-audit --no-fund --no-package-lock \
"node-llama-cpp@${NODE_LLAMA_CPP_VERSION}" \
&& npm cache clean --force \
&& test "$(node -p "require('/app/node_modules/node-llama-cpp/package.json').version")" = "${NODE_LLAMA_CPP_VERSION}"
COPY --from=model /opt/models/model.gguf /opt/models/model.gguf
ENV ACG_MODEL_PATH=/opt/models/model.gguf