initial commit

This commit is contained in:
Lance Vick 2025-03-10 02:57:12 -07:00
commit b03851545e
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
5 changed files with 80 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
models/*.gguf
out/*

11
Containerfile Normal file
View File

@ -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"]

37
Makefile Normal file
View File

@ -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

1
models/mistral7b.sha256 Normal file
View File

@ -0,0 +1 @@
31ad02ec68e43ea73fc0372c29d6ba23f3da8ff3347a82b7fabd2b6c74287208 models/mistral7b.gguf

29
scripts/update.py Executable file
View File

@ -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='')