mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 16:27:33 -10:00
--from IMAGE (default $DEVVM_FROM) starts base from a Debian-, Ubuntu- or Alpine-based container image instead of Ubuntu's cloud image, for new VMs, build and rebuild. base is keyed by the image's digest, looked up once per build and recorded per reference; existing VMs keep their own (from_ignored). - internal/from: ParseRef (registry_ref, with a fuzz target), Valid/ Check (bad_from), Pinned, Name, Recorded (from_digest), Registry.Digest (manifest HEAD, anonymous Bearer token from an https realm only, timeouts, size caps, retries; ErrUnreachable/ErrNotFound), Lookup.Refresh (refresh_from_digest: registry, else Docker's ID, else the recorded digest with a warning), DockerID, DockerRunning. - build.Builder: From and Lookup; Inputs/Key/Chain with the recorded digest; spec.From for base; records keep from and digest on every image above a --from base; rebuild counters per from; building_image_from. - lima: convert (oci_base): devvm-oci-build from Ubuntu's image with only <tmp>/vm (rw) and oci/ (ro) mounted, confined to the internet, runs oci/build.sh; docker save plus exportIs for images only Docker has; checkConverted (regular files, gnu/musl, cmdline charset, raw ext4); base created with --set .images (disk, kernel, cmdline, initrd); the temp folder, build VM and the OCI build lock (lockOCI, pid, stale takeover, oci_waiting) go however the run ends. - cli/vm: global --from flag, state from=, builders with the VM's from in open, update, remove. - Messages: building_image_from, bad_from, from_ignored, from_unreachable, from_not_found, from_cached_unreachable, from_cached_not_found, no_digest, docker_only, exporting_docker, docker_export_failed, docker_image_changed, oci_waiting, converting_in_vm, converting, convert_failed, convert_bad_output; doc links to from.md. - Copied: oci/ (build.sh and README edited: comment, docs link), testdata/stubs/docker; limactl stub gains oci/build.sh outputs and interrupt-on. - Converted: from.bats (registry_ref, registry_digest token, 1/2, https realm, refresh per tag, Docker-only, offline, no Docker, pinned, moved tag, cached keys, build flow, docker save, Ctrl+C, steps, failures, bad outputs, record, export check, lock) as Go tests and from.txtar; oci.bats (libc_for, missing architecture, crane pins) as oci.txtar; cli.bats --from parse_args and project.bats --from input checks. - e2e: from section (--from tier, or --only from): node:24 Debian 12 node+python+claude, alpine:3 musl tools and Docker on OpenRC, base from ubuntu:26.04, no Docker needed. Left out: features, an image only Docker has. - Docs: from.md; images, commands, lima, contributing, index; CLI reference. Co-Authored-By: Claude Opus 5.5 <[email protected]>
22 lines
1.1 KiB
Bash
Executable File
22 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
# Stand-in for docker in unit tests. Logs every call to $STUB_LOG. `info` fails when
|
|
# $STUB_DIR/docker-down exists, `buildx version` when $STUB_DIR/no-buildx exists. `image inspect`
|
|
# finds an image only when $STUB_DIR/docker-image exists, and prints it (its ID). `save -o F` writes
|
|
# a tarball whose manifest.json names that image's config ($STUB_DIR/docker-saved instead, if it
|
|
# exists: the tag moved meanwhile).
|
|
set -euo pipefail
|
|
echo "docker $*" >> "$STUB_LOG"
|
|
case "${1:-} ${2:-}" in
|
|
"info "*) [[ ! -e "$STUB_DIR/docker-down" ]] ;;
|
|
"buildx version") [[ ! -e "$STUB_DIR/no-buildx" ]] ;;
|
|
"image inspect")
|
|
[[ ! -e "$STUB_DIR/docker-down" && -f "$STUB_DIR/docker-image" ]] || { echo "Error: No such image" >&2; exit 1; }
|
|
cat "$STUB_DIR/docker-image" ;;
|
|
"save -o")
|
|
id=$(cat "$STUB_DIR/docker-saved" 2>/dev/null || cat "$STUB_DIR/docker-image")
|
|
d=$(mktemp -d)
|
|
printf '[{"Config":"blobs/sha256/%s","RepoTags":["%s"],"Layers":[]}]' "${id#sha256:}" "$4" > "$d/manifest.json"
|
|
tar -cf "$3" -C "$d" manifest.json
|
|
rm -rf "$d" ;;
|
|
esac
|