Docker: publish the images from 0.2.1 (workflow, signed-feed fetch, local script)
- .github/workflows/docker-images.yml: manual only (workflow_dispatch) with the release tag as input; a plan job lists the flavors the release has an engine package for; one job per flavor builds the image and, only with push on, pushes ghcr.io/niko1221/strata:<version>-<flavor> and latest-<flavor> with GITHUB_TOKEN (packages: write). - docker/fetch-engines.py: downloads the engine package from the release and checks it against the signed update feed (feed signature, archive size and SHA-256, manifest hash, package signature, every file), the same code as `strata update`. Flavors cuda13, cuda12, rocm-gfx120x, rocm-gfx110x, rocm-gfx1151 (the halo package), sycl (only if the feed lists one). - docker/publish.sh: the same steps by hand (fetch, build, start check, push only with --push). - Fix: docker/build.sh did not copy docs/TERMINAL_LAUNCH.md, which package_terminal.py needs; no image could be built from a clean tree. - Dockerfile: OCI source/url/documentation labels (ghcr links the package to the repository). - Compose files and docs/DOCKER.md name the 0.2.1 tags on ghcr.io; DOCKER.md has a maintainers section. Tests for the scripts, the workflow and the fetch.
This commit is contained in:
1 parent
74e25e165b
commit
578bb6aa7a
13 files changed
+578
-41
No files matched your search
@@ -0,0 +1,114 @@
|
||||
name: Docker images
|
||||
|
||||
# Builds the Strata container images of one release from its engine packages and pushes them to ghcr.io.
|
||||
# Run by hand only (Actions tab -> Docker images -> Run workflow). Nothing starts it on its own.
|
||||
#
|
||||
# For each flavor the job downloads the engine package from the release and checks it against the signed update feed
|
||||
# (docker/fetch-engines.py: the feed's Ed25519 signature, the archive's SHA-256, the manifest hash, the package signature,
|
||||
# every file's hash), builds the image with docker/build.sh and, only when "push" is on, pushes
|
||||
# ghcr.io/niko1221/strata:<version>-<flavor> and ghcr.io/niko1221/strata:latest-<flavor>
|
||||
# The first run with "push" off builds everything without publishing it (a dry run).
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
release_tag:
|
||||
description: 'Release tag whose engine packages go into the images (for example v0.2.1)'
|
||||
required: true
|
||||
type: string
|
||||
flavors:
|
||||
description: 'Flavors to build, comma separated (empty: every flavor the release has a package for)'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
push:
|
||||
description: 'Push the images to ghcr.io (off: build only, nothing is published)'
|
||||
required: true
|
||||
default: false
|
||||
type: boolean
|
||||
latest:
|
||||
description: 'Also move the latest-<flavor> tags (turn off for a pre-release or a test)'
|
||||
required: true
|
||||
default: true
|
||||
type: boolean
|
||||
source_ref:
|
||||
description: 'Git ref of the Dockerfile and the Terminal sources (empty: the release tag)'
|
||||
required: false
|
||||
default: ''
|
||||
type: string
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
env:
|
||||
IMAGE: ghcr.io/niko1221/strata
|
||||
|
||||
jobs:
|
||||
plan:
|
||||
runs-on: ubuntu-24.04
|
||||
outputs:
|
||||
flavors: ${{ steps.list.outputs.flavors }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.source_ref || inputs.release_tag }}
|
||||
- name: Which flavors does the release have a package for
|
||||
id: list
|
||||
env:
|
||||
WANT: ${{ inputs.flavors }}
|
||||
TAG: ${{ inputs.release_tag }}
|
||||
run: |
|
||||
set -eu
|
||||
args="--release-tag $TAG --list --skip-missing"
|
||||
[ -n "$WANT" ] && args="$args --flavors $WANT"
|
||||
python3 docker/fetch-engines.py $args > list.tsv
|
||||
cat list.tsv
|
||||
flavors=$(awk -F'\t' '$3 != "SKIP" {printf "%s\"%s\"", (n++ ? "," : ""), $1}' list.tsv)
|
||||
[ -n "$flavors" ] || { echo "the release has no engine package for any requested flavor"; exit 1; }
|
||||
echo "flavors=[$flavors]" >> "$GITHUB_OUTPUT"
|
||||
|
||||
image:
|
||||
needs: plan
|
||||
runs-on: ubuntu-24.04
|
||||
timeout-minutes: 120
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
max-parallel: 3
|
||||
matrix:
|
||||
flavor: ${{ fromJSON(needs.plan.outputs.flavors) }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ inputs.source_ref || inputs.release_tag }}
|
||||
- name: Free disk space (the runner has about 14 GB; a package plus its image needs about 10 GB)
|
||||
run: |
|
||||
sudo rm -rf /usr/share/dotnet /usr/local/lib/android /opt/ghc /opt/hostedtoolcache/CodeQL || true
|
||||
docker system prune -af >/dev/null 2>&1 || true
|
||||
df -h /
|
||||
- name: Log in to ghcr.io
|
||||
if: ${{ inputs.push }}
|
||||
env:
|
||||
REGISTRY_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
REGISTRY_USER: ${{ github.actor }}
|
||||
run: printf '%s' "$REGISTRY_TOKEN" | docker login ghcr.io -u "$REGISTRY_USER" --password-stdin
|
||||
- name: Fetch, verify, build (and push when push is on)
|
||||
env:
|
||||
TAG: ${{ inputs.release_tag }}
|
||||
FLAVOR: ${{ matrix.flavor }}
|
||||
PUSH: ${{ inputs.push && '--push' || '' }}
|
||||
LATEST: ${{ !inputs.latest && '--no-latest' || '' }}
|
||||
run: |
|
||||
docker/publish.sh --release-tag "$TAG" --flavors "$FLAVOR" --image "$IMAGE" $PUSH $LATEST
|
||||
- name: Summary
|
||||
if: ${{ always() }}
|
||||
run: |
|
||||
{
|
||||
echo "### ${{ matrix.flavor }}"
|
||||
echo "- release: ${{ inputs.release_tag }}, pushed: ${{ inputs.push }}"
|
||||
echo "- image: \`$IMAGE:${INPUT_TAG#v}-${{ matrix.flavor }}\`"
|
||||
} >> "$GITHUB_STEP_SUMMARY"
|
||||
env:
|
||||
INPUT_TAG: ${{ inputs.release_tag }}
|
||||
+5
-2
@@ -5,13 +5,13 @@
|
||||
#
|
||||
# Build it with docker/build.sh (it assembles the build context: the Terminal sources and the package folder):
|
||||
#
|
||||
# docker/build.sh --flavor cuda --engine /path/to/0.2.0-linux-x86_64-cuda-cuda13 --tag strata:0.2.0-cuda13
|
||||
# docker/build.sh --flavor cuda --engine /path/to/0.1.45.3-linux-x86_64-cuda-cuda13 --tag strata:0.2.1-cuda13
|
||||
#
|
||||
# Plain `docker build` also works when the context folder has this layout (build.sh makes it):
|
||||
# terminal-src/ the files package_terminal.py needs (packaging/, strata_cli/, strata_control/, serve/, tools/, data/, ...)
|
||||
# engine/ one folder per engine package, exactly as `package_engine.py` wrote it (engine-component.json inside)
|
||||
# docker/ entrypoint.sh, strata-wrapper.sh, healthcheck.sh
|
||||
# docker build --build-arg FLAVOR=cuda -t strata:0.2.0-cuda13 -f Dockerfile <context>
|
||||
# docker build --build-arg FLAVOR=cuda -t strata:0.2.1-cuda13 -f Dockerfile <context>
|
||||
#
|
||||
# FLAVOR picks the small set of system libraries the runtime image adds and its base:
|
||||
# cuda NVIDIA: the engine package carries cudart/cublas; the driver's libcuda comes from nvidia-container-toolkit
|
||||
@@ -111,6 +111,9 @@ VOLUME ["/data"]
|
||||
EXPOSE 8080
|
||||
|
||||
LABEL org.opencontainers.image.title="Strata" \
|
||||
org.opencontainers.image.source="https://github.com/Niko1221/Strata" \
|
||||
org.opencontainers.image.url="https://github.com/Niko1221/Strata" \
|
||||
org.opencontainers.image.documentation="https://github.com/Niko1221/Strata/blob/main/docs/DOCKER.md" \
|
||||
org.opencontainers.image.description="Strata local LLM server (Terminal + engine package), flavor ${FLAVOR}" \
|
||||
org.opencontainers.image.version="${STRATA_VERSION}" \
|
||||
org.opencontainers.image.licenses="see LICENSE" \
|
||||
|
||||
+4
-4
@@ -2,9 +2,9 @@
|
||||
# Build a Strata image from an engine component package. Run it on a Linux x86_64 machine with Docker (it needs the internet
|
||||
# for the base image and for the Terminal's pinned Python and locked wheels; the engine package is local).
|
||||
#
|
||||
# docker/build.sh --flavor cuda --engine ~/pkgs/0.2.0-linux-x86_64-cuda-cuda13 --tag strata:0.2.0-cuda13
|
||||
# docker/build.sh --flavor hip --engine ~/pkgs/0.2.0-linux-x86_64-hip-gfx120X --tag strata:0.2.0-rocm-gfx120x
|
||||
# docker/build.sh --flavor sycl --engine ~/pkgs/0.2.0-linux-x86_64-sycl --tag strata:0.2.0-sycl
|
||||
# docker/build.sh --flavor cuda --engine ~/pkgs/0.1.45.3-linux-x86_64-cuda-cuda13 --tag strata:0.2.1-cuda13
|
||||
# docker/build.sh --flavor hip --engine ~/pkgs/0.1.45.3-linux-x86_64-hip-gfx120X --tag strata:0.2.1-rocm-gfx120x
|
||||
# docker/build.sh --flavor sycl --engine ~/pkgs/0.1.45.3-linux-x86_64-sycl --tag strata:0.2.1-sycl
|
||||
#
|
||||
# --engine is the package FOLDER that packaging/package_engine.py wrote (engine-component.json inside). It can be given more than
|
||||
# once to put several packages in one image (the Terminal picks the one that fits the card).
|
||||
@@ -58,7 +58,7 @@ trap cleanup EXIT
|
||||
|
||||
# 1. the Terminal's sources: exactly what packaging/package_terminal.py copies (the working tree, so local edits are in the image)
|
||||
cd "$repo"
|
||||
paths="packaging bin strata.py strata_control strata_cli serve requirements.txt requirements-monitor.txt docs/MANAGEMENT_PROTOCOL.md data setup.py ref/load.py CMakeLists.txt"
|
||||
paths="packaging bin strata.py strata_control strata_cli serve requirements.txt requirements-monitor.txt docs/MANAGEMENT_PROTOCOL.md docs/TERMINAL_LAUNCH.md data setup.py ref/load.py CMakeLists.txt"
|
||||
if git rev-parse --git-dir >/dev/null 2>&1; then
|
||||
# shellcheck disable=SC2086
|
||||
{ git ls-files -z -- $paths ':(glob)tools/*.py'; } | tar --null -T - -cf - | tar -xf - -C "$ctx/terminal-src"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Copy to .env next to the compose file you use. Every line is optional.
|
||||
# STRATA_IMAGE=ghcr.io/niko1221/strata:0.2.0-cuda13 # TODO(owner): where the images will be published
|
||||
# STRATA_IMAGE=strata:0.2.1-cuda13 # only to use an image you built yourself (docker/build.sh); the default is the published ghcr.io/niko1221/strata image
|
||||
# MODEL=IQ3_XXS
|
||||
# MODEL_PATH=/models # with a volume line - /srv/gguf/IQ3_XXS:/models:ro
|
||||
# CONTEXT=32k
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
# cp .env.example .env
|
||||
# docker compose -f docker-compose.amd.yml up -d
|
||||
#
|
||||
# TODO(owner): registry name. Until the images are published, build them (docker/build.sh) and use the local tag.
|
||||
# Images: ghcr.io/niko1221/strata (published from 0.2.1 on). To use one you built yourself: STRATA_IMAGE=strata:0.2.1-<flavor> docker compose up -d
|
||||
services:
|
||||
strata:
|
||||
image: ${STRATA_IMAGE:-strata:0.2.0-rocm-gfx120x}
|
||||
image: ${STRATA_IMAGE:-ghcr.io/niko1221/strata:0.2.1-rocm-gfx120x}
|
||||
container_name: strata
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
|
||||
@@ -4,10 +4,10 @@
|
||||
# cp .env.example .env
|
||||
# docker compose -f docker-compose.intel.yml up -d
|
||||
#
|
||||
# TODO(owner): registry name. Until the images are published, build them (docker/build.sh) and use the local tag.
|
||||
# Images: ghcr.io/niko1221/strata (published from 0.2.1 on). To use one you built yourself: STRATA_IMAGE=strata:0.2.1-<flavor> docker compose up -d
|
||||
services:
|
||||
strata:
|
||||
image: ${STRATA_IMAGE:-strata:0.2.0-sycl}
|
||||
image: ${STRATA_IMAGE:-ghcr.io/niko1221/strata:0.2.1-sycl}
|
||||
container_name: strata
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
# docker compose -f docker-compose.nvidia.yml logs -f # the first start downloads the model (resumable)
|
||||
#
|
||||
# Image: cuda13 for RTX 20-50 with driver 580 or newer; cuda12 for Pascal / Volta (GTX 10, Tesla P100, V100) or drivers 575-579.
|
||||
# TODO(owner): registry name. Until the images are published, build them (docker/build.sh) and use the local tag.
|
||||
# Images: ghcr.io/niko1221/strata (published from 0.2.1 on). To use one you built yourself: STRATA_IMAGE=strata:0.2.1-<flavor> docker compose up -d
|
||||
services:
|
||||
strata:
|
||||
image: ${STRATA_IMAGE:-strata:0.2.0-cuda13}
|
||||
image: ${STRATA_IMAGE:-ghcr.io/niko1221/strata:0.2.1-cuda13}
|
||||
container_name: strata
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Fetch the engine packages for the Docker images from a release, checked against the signed update feed.
|
||||
|
||||
python3 docker/fetch-engines.py --release-tag v0.2.1 --flavors cuda13,cuda12,rocm-gfx120x --out ./pkgs
|
||||
python3 docker/fetch-engines.py --source /path/to/release-folder --flavors cuda13 --out ./pkgs
|
||||
python3 docker/fetch-engines.py --release-tag v0.2.1 --list
|
||||
|
||||
What it does, in the same order and with the same code as `strata update`:
|
||||
|
||||
1. reads strata-feed.json and strata-feed.json.sig from the release (GitHub release assets, or a folder / URL given with --source)
|
||||
and checks the Ed25519 signature against the public key in strata_control/update_keys.json;
|
||||
2. for each flavor picks the linux-x86_64 engine package the feed lists for it (see FLAVORS);
|
||||
3. downloads the archive and checks its size and SHA-256 against the signed feed (a mismatch deletes the file and stops);
|
||||
4. unpacks it (the archive's names and links are checked, its size may not exceed what the feed declares), checks that the
|
||||
manifest is the one the feed names and says what the feed says, then the package signature and every file's hash.
|
||||
|
||||
Stdout gets one line per flavor, tab separated: `<flavor> <build.sh --flavor value> <package folder>`; everything else goes to
|
||||
stderr. Nothing is installed anywhere and nothing is pushed. Needs only the Python standard library and this repository.
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import shutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(REPO_ROOT))
|
||||
|
||||
from strata_control import engine_component as ec, feed as feedmod, signing, transfer, updater # noqa: E402
|
||||
|
||||
#: image flavor (the tag suffix) -> (feed backend, feed variant or None for any, docker/build.sh --flavor)
|
||||
FLAVORS = {
|
||||
"cuda13": ("cuda", "cuda13", "cuda"),
|
||||
"cuda12": ("cuda", "cuda12", "cuda"),
|
||||
"rocm-gfx120x": ("hip", "rx9070", "hip"), # RX 9000, Radeon AI PRO R9700 (gfx1200 / gfx1201)
|
||||
"rocm-gfx110x": ("hip", "rx7900", "hip"), # RX 7000 (gfx1100 / gfx1101 / gfx1102)
|
||||
"rocm-gfx1151": ("hip", "halo", "hip"), # Strix Halo (gfx1151)
|
||||
"sycl": ("sycl", None, "sycl"), # Intel Arc; only when the release has a Linux SYCL package
|
||||
}
|
||||
PLATFORM = "linux-x86_64"
|
||||
|
||||
|
||||
def log(message: str) -> None:
|
||||
print(message, file=sys.stderr, flush=True)
|
||||
|
||||
|
||||
def pick(feed: feedmod.Feed, flavor: str) -> feedmod.EnginePackage | None:
|
||||
backend, variant, _ = FLAVORS[flavor]
|
||||
found = [p for p in feed.engine if p.platform == PLATFORM and p.backend == backend and (variant is None or p.variant == variant)]
|
||||
if not found:
|
||||
return None
|
||||
return max(found, key=lambda p: feedmod.version_key(p.version))
|
||||
|
||||
|
||||
def fetch_one(feed: feedmod.Feed, pkg: feedmod.EnginePackage, out: Path, trusted: dict) -> Path:
|
||||
folder = out / updater.folder_name(pkg)
|
||||
archive = out / ".partial" / pkg.url.rsplit("/", 1)[-1]
|
||||
if folder.is_dir() and (folder / ec.MANIFEST).is_file() and transfer.sha256_file(folder / ec.MANIFEST) == pkg.manifest_sha256:
|
||||
log(f" {folder.name}: already unpacked, manifest matches the feed")
|
||||
else:
|
||||
log(f" downloading {pkg.url} ({pkg.size / (1 << 20):.0f} MiB)")
|
||||
try:
|
||||
transfer.download(feed.url(pkg.url), archive, size=pkg.size, sha256=pkg.sha256)
|
||||
except transfer.TransferError as exc:
|
||||
raise SystemExit(f"fetch-engines: {exc}")
|
||||
log(" size and SHA-256 match the signed feed; unpacking")
|
||||
try:
|
||||
updater.extract(archive, folder, pkg.format, pkg.installed_bytes)
|
||||
except updater.UpdateError as exc:
|
||||
raise SystemExit(f"fetch-engines: {exc}")
|
||||
finally:
|
||||
archive.unlink(missing_ok=True)
|
||||
manifest = folder / ec.MANIFEST
|
||||
if transfer.sha256_file(manifest) != pkg.manifest_sha256:
|
||||
raise SystemExit(f"fetch-engines: {folder.name} has a manifest the signed feed does not name")
|
||||
try:
|
||||
component = ec.read_manifest(folder)
|
||||
except ec.ComponentProblem as exc:
|
||||
raise SystemExit(f"fetch-engines: {folder.name}: the package manifest is invalid: {exc}")
|
||||
for name, a, b in (("version", component.version, pkg.version), ("platform", component.platform, pkg.platform),
|
||||
("backend", component.backend, pkg.backend), ("variant", component.variant, pkg.variant),
|
||||
("build_id", component.build_id, pkg.build_id), ("archs", set(component.archs), set(pkg.archs))):
|
||||
if a != b:
|
||||
raise SystemExit(f"fetch-engines: {folder.name}: the manifest says a different {name} than the signed feed")
|
||||
outer = ec._verifier
|
||||
signing.install_component_verifier(trusted)
|
||||
try:
|
||||
ec.verify_signature(component, {ec.ENV_REQUIRE_SIGNED: "1"})
|
||||
ec.verify(component, full=True)
|
||||
except ec.ComponentProblem as exc:
|
||||
raise SystemExit(f"fetch-engines: {folder.name} failed its check: {exc}")
|
||||
finally:
|
||||
ec.register_signature_verifier(outer)
|
||||
log(f" {folder.name}: signature and every file verified (build {pkg.build_id})")
|
||||
return folder
|
||||
|
||||
|
||||
def main() -> int:
|
||||
ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
|
||||
ap.add_argument("--release-tag", help="the GitHub release tag, for example v0.2.1")
|
||||
ap.add_argument("--repo", default="Niko1221/Strata", help="owner/name of the GitHub repository (default %(default)s)")
|
||||
ap.add_argument("--source", help="a release folder or base URL holding strata-feed.json(.sig) and the archives (instead of --release-tag)")
|
||||
ap.add_argument("--flavors", default=",".join(FLAVORS), help="comma separated; default: all (%s)" % ", ".join(FLAVORS))
|
||||
ap.add_argument("--out", type=Path, help="where the unpacked package folders go")
|
||||
ap.add_argument("--skip-missing", action="store_true", help="a flavor the feed has no package for is skipped (default: an error)")
|
||||
ap.add_argument("--list", action="store_true", help="only print which package each flavor would use")
|
||||
a = ap.parse_args()
|
||||
if bool(a.release_tag) == bool(a.source):
|
||||
ap.error("give exactly one of --release-tag and --source")
|
||||
if not a.list and not a.out:
|
||||
ap.error("--out is required")
|
||||
flavors = [f.strip() for f in a.flavors.split(",") if f.strip()]
|
||||
unknown = [f for f in flavors if f not in FLAVORS]
|
||||
if unknown:
|
||||
ap.error(f"unknown flavor {', '.join(unknown)} (known: {', '.join(FLAVORS)})")
|
||||
source = a.source or f"https://github.com/{a.repo}/releases/download/{a.release_tag}"
|
||||
trusted = signing.load_trusted_keys()
|
||||
log(f"feed: {source}")
|
||||
try:
|
||||
feed = feedmod.fetch(source, trusted)
|
||||
except feedmod.FeedError as exc:
|
||||
raise SystemExit(f"fetch-engines: {exc}")
|
||||
log(f"feed signature OK (key {feed.key_id}), channel {feed.channel}, sequence {feed.sequence}")
|
||||
status = 0
|
||||
for flavor in flavors:
|
||||
pkg = pick(feed, flavor)
|
||||
if pkg is None:
|
||||
log(f"{flavor}: the feed has no {PLATFORM} package for it")
|
||||
if not a.skip_missing:
|
||||
status = 3
|
||||
else:
|
||||
print(f"{flavor}\t{FLAVORS[flavor][2]}\tSKIP")
|
||||
continue
|
||||
log(f"{flavor}: {pkg.label} ({pkg.url})")
|
||||
if a.list:
|
||||
print(f"{flavor}\t{FLAVORS[flavor][2]}\t{pkg.url}\t{pkg.size}\t{pkg.sha256}")
|
||||
continue
|
||||
a.out.mkdir(parents=True, exist_ok=True)
|
||||
folder = fetch_one(feed, pkg, a.out, trusted)
|
||||
print(f"{flavor}\t{FLAVORS[flavor][2]}\t{folder}", flush=True)
|
||||
if a.out and (a.out / ".partial").is_dir():
|
||||
shutil.rmtree(a.out / ".partial", ignore_errors=True)
|
||||
return status
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,92 @@
|
||||
#!/bin/sh
|
||||
# Build the Strata images of one release from its engine packages and, only with --push, push them to the registry.
|
||||
# The GitHub Actions workflow (.github/workflows/docker-images.yml) runs this script once per flavor; you can run it by hand too.
|
||||
#
|
||||
# docker/publish.sh --release-tag v0.2.1 # builds every flavor the release has a package for; pushes nothing
|
||||
# docker/publish.sh --release-tag v0.2.1 --flavors cuda13,cuda12 --push
|
||||
# docker/publish.sh --source ~/release-folder --version 0.2.1-test --flavors cuda13 --no-latest
|
||||
#
|
||||
# For every flavor:
|
||||
# 1. docker/fetch-engines.py downloads the engine package from the release (a GitHub release URL, or --source) and checks it
|
||||
# against the signed update feed: the feed's Ed25519 signature, the archive's size and SHA-256, the manifest hash, the package
|
||||
# signature and every file's hash. A package that fails stops the run before anything is built.
|
||||
# 2. docker/build.sh builds <image>:<version>-<flavor> (the Dockerfile checks the package again, and that its libraries resolve).
|
||||
# 3. a short check that the image starts and the Terminal inside it reports the version.
|
||||
# 4. with --push: docker push of <image>:<version>-<flavor> and, unless --no-latest, <image>:latest-<flavor>. You must be logged in
|
||||
# to the registry already (`docker login ghcr.io`; the workflow logs in with GITHUB_TOKEN).
|
||||
#
|
||||
# --release-tag TAG the release, for example v0.2.1; the image version is the tag without the leading v
|
||||
# --source DIR|URL use this folder or URL (with strata-feed.json, its .sig and the archives) instead of the GitHub release
|
||||
# --version V image version (default: the tag without v)
|
||||
# --flavors LIST comma separated (default: all that the release has: cuda13 cuda12 rocm-gfx120x rocm-gfx110x rocm-gfx1151 sycl)
|
||||
# --image NAME image repository (default ghcr.io/niko1221/strata)
|
||||
# --work DIR where packages are unpacked (default a temporary folder, removed at the end)
|
||||
# --push push the images (default: build only)
|
||||
# --no-latest do not tag / push latest-<flavor>
|
||||
# --keep-images do not remove the local images after the run (default: removed only when this script pushed them)
|
||||
# Environment: STRATA_DOCKER_BUILD_OPTS adds options to `docker build` (see build.sh).
|
||||
set -eu
|
||||
|
||||
here=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)
|
||||
repo=$(CDPATH= cd -- "$here/.." && pwd -P)
|
||||
tag=""; source=""; version=""; flavors=""; image="ghcr.io/niko1221/strata"; work=""; push=""; latest=1; keepimg=""
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
--release-tag) tag=$2; shift 2 ;;
|
||||
--source) source=$2; shift 2 ;;
|
||||
--version) version=$2; shift 2 ;;
|
||||
--flavors) flavors=$2; shift 2 ;;
|
||||
--image) image=$2; shift 2 ;;
|
||||
--work) work=$2; shift 2 ;;
|
||||
--push) push=1; shift ;;
|
||||
--no-latest) latest=""; shift ;;
|
||||
--keep-images) keepimg=1; shift ;;
|
||||
-h|--help) sed -n '2,29p' "$0"; exit 0 ;;
|
||||
*) echo "publish.sh: unknown option $1" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
[ -n "$tag" ] || [ -n "$source" ] || { echo "publish.sh: give --release-tag or --source" >&2; exit 2; }
|
||||
if [ -z "$version" ]; then
|
||||
[ -n "$tag" ] || { echo "publish.sh: --version is required with --source" >&2; exit 2; }
|
||||
version=${tag#v}
|
||||
fi
|
||||
case "$image" in *[A-Z]*) echo "publish.sh: the image name must be lower case ($image)" >&2; exit 2 ;; esac
|
||||
command -v docker >/dev/null || { echo "publish.sh: docker not found" >&2; exit 2; }
|
||||
PY=${PYTHON:-python3}
|
||||
|
||||
own_work=""
|
||||
if [ -z "$work" ]; then work=$(mktemp -d "${TMPDIR:-/tmp}/strata-docker-pkgs.XXXXXX"); own_work=1; fi
|
||||
mkdir -p "$work"
|
||||
cleanup() { [ -n "$own_work" ] && rm -rf "$work"; }
|
||||
trap cleanup EXIT
|
||||
|
||||
built=""
|
||||
# one flavor at a time: the package is deleted after its image is built, so the disk never holds more than one
|
||||
flavor_list=${flavors:-cuda13,cuda12,rocm-gfx120x,rocm-gfx110x,rocm-gfx1151,sycl}
|
||||
for flavor in $(echo "$flavor_list" | tr ',' ' '); do
|
||||
echo "=== $flavor"
|
||||
src_arg="--release-tag $tag"; [ -n "$source" ] && src_arg="--source $source"
|
||||
# a failed fetch (bad signature, bad hash) must stop the run: it is not a skipped flavor
|
||||
$PY "$here/fetch-engines.py" --out "$work" --skip-missing --flavors "$flavor" $src_arg > "$work/.fetch.out"
|
||||
line=$(tail -1 "$work/.fetch.out")
|
||||
bflavor=$(echo "$line" | cut -f2); folder=$(echo "$line" | cut -f3)
|
||||
if [ "$folder" = "SKIP" ] || [ -z "$folder" ]; then echo "$flavor: no package in this release, skipped"; continue; fi
|
||||
img="$image:$version-$flavor"
|
||||
"$here/build.sh" --flavor "$bflavor" --engine "$folder" --tag "$img" --version "$version" --repo "$repo"
|
||||
[ -n "$latest" ] && docker tag "$img" "$image:latest-$flavor"
|
||||
# the image starts and its Terminal runs (no GPU needed for this)
|
||||
docker run --rm --entrypoint /opt/strata/terminal/bin/strata "$img" --version
|
||||
rm -rf "$folder"
|
||||
if [ -n "$push" ]; then
|
||||
docker push "$img"
|
||||
[ -n "$latest" ] && docker push "$image:latest-$flavor"
|
||||
echo "pushed $img$( [ -n "$latest" ] && echo " and $image:latest-$flavor")"
|
||||
docker image inspect "$img" --format '{{index .RepoDigests 0}}' 2>/dev/null || true
|
||||
[ -z "$keepimg" ] && { docker rmi "$img" >/dev/null 2>&1 || true; [ -n "$latest" ] && { docker rmi "$image:latest-$flavor" >/dev/null 2>&1 || true; }; }
|
||||
else
|
||||
echo "built $img (not pushed; add --push)"
|
||||
fi
|
||||
built="$built $flavor"
|
||||
done
|
||||
[ -n "$built" ] || { echo "publish.sh: no flavor was built (the release has none of: $flavor_list)" >&2; exit 3; }
|
||||
echo "done:$built"
|
||||
+54
-19
@@ -18,21 +18,23 @@ Docker on a **Mac** has no access to the Mac's graphics chip (no Metal): use the
|
||||
|
||||
| Your graphics card | Image tag | Needs on the computer |
|
||||
| --- | --- | --- |
|
||||
| NVIDIA **RTX 20, 30, 40, 50** series (and the matching RTX A / Quadro cards) | `0.2.0-cuda13` | NVIDIA driver **580 or newer**, [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) |
|
||||
| NVIDIA **GTX 10 (Pascal), Tesla P100, V100 (Volta)**, or any NVIDIA card whose driver is **575 to 579** | `0.2.0-cuda12` | NVIDIA driver **575 or newer**, the same toolkit |
|
||||
| AMD **RX 9000** series and Radeon AI PRO R9700 (RDNA 4, gfx1200 / gfx1201) | `0.2.0-rocm-gfx120x` | the `amdgpu` kernel driver (Linux 6.8+) |
|
||||
| AMD **RX 7000** series (RDNA 3, gfx1100 / gfx1101 / gfx1102) | `0.2.0-rocm-gfx110x` | the `amdgpu` kernel driver |
|
||||
| Intel **Arc** A-series and B-series (including Arc Pro B70) | `0.2.0-sycl` | the `i915` or `xe` kernel driver; **prepared model files** (see [Intel](#intel-arc)) |
|
||||
| NVIDIA **RTX 20, 30, 40, 50** series (and the matching RTX A / Quadro cards) | `0.2.1-cuda13` | NVIDIA driver **580 or newer**, [NVIDIA Container Toolkit](https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html) |
|
||||
| NVIDIA **GTX 10 (Pascal), Tesla P100, V100 (Volta)**, or any NVIDIA card whose driver is **575 to 579** | `0.2.1-cuda12` | NVIDIA driver **575 or newer**, the same toolkit |
|
||||
| AMD **RX 9000** series and Radeon AI PRO R9700 (RDNA 4, gfx1200 / gfx1201) | `0.2.1-rocm-gfx120x` | the `amdgpu` kernel driver (Linux 6.8+) |
|
||||
| AMD **RX 7000** series (RDNA 3, gfx1100 / gfx1101 / gfx1102) | `0.2.1-rocm-gfx110x` | the `amdgpu` kernel driver |
|
||||
| AMD **Ryzen AI Max** ("Strix Halo", Radeon 8060S, gfx1151) | `0.2.1-rocm-gfx1151` | the `amdgpu` kernel driver |
|
||||
| Intel **Arc** A-series and B-series (including Arc Pro B70) | `0.2.1-sycl` (only for a release that carries the Intel engine package; otherwise [build it](#build-it-yourself)) | the `i915` or `xe` kernel driver; **prepared model files** (see [Intel](#intel-arc)) |
|
||||
|
||||
Size of the images (0.1.45 packages as measured; 0.2.0 ones may differ a little): `cuda13` 640 MB download / 2.0 GB on disk, `cuda12`
|
||||
Size of the images (measured on the 0.1.45 packages; the current ones may differ a little): `cuda13` 640 MB download / 2.0 GB on disk, `cuda12`
|
||||
845 MB / 2.6 GB, `rocm-gfx120x` 505 MB / 2.2 GB, `rocm-gfx110x` 330 MB / 1.6 GB, `sycl` 450 MB / 1.9 GB. The model comes on top, on the first start.
|
||||
|
||||
Not sure which NVIDIA image? Take `cuda13` when `nvidia-smi` shows driver 580 or newer and the card is an RTX; otherwise `cuda12`.
|
||||
A wrong pick does no harm: the container starts, says in plain words that the engine does not fit this card, and stops.
|
||||
|
||||
**Ready-made images are not available yet.** No image has been published, so [build one yourself](#build-it-yourself) (one command
|
||||
per card, from the engine package). The examples below name the images `ghcr.io/niko1221/strata:0.2.0-cuda13` and so on, after the
|
||||
tags in the table; if you built the image yourself, use the tag you gave it (for example `strata:0.2.0-cuda13`) in their place.
|
||||
**Ready-made images are published from version 0.2.1 on**, to the GitHub Container Registry: `ghcr.io/niko1221/strata:<version>-<flavor>`
|
||||
(for example `0.2.1-cuda13`), and `ghcr.io/niko1221/strata:latest-<flavor>` for the newest release of that flavor. Pin the version
|
||||
tag if you want updates only when you decide. The examples below use these images. If you built an image yourself
|
||||
([Build it yourself](#build-it-yourself)), use the tag you gave it (for example `strata:0.2.1-cuda13`) in their place.
|
||||
|
||||
## One command per card
|
||||
|
||||
@@ -46,7 +48,7 @@ Each command runs Strata in the background, keeps your files in the volume `stra
|
||||
docker run -d --name strata --gpus all -p 127.0.0.1:8080:8080 \
|
||||
--ulimit memlock=-1:-1 --shm-size 2g --stop-timeout 120 \
|
||||
-v strata-data:/data -e MODEL=IQ3_XXS -e API_KEY=$(openssl rand -hex 24) \
|
||||
ghcr.io/niko1221/strata:0.2.0-cuda13
|
||||
ghcr.io/niko1221/strata:0.2.1-cuda13
|
||||
```
|
||||
|
||||
**AMD**
|
||||
@@ -56,7 +58,7 @@ docker run -d --name strata --device /dev/kfd --device /dev/dri \
|
||||
--group-add video --group-add $(getent group render | cut -d: -f3) -p 127.0.0.1:8080:8080 \
|
||||
--ulimit memlock=-1:-1 --shm-size 2g --stop-timeout 120 \
|
||||
-v strata-data:/data -e MODEL=IQ3_XXS -e API_KEY=$(openssl rand -hex 24) \
|
||||
ghcr.io/niko1221/strata:0.2.0-rocm-gfx120x
|
||||
ghcr.io/niko1221/strata:0.2.1-rocm-gfx120x
|
||||
```
|
||||
|
||||
**Intel Arc**
|
||||
@@ -65,7 +67,7 @@ docker run -d --name strata --device /dev/kfd --device /dev/dri \
|
||||
docker run -d --name strata --device /dev/dri --group-add $(getent group render | cut -d: -f3) \
|
||||
-p 127.0.0.1:8080:8080 --ulimit memlock=-1:-1 --shm-size 2g --stop-timeout 120 \
|
||||
-v strata-data:/data -e MODEL=IQ3_S -e MODEL_PATH=/models -v /srv/gguf/IQ3_S:/models:ro \
|
||||
-e API_KEY=$(openssl rand -hex 24) ghcr.io/niko1221/strata:0.2.0-sycl
|
||||
-e API_KEY=$(openssl rand -hex 24) ghcr.io/niko1221/strata:0.2.1-sycl
|
||||
```
|
||||
|
||||
What the options are for: `--ulimit memlock=-1:-1` lets the engine pin the RAM it uses for the model, `--shm-size 2g` gives
|
||||
@@ -186,7 +188,7 @@ The health check asks `GET /v1/models` with the key. During the first download t
|
||||
## Updating
|
||||
|
||||
```sh
|
||||
docker pull ghcr.io/niko1221/strata:0.2.0-cuda13 # the new tag (not available yet; with a self-built image, build it again instead)
|
||||
docker pull ghcr.io/niko1221/strata:0.2.1-cuda13 # the new tag (with a self-built image, build it again instead)
|
||||
docker stop strata && docker rm strata
|
||||
# run the same docker run command again with the new tag (compose: docker compose pull && docker compose up -d)
|
||||
```
|
||||
@@ -259,14 +261,13 @@ the old model folder. The container name, the volume and the port can stay as th
|
||||
|
||||
## Build it yourself
|
||||
|
||||
Until ready-made images are available this is the way to get one, and it stays the way for a computer without
|
||||
registry access or after changing Strata. You need an engine package folder (made by `packaging/package_engine.py`, or fetched
|
||||
by `strata update` into a components folder) and Docker on Linux:
|
||||
This is the way to get an image for a computer without registry access or after changing Strata. You need an engine package
|
||||
folder (made by `packaging/package_engine.py`, or fetched by `strata update` into a components folder) and Docker on Linux:
|
||||
|
||||
```sh
|
||||
docker/build.sh --flavor cuda --engine ~/components/engine/0.2.0-linux-x86_64-cuda-cuda13 --tag strata:0.2.0-cuda13
|
||||
docker/build.sh --flavor hip --engine ~/components/engine/0.2.0-linux-x86_64-hip-gfx120X --tag strata:0.2.0-rocm-gfx120x
|
||||
docker/build.sh --flavor sycl --engine ~/components/engine/0.2.0-linux-x86_64-sycl --tag strata:0.2.0-sycl
|
||||
docker/build.sh --flavor cuda --engine ~/components/engine/0.1.45.3-linux-x86_64-cuda-cuda13 --tag strata:0.2.1-cuda13
|
||||
docker/build.sh --flavor hip --engine ~/components/engine/0.1.45.3-linux-x86_64-hip-rx9070 --tag strata:0.2.1-rocm-gfx120x
|
||||
docker/build.sh --flavor sycl --engine ~/components/engine/<a-sycl-package-folder> --tag strata:0.2.1-sycl
|
||||
```
|
||||
|
||||
`build.sh` assembles the build context (the Terminal's files and the package) and runs `docker build`. The build makes the
|
||||
@@ -281,6 +282,40 @@ and puts it in the same kind of image (`--build-arg CUDA_ARCHITECTURES=89` for o
|
||||
builds from source see [AMD_HIP.md](AMD_HIP.md) and [INTEL.md](INTEL.md); then package the result with
|
||||
`packaging/package_engine.py` and use `docker/build.sh`.
|
||||
|
||||
## Publishing the images (for maintainers)
|
||||
|
||||
The images are built from the **engine packages of a release**, never from a build on the runner, so an image holds exactly the
|
||||
files the signed update feed names. Nothing publishes by itself: a maintainer starts the workflow, after the owner's OK.
|
||||
|
||||
1. Make the release first (its `strata-feed.json`, `strata-feed.json.sig` and the engine archives must be on the GitHub release).
|
||||
2. GitHub, **Actions, Docker images, Run workflow** ([.github/workflows/docker-images.yml](../.github/workflows/docker-images.yml); the file has to be on
|
||||
the default branch to show up). Inputs: the release tag (`v0.2.1`), the flavors (empty: every flavor the release has a package
|
||||
for), **push** and **latest**. Run it once with **push off**: it builds every image and publishes nothing (a dry run).
|
||||
3. Run it again with **push on**. It logs in to `ghcr.io` with the job's `GITHUB_TOKEN` (`packages: write`) and pushes
|
||||
`ghcr.io/niko1221/strata:0.2.1-<flavor>` and `latest-<flavor>`. Turn **latest** off for a pre-release.
|
||||
4. The first push creates each package as private. In the repository's Packages, open every package, **Package settings, Change
|
||||
visibility, Public**, and check it is linked to the repository (the image carries the `org.opencontainers.image.source` label).
|
||||
5. Check one pull from a computer that is not logged in: `docker pull ghcr.io/niko1221/strata:0.2.1-cuda13`.
|
||||
|
||||
For each flavor the job runs [docker/fetch-engines.py](../docker/fetch-engines.py), which reads the release's signed feed (the
|
||||
Ed25519 key in `strata_control/update_keys.json`), downloads the package, and checks the archive's size and SHA-256, the manifest
|
||||
hash, the package signature and every file's hash, exactly as `strata update` does; a package that fails stops the job before
|
||||
anything is built. [docker/build.sh](../docker/build.sh) then builds the image (and checks the package again inside the build), and
|
||||
the job starts the image once to see that the Terminal inside it runs.
|
||||
|
||||
| Flavor (tag suffix) | Engine package in the release feed |
|
||||
| --- | --- |
|
||||
| `cuda13` | `linux-x86_64`, cuda, variant `cuda13` |
|
||||
| `cuda12` | `linux-x86_64`, cuda, variant `cuda12` |
|
||||
| `rocm-gfx120x` | `linux-x86_64`, hip, variant `rx9070` (gfx1200 / gfx1201) |
|
||||
| `rocm-gfx110x` | `linux-x86_64`, hip, variant `rx7900` (gfx1100 / gfx1101 / gfx1102) |
|
||||
| `rocm-gfx1151` | `linux-x86_64`, hip, variant `halo` (Strix Halo, gfx1151) |
|
||||
| `sycl` | `linux-x86_64`, sycl; **only when the feed lists one** (the 0.2.0-beta feed has none, so no Intel image is built from it) |
|
||||
|
||||
A flavor the feed has no package for is left out, with a line in the log. The same steps run from a Linux computer with Docker:
|
||||
`docker/publish.sh --release-tag v0.2.1` builds everything and pushes nothing; add `--push` (after `docker login ghcr.io`) to publish.
|
||||
The images run on the runner without a graphics card, so the card checks (`docker/smoke-test.sh`) stay a manual step on a computer with the card.
|
||||
|
||||
## Tested
|
||||
|
||||
2026-10-17, images built from the 0.1.45 engine packages (images from the 0.2.0 packages have not been run on a card), on real cards: NVIDIA RTX 3060 (`cuda13`
|
||||
|
||||
+3
-2
@@ -11,8 +11,9 @@ Intel GPU and every result on Arc hardware came from the community. Since 0.1.40
|
||||
are still community reports. The NVIDIA and AMD engines are unchanged: the Intel build is a separate CMake target, off by default.
|
||||
|
||||
**Where the engine comes from.** There is **no Intel engine in the release zips** (the ones `START-HERE.bat` and `setup.sh`
|
||||
use): you build it from source on Linux, as described below. A ready-made Intel engine does exist as a Docker image,
|
||||
`ghcr.io/niko1221/strata:0.2.0-sycl`, built for the 0.2.0 release (the image needs prepared model files; see
|
||||
use): you build it from source on Linux, as described below. The Docker route is a ready-made image,
|
||||
`ghcr.io/niko1221/strata:0.2.1-sycl`, which is published only for a release that carries a Linux Intel engine package; with none, [build
|
||||
the image yourself](DOCKER.md#build-it-yourself) from the engine you built (the image needs prepared model files; see
|
||||
[Docker: Intel Arc](DOCKER.md#intel-arc)). The Mac and Windows builds have no Intel engine.
|
||||
|
||||
## What has been run, and by whom
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
"""docker/fetch-engines.py against a LOCAL signed release folder: it fetches the engine package for an image flavor and refuses what the
|
||||
signed feed does not vouch for (a feed signed by an unknown key, an archive that does not match the feed's SHA-256).
|
||||
Linux x86-64 only: the script picks `linux-x86_64` packages, and the fixture builds a package for the host."""
|
||||
|
||||
import json
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from strata_control import components
|
||||
from tests.terminal import update_fixture as fx
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[2]
|
||||
SCRIPT = ROOT / "docker" / "fetch-engines.py"
|
||||
|
||||
|
||||
@unittest.skipUnless(components.host_platform() == "linux-x86_64", "the Docker images are for linux-x86_64 packages")
|
||||
class FetchEngines(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.temp = tempfile.TemporaryDirectory(prefix="strata-dockfetch-")
|
||||
self.addCleanup(self.temp.cleanup)
|
||||
self.root = Path(self.temp.name)
|
||||
self.key = fx.make_key()
|
||||
self.release = self.root / "release"
|
||||
self.release.mkdir()
|
||||
self.trust = self.root / "trust.json"
|
||||
self.trust.write_text(json.dumps({"keys": [{k: self.key[k] for k in ("alg", "key_id", "public")}]}), encoding="utf-8")
|
||||
folder = fx.build_package(self.root / "pub", "0.1.45", key=self.key, backend="cuda", variant="cuda13")
|
||||
from feed_tool import build_feed, pack_engine
|
||||
pack_engine(folder, self.release, url_prefix="")
|
||||
build_feed(self.release, key=self.key, sequence=1, engine_dir=self.release)
|
||||
self.out = self.root / "out"
|
||||
|
||||
def run_script(self, *args, trust=True):
|
||||
env = dict(os.environ)
|
||||
env.pop("STRATA_UPDATE_TRUSTED_KEYS", None)
|
||||
if trust:
|
||||
env["STRATA_UPDATE_TRUSTED_KEYS"] = str(self.trust)
|
||||
return subprocess.run([sys.executable, str(SCRIPT), "--source", str(self.release), "--out", str(self.out), *args],
|
||||
capture_output=True, text=True, env=env, cwd=str(ROOT))
|
||||
|
||||
def test_fetches_and_verifies_a_package_for_the_flavor(self):
|
||||
r = self.run_script("--flavors", "cuda13")
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
flavor, build_flavor, folder = r.stdout.strip().split("\t")
|
||||
self.assertEqual((flavor, build_flavor), ("cuda13", "cuda"))
|
||||
self.assertTrue((Path(folder) / "engine-component.json").is_file())
|
||||
self.assertIn("signature and every file verified", r.stderr)
|
||||
|
||||
def test_a_flavor_without_a_package_is_an_error_unless_skipped(self):
|
||||
r = self.run_script("--flavors", "cuda13,sycl")
|
||||
self.assertEqual(r.returncode, 3, r.stderr)
|
||||
self.assertIn("no linux-x86_64 package", r.stderr)
|
||||
r = self.run_script("--flavors", "sycl", "--skip-missing")
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
self.assertEqual(r.stdout.strip().split("\t")[-1], "SKIP")
|
||||
|
||||
def test_a_feed_signed_by_a_key_we_do_not_trust_is_refused(self):
|
||||
r = self.run_script("--flavors", "cuda13", trust=False)
|
||||
self.assertNotEqual(r.returncode, 0)
|
||||
self.assertIn("not trusted", r.stderr + r.stdout)
|
||||
self.assertFalse(self.out.exists() and any(self.out.iterdir()))
|
||||
|
||||
def test_an_archive_that_is_not_the_one_in_the_feed_is_refused(self):
|
||||
archive = next(self.release.glob("strata-engine-*.tar.gz"))
|
||||
data = bytearray(archive.read_bytes())
|
||||
data[len(data) // 2] ^= 0xFF
|
||||
archive.write_bytes(bytes(data))
|
||||
r = self.run_script("--flavors", "cuda13")
|
||||
self.assertNotEqual(r.returncode, 0)
|
||||
self.assertIn("SHA-256", r.stderr + r.stdout)
|
||||
self.assertEqual(r.stdout.strip(), "")
|
||||
|
||||
def test_a_tampered_feed_is_refused(self):
|
||||
feed = self.release / "strata-feed.json"
|
||||
feed.write_bytes(feed.read_bytes().replace(b'"sequence": 1', b'"sequence": 2'))
|
||||
r = self.run_script("--flavors", "cuda13")
|
||||
self.assertNotEqual(r.returncode, 0)
|
||||
self.assertIn("not trusted", r.stderr + r.stdout)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -2,6 +2,7 @@
|
||||
docs/DOCKER.md says they carry, and every setting the document lists is one the entry point reads."""
|
||||
from __future__ import annotations
|
||||
|
||||
import ast
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
@@ -18,12 +19,17 @@ SH = shutil.which("sh")
|
||||
class Scripts(unittest.TestCase):
|
||||
@unittest.skipIf(SH is None, "needs sh")
|
||||
def test_shell_scripts_parse(self):
|
||||
for name in ("entrypoint.sh", "strata-wrapper.sh", "healthcheck.sh", "build.sh", "smoke-test.sh"):
|
||||
for name in ("entrypoint.sh", "strata-wrapper.sh", "healthcheck.sh", "build.sh", "publish.sh"):
|
||||
r = subprocess.run([SH, "-n", str(DOCKER / name)], capture_output=True, text=True)
|
||||
self.assertEqual(r.returncode, 0, f"{name}: {r.stderr}")
|
||||
|
||||
@unittest.skipIf(shutil.which("bash") is None, "needs bash")
|
||||
def test_smoke_test_parses_with_bash(self): # it is a bash script (process substitution), not POSIX sh
|
||||
r = subprocess.run(["bash", "-n", str(DOCKER / "smoke-test.sh")], capture_output=True, text=True)
|
||||
self.assertEqual(r.returncode, 0, r.stderr)
|
||||
|
||||
def test_scripts_use_unix_line_ends(self):
|
||||
for name in ("entrypoint.sh", "strata-wrapper.sh", "healthcheck.sh", "build.sh"):
|
||||
for name in ("entrypoint.sh", "strata-wrapper.sh", "healthcheck.sh", "build.sh", "publish.sh"):
|
||||
self.assertNotIn(b"\r", (DOCKER / name).read_bytes(), name) # build.sh strips CR for a CRLF checkout, the files themselves stay LF
|
||||
|
||||
|
||||
@@ -105,16 +111,68 @@ class Document(unittest.TestCase):
|
||||
|
||||
def test_tags_in_the_document_match_the_compose_defaults(self):
|
||||
doc = (ROOT / "docs" / "DOCKER.md").read_text(encoding="utf-8")
|
||||
for tag in ("0.2.0-cuda13", "0.2.0-cuda12", "0.2.0-rocm-gfx120x", "0.2.0-rocm-gfx110x", "0.2.0-sycl"):
|
||||
for tag in ("0.2.1-cuda13", "0.2.1-cuda12", "0.2.1-rocm-gfx120x", "0.2.1-rocm-gfx110x", "0.2.1-rocm-gfx1151", "0.2.1-sycl"):
|
||||
self.assertIn(tag, doc)
|
||||
for name, tag in (("docker-compose.nvidia.yml", "0.2.0-cuda13"), ("docker-compose.amd.yml", "0.2.0-rocm-gfx120x"),
|
||||
("docker-compose.intel.yml", "0.2.0-sycl")):
|
||||
for name, tag in (("docker-compose.nvidia.yml", "ghcr.io/niko1221/strata:0.2.1-cuda13"), ("docker-compose.amd.yml", "ghcr.io/niko1221/strata:0.2.1-rocm-gfx120x"),
|
||||
("docker-compose.intel.yml", "ghcr.io/niko1221/strata:0.2.1-sycl")):
|
||||
self.assertIn(tag, (DOCKER / "compose" / name).read_text(encoding="utf-8"))
|
||||
|
||||
def test_the_user_doc_says_images_are_not_published(self):
|
||||
def test_the_user_doc_says_images_are_published_from_0_2_1(self):
|
||||
doc = (ROOT / "docs" / "DOCKER.md").read_text(encoding="utf-8")
|
||||
self.assertNotIn("TODO(owner)", doc)
|
||||
self.assertIn("Ready-made images are not available yet", doc)
|
||||
self.assertNotIn("not available yet", doc)
|
||||
self.assertIn("published from version 0.2.1 on", doc)
|
||||
self.assertIn("Publishing the images (for maintainers)", doc)
|
||||
|
||||
|
||||
class Publishing(unittest.TestCase):
|
||||
"""The scripts and the workflow that publish the images (docker/publish.sh, docker/fetch-engines.py, .github/workflows/docker-images.yml)."""
|
||||
WORKFLOW = ROOT / ".github" / "workflows" / "docker-images.yml"
|
||||
|
||||
@unittest.skipIf(SH is None, "needs sh")
|
||||
def test_publish_script_parses_and_defaults_to_not_pushing(self):
|
||||
path = DOCKER / "publish.sh"
|
||||
self.assertEqual(subprocess.run([SH, "-n", str(path)], capture_output=True, text=True).returncode, 0)
|
||||
text = path.read_text(encoding="utf-8")
|
||||
self.assertNotIn("\r", text)
|
||||
self.assertIn('push=""', text) # no --push, no docker push
|
||||
pushes = re.findall(r'^[^#\n]*docker push "', text, re.M)
|
||||
self.assertEqual(len(pushes), 2, pushes) # the version tag and latest-<flavor>, both inside `if [ -n "$push" ]`
|
||||
|
||||
def test_every_flavor_of_the_document_is_one_the_fetch_script_knows(self):
|
||||
src = (DOCKER / "fetch-engines.py").read_text(encoding="utf-8")
|
||||
flavors = re.findall(r'^ "([a-z0-9-]+)": \("', src, re.M)
|
||||
doc = (ROOT / "docs" / "DOCKER.md").read_text(encoding="utf-8")
|
||||
self.assertTrue({"cuda13", "cuda12", "rocm-gfx120x", "rocm-gfx110x", "rocm-gfx1151", "sycl"} <= set(flavors), flavors)
|
||||
for flavor in flavors:
|
||||
self.assertIn(f"0.2.1-{flavor}", doc)
|
||||
|
||||
def test_build_script_copies_everything_the_terminal_package_needs(self):
|
||||
"""docker/build.sh lists the Terminal's files by hand; the list must cover package_terminal.py's payload (it once missed docs/TERMINAL_LAUNCH.md)."""
|
||||
build = (DOCKER / "build.sh").read_text(encoding="utf-8")
|
||||
listed = re.search(r'^paths="([^"]+)"', build, re.M).group(1).split()
|
||||
pt = ast.parse((ROOT / "packaging" / "package_terminal.py").read_text(encoding="utf-8"))
|
||||
payload = None
|
||||
for node in pt.body:
|
||||
if isinstance(node, ast.Assign) and any(getattr(t, "id", "") == "PAYLOAD" for t in node.targets):
|
||||
payload = ast.literal_eval(node.value)
|
||||
self.assertTrue(payload)
|
||||
for item in payload:
|
||||
self.assertTrue(any(item == p or item.startswith(p.rstrip("/") + "/") for p in listed), f"build.sh does not copy {item}")
|
||||
|
||||
def test_workflow_is_manual_and_pushes_only_on_request(self):
|
||||
data = yaml.safe_load(self.WORKFLOW.read_text(encoding="utf-8"))
|
||||
triggers = data.get("on", data.get(True)) # YAML 1.1 reads a bare `on` as True
|
||||
self.assertEqual(set(triggers), {"workflow_dispatch"})
|
||||
inputs = triggers["workflow_dispatch"]["inputs"]
|
||||
self.assertIn("release_tag", inputs)
|
||||
self.assertFalse(inputs["push"]["default"])
|
||||
self.assertEqual(data["permissions"], {"contents": "read"})
|
||||
self.assertEqual(data["jobs"]["image"]["permissions"], {"contents": "read", "packages": "write"})
|
||||
text = self.WORKFLOW.read_text(encoding="utf-8")
|
||||
self.assertIn("ghcr.io/niko1221/strata", text)
|
||||
self.assertIn("docker/publish.sh", text)
|
||||
self.assertNotIn("${{ secrets.GITHUB_TOKEN }}\" |", text) # the token goes through an env variable, not into the command line
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user