Files
cairnobs/scripts/build-image.sh
T
jcoffey-dev 52e527d727
ci / check (pull_request) Successful in 5m36s
ci / postgres (pull_request) Successful in 10m53s
Launch: public image on GHCR, GitHub's copy of each release
.github/workflows/release.yml runs on GitHub when a v* tag arrives through
the mirror: it waits for Gitea's Release, checks SHA256SUMS's signature and
every file against it, copies the Release to GitHub and builds the server
image from those same binaries as ghcr.io/coffey-labs/cairnobs:<version>
(and :latest for a final release). Gitea doesn't read .github/workflows,
and every job waits on BUILD_ON=github like the other mirrored repos.

The docs, the kustomize base and the join.image example now name that
image; the image's labels point at the source and the docs. The
"Private until launch" lines are gone.
2026-11-15 13:42:59 -07:00

36 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2026 Coffey Labs LLC
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# build-image.sh TAG DIST [IMAGE]: the obs-beacond image for linux/amd64 and
# linux/arm64 from a release's binaries in DIST (scripts/build-release.sh).
# Without IMAGE it writes an OCI archive, DIST/obs-beacond-image-TAG.tar,
# that `skopeo copy oci-archive:...` or `oc image mirror` can push anywhere.
# With IMAGE (e.g. registry.example.org/ops/obs-beacond) it pushes
# IMAGE:VERSION. Needs docker buildx.
#
# Each release's image is published as ghcr.io/coffey-labs/cairnobs by
# .github/workflows/release.yml; this script is how it's built.
set -euo pipefail
TAG="${1:?usage: build-image.sh TAG DIST [IMAGE]}"
DIST="${2:?usage: build-image.sh TAG DIST [IMAGE]}"
IMAGE="${3:-}"
VERSION="${TAG#v}"
for arch in amd64 arm64; do
for bin in obs-beacond obs-beacon-agent; do
[ -f "$DIST/$bin-linux-$arch" ] || { echo "$DIST/$bin-linux-$arch is missing: run scripts/build-release.sh $TAG $DIST first" >&2; exit 1; }
done
done
# A small build context: only what the image holds.
ctx="$(mktemp -d)"; trap 'rm -rf "$ctx"' EXIT
cp LICENSE THIRD_PARTY_NOTICES.md "$DIST"/obs-beacond-linux-{amd64,arm64} "$DIST"/obs-beacon-agent-linux-{amd64,arm64} "$ctx/"
args=(--file deploy/container/Containerfile --platform linux/amd64,linux/arm64
--build-arg "VERSION=$VERSION" --provenance=false)
if [ -n "$IMAGE" ]; then
docker buildx build "${args[@]}" --tag "$IMAGE:$VERSION" --push "$ctx"
else
out="$(cd "$DIST" && pwd)/obs-beacond-image-$TAG.tar"
docker buildx build "${args[@]}" --output "type=oci,dest=$out" "$ctx"
echo "$out"
fi