From b03851545e8f6849f96b38136b127895fe542620 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Mon, 10 Mar 2025 02:57:12 -0700 Subject: [PATCH] initial commit --- .gitignore | 2 ++ Containerfile | 11 +++++++++++ Makefile | 37 +++++++++++++++++++++++++++++++++++++ models/mistral7b.sha256 | 1 + scripts/update.py | 29 +++++++++++++++++++++++++++++ 5 files changed, 80 insertions(+) create mode 100644 .gitignore create mode 100644 Containerfile create mode 100644 Makefile create mode 100644 models/mistral7b.sha256 create mode 100755 scripts/update.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b645c86 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +models/*.gguf +out/* diff --git a/Containerfile b/Containerfile new file mode 100644 index 0000000..20f6242 --- /dev/null +++ b/Containerfile @@ -0,0 +1,11 @@ +FROM stagex/core-busybox@sha256:01b31cc07543733fbf6889e596427af943aba2780bc2f514a3d30bb290da7e2a AS core-busybox +FROM stagex/core-musl@sha256:23d0614f60449015add2369959c89a6ea08e208302773b9a0811ce1195afc3a4 AS core-musl +FROM stagex/core-gcc@sha256:02896413375c15cbff666fbab7c534caefc8936d53e167a6ea457a05c27e8096 AS core-gcc +FROM stagex/user-llama-cpp@sha256:04c47c26ef9dec4477317b686cb537a22ac3847c7f206ed17b05216b602f7ea0 AS user-llama-cpp +FROM scratch as shell +COPY --from=core-busybox . / +COPY --from=core-musl . / +COPY --from=core-gcc /usr/lib/ /usr/lib +COPY --from=user-llama-cpp . / +WORKDIR /workdir +CMD ["sh"] diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..edbdd29 --- /dev/null +++ b/Makefile @@ -0,0 +1,37 @@ +.DEFAULT_GOAL := +.PHONY: default +default: out/shell.digest + +.PHONY: models +models: \ + models/mistral7b.gguf + +out: + mkdir -p out + +models/mistral7b.gguf: models/mistral7b.sha256 + wget -nc -O $@ \ + https://huggingface.co/TheBloke/MetaMath-Mistral-7B-GGUF/resolve/main/metamath-mistral-7b.Q5_K_M.gguf || : + sha256sum --check --status < $< || mv $@ $@.fail + touch $@ + +out/shell.digest: Containerfile | out + docker build --target shell -f Containerfile -q . > $@ + +.PHONY: shell +shell: out/shell.digest models + docker run -it -v ./models:/workdir/models $(shell cat $<) + +.PHONY: reproduce +vm: out/shell.digest models + docker run -it -v ./models:/workdir/models $(shell cat $<) sh -c "\ + llama-cpp --version + " + +.PHONY: clean +clean: + rm -rf out + +.PHONY: update +update: + python3 scripts/update.py diff --git a/models/mistral7b.sha256 b/models/mistral7b.sha256 new file mode 100644 index 0000000..dfe539f --- /dev/null +++ b/models/mistral7b.sha256 @@ -0,0 +1 @@ +31ad02ec68e43ea73fc0372c29d6ba23f3da8ff3347a82b7fabd2b6c74287208 models/mistral7b.gguf diff --git a/scripts/update.py b/scripts/update.py new file mode 100755 index 0000000..cb9fd5b --- /dev/null +++ b/scripts/update.py @@ -0,0 +1,29 @@ +#!/usr/bin/env python3 +from requests import Session +from fileinput import FileInput + +target = "Containerfile" +source = "https://codeberg.org/stagex/stagex/raw/branch/main/digests/" +stages = ["core","user","bootstrap"] + +digests = {} +for stage in stages: + response = Session().get(f"{source}{stage}.txt") + for line in response.iter_lines(): + if not line: + continue + digest,name = line.decode("utf-8").split(" ") + digests[name] = digest + +with FileInput(target, inplace=True, backup='.bak') as f: + for line in f: + if line.startswith("FROM stagex/"): + name = line.split("/")[1].split(":")[0] + tag = line.split(":")[1].split("@")[0] + if name not in digests: + for stage in stages: + if f"{stage}-{name}" in digests: + name = f"{stage}-{name}" + print(f"FROM stagex/{name}:{tag}@sha256:{digests[name]} AS {name}") + else: + print(line,end='')