|
| 1 | +_sources := justfile_directory() / "sources.py" |
| 2 | +registry := env("REGISTRY", "ghcr.io") |
| 3 | +registry_owner := env("REGISTRY_OWNER", "bootc-dev") |
| 4 | + |
| 5 | +# List available staged images |
| 6 | +list: |
| 7 | + @python3 "{{_sources}}" list |
| 8 | + |
| 9 | +# Mirror an upstream source image to our registry. |
| 10 | +# Usage: just staged-images/mirror fedora-bootc-43 |
| 11 | +mirror image: |
| 12 | + #!/bin/bash |
| 13 | + set -euo pipefail |
| 14 | + name=$(python3 "{{_sources}}" field {{image}} name) |
| 15 | + tag=$(python3 "{{_sources}}" field {{image}} tag) |
| 16 | + ref=$(python3 "{{_sources}}" mirror-ref {{image}}) |
| 17 | + dest="{{registry}}/{{registry_owner}}/${name}-source:${tag}" |
| 18 | + echo "Mirroring ${ref} -> ${dest}" |
| 19 | + skopeo copy --all --retry-times 3 "docker://${ref}" "docker://${dest}" |
| 20 | + echo "Mirrored ${dest}" |
| 21 | + |
| 22 | +# Build a staged image locally. |
| 23 | +# Usage: just staged-images/build fedora-bootc-43 |
| 24 | +# Set SOURCE_FROM_MIRROR=1 to pull from registry mirror instead of upstream. |
| 25 | +build image: |
| 26 | + #!/bin/bash |
| 27 | + set -euo pipefail |
| 28 | + name=$(python3 "{{_sources}}" field {{image}} name) |
| 29 | + tag=$(python3 "{{_sources}}" field {{image}} tag) |
| 30 | + src=$(python3 "{{_sources}}" field {{image}} source) |
| 31 | + staged_name="${name}-staged" |
| 32 | + if [ "${SOURCE_FROM_MIRROR:-}" = "1" ]; then |
| 33 | + src="{{registry}}/{{registry_owner}}/${name}-source:${tag}" |
| 34 | + fi |
| 35 | + echo "=== Pulling source image ===" |
| 36 | + podman pull "${src}" |
| 37 | + echo "=== Writing source config ===" |
| 38 | + podman inspect "${src}" > "{{justfile_directory()}}/source-config.json" |
| 39 | + echo "=== Building ${staged_name}:${tag} ===" |
| 40 | + # -v is needed for buildah < 1.44 (see containers/buildah#5952) |
| 41 | + buildah build --skip-unused-stages=false \ |
| 42 | + -v "{{justfile_directory()}}:/run/src" --security-opt=label=disable \ |
| 43 | + --build-arg SOURCE_IMAGE="${src}" \ |
| 44 | + --build-arg MAX_LAYERS=128 \ |
| 45 | + -f "{{justfile_directory()}}/Containerfile" \ |
| 46 | + -t "localhost/${staged_name}:${tag}" \ |
| 47 | + "{{justfile_directory()}}" |
| 48 | + echo "=== Verifying ===" |
| 49 | + echo "Labels:" |
| 50 | + podman inspect "localhost/${staged_name}:${tag}" | jq '.[0].Config.Labels' |
| 51 | + echo "Layer count:" |
| 52 | + podman inspect "localhost/${staged_name}:${tag}" | jq '.[0].RootFS.Layers | length' |
| 53 | + echo "Built localhost/${staged_name}:${tag}" |
| 54 | + |
| 55 | +# Build all staged images |
| 56 | +build-all: |
| 57 | + #!/bin/bash |
| 58 | + set -euo pipefail |
| 59 | + for image in $(python3 "{{_sources}}" list); do |
| 60 | + just {{justfile_directory()}}/build "$image" |
| 61 | + done |
| 62 | + |
| 63 | +# Push a built staged image by digest, print only the digest to stdout. |
| 64 | +# Usage: just staged-images/push fedora-bootc-43 amd64 |
| 65 | +push image arch="": |
| 66 | + #!/bin/bash |
| 67 | + set -euo pipefail |
| 68 | + name=$(python3 "{{_sources}}" field {{image}} name) |
| 69 | + tag=$(python3 "{{_sources}}" field {{image}} tag) |
| 70 | + staged_name="${name}-staged" |
| 71 | + arch="{{arch}}" |
| 72 | + if [ -z "$arch" ]; then |
| 73 | + arch=$(podman info --format '{{{{.Host.Arch}}') |
| 74 | + fi |
| 75 | + dest="{{registry}}/{{registry_owner}}/${staged_name}" |
| 76 | + # Use a per-arch tag to avoid collisions when pushing in parallel |
| 77 | + push_tag="${tag}-${arch}" |
| 78 | + podman tag "localhost/${staged_name}:${tag}" "${dest}:${push_tag}" >&2 |
| 79 | + digestfile=$(mktemp) |
| 80 | + podman push --retry 3 --digestfile "${digestfile}" "${dest}:${push_tag}" >&2 |
| 81 | + digest=$(cat "${digestfile}") |
| 82 | + rm -f "${digestfile}" |
| 83 | + echo "${digest}" |
| 84 | + |
| 85 | +# Generate GHA matrices (used by CI workflow) |
| 86 | +[private] |
| 87 | +ci-matrix: |
| 88 | + @python3 "{{_sources}}" ci-matrix |
| 89 | +[private] |
| 90 | +ci-mirror-matrix: |
| 91 | + @python3 "{{_sources}}" ci-mirror-matrix |
| 92 | +[private] |
| 93 | +ci-manifest-matrix: |
| 94 | + @python3 "{{_sources}}" ci-manifest-matrix |
0 commit comments