feat(ci): publish ARM64 development node images [CI] [SKIP TESTS]
This commit is contained in:
1 parent
32507fcb4d
commit
8b3abd5b22
7 files changed
+173
-24
No files matched your search
+22
-10
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env bash
|
||||
# Build and push one opt-in Linux amd64 development image (main push with [CI]) to the moshiro-dev repository in Zot.
|
||||
# Build and push one architecture-specific development image (main push with [CI]) to moshiro-dev.
|
||||
set -euo pipefail
|
||||
|
||||
[[ "${CI_PIPELINE_EVENT:-}" == push && "${CI_COMMIT_BRANCH:-}" == main && "${CI_COMMIT_MESSAGE:-}" == *"[CI]"* ]] || {
|
||||
@@ -7,11 +7,20 @@ set -euo pipefail
|
||||
exit 2
|
||||
}
|
||||
|
||||
component="${1:?usage: build-dev-image.sh <backend|agent|probe>}"
|
||||
component="${1:?usage: build-dev-image.sh <backend|agent|probe> [amd64|arm64]}"
|
||||
arch="${2:-amd64}"
|
||||
case "$component" in
|
||||
backend|agent|probe) ;;
|
||||
*) echo "unsupported component: $component" >&2; exit 2 ;;
|
||||
esac
|
||||
case "$arch" in
|
||||
amd64|arm64) ;;
|
||||
*) echo "unsupported architecture: $arch" >&2; exit 2 ;;
|
||||
esac
|
||||
if [[ "$component" == backend && "$arch" != amd64 ]]; then
|
||||
echo "the main development pipeline currently builds Backend for amd64 only" >&2
|
||||
exit 2
|
||||
fi
|
||||
[[ -n "${ZOT_USERNAME:-}" && -n "${ZOT_SECRET:-}" ]] || {
|
||||
echo "Zot credentials are required" >&2
|
||||
exit 2
|
||||
@@ -28,7 +37,7 @@ moshiro_apply_version
|
||||
registry="${ZOT_REGISTRY:-registry.oeo.one}"
|
||||
repository="$registry/moshiro-dev/moshiro-$component"
|
||||
work="$root/.release/dev-image-build"
|
||||
base_home="/home/justme/woodpecker/buildah-home/dev-image-build-$component"
|
||||
base_home="/home/justme/woodpecker/buildah-home/dev-image-build-$component-$arch"
|
||||
# 镜像标签不带 v(和正式版一致):latest 和 <版本>;构建信息和清单里的 tag 带 v
|
||||
image_version="$MOSHIRO_VERSION"
|
||||
mkdir -p "$work" "$base_home"
|
||||
@@ -39,7 +48,7 @@ if [[ "$component" == backend ]]; then
|
||||
ZOT_IMAGE_REPOSITORY="$repository" \
|
||||
IMAGE_TAGS="latest,$image_version" \
|
||||
IMAGE_PUBLISH=true \
|
||||
bash "$root/ci/release-linux.sh" amd64 backend
|
||||
bash "$root/ci/release-linux.sh" "$arch" backend
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@@ -47,11 +56,14 @@ export HOME="$base_home"
|
||||
export BUILDAH_HOME="$base_home"
|
||||
export REGISTRY_AUTH_FILE="$work/$component-auth.json"
|
||||
context="$work/$component"
|
||||
local_image="localhost/moshiro-$component:dev-amd64-check"
|
||||
local_image="localhost/moshiro-$component:dev-$arch-check"
|
||||
node_rid="linux-musl-x64"
|
||||
[[ "$arch" == arm64 ]] && node_rid="linux-musl-arm64"
|
||||
|
||||
python3 "$root/ci/stage-node-image.py" "$component" "$context"
|
||||
buildah bud --layers --network host --tls-verify=true --arch amd64 \
|
||||
buildah bud --layers --network host --tls-verify=true --arch "$arch" \
|
||||
--build-arg "APP_VERSION=$image_version" \
|
||||
--build-arg "NODE_RID=$node_rid" \
|
||||
--build-arg "MOSHIRO_TAG=$MOSHIRO_TAG" --build-arg "MOSHIRO_COMMIT=${CI_COMMIT_SHA:0:10}" --build-arg "MOSHIRO_BUILT_AT=$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
|
||||
-f "$context/Containerfile" \
|
||||
-t "$local_image" "$context"
|
||||
@@ -69,7 +81,7 @@ for attempt in 1 2 3 4; do
|
||||
done
|
||||
[[ "$logged_in" == true ]] || { echo "could not authenticate to Zot after 4 attempts" >&2; exit 1; }
|
||||
|
||||
for tag in latest "$image_version"; do
|
||||
for tag in "$image_version-$arch"; do
|
||||
pushed=false
|
||||
for attempt in 1 2 3; do
|
||||
if buildah push --tls-verify=true --digestfile "$work/$component.digest" "$local_image" "docker://$repository:$tag"; then
|
||||
@@ -85,8 +97,8 @@ for tag in latest "$image_version"; do
|
||||
echo "pushed development image $repository:$tag"
|
||||
done
|
||||
|
||||
# 发布清单:给镜像的 digest 签名(私钥只在 CI 密钥里),放进镜像仓库(<仓库>-manifest:dev),面板在线时再登记一份加速。
|
||||
# 没有配置签名密钥(例如 fork)就只构建镜像、不发清单。
|
||||
if [[ -n "${RELEASE_SIGNING_KEY:-}" ]]; then
|
||||
# Agent and Probe manifests are signed after both architecture-specific images
|
||||
# have been pushed. Backend is still a single-architecture development image.
|
||||
if [[ "$component" == backend && -n "${RELEASE_SIGNING_KEY:-}" ]]; then
|
||||
bash "$root/ci/publish-release-offer.sh" "$component" "$repository" "$(cat "$work/$component.digest")" "$MOSHIRO_TAG" dev "$work/$component-release"
|
||||
fi
|
||||
Executable
+66
@@ -0,0 +1,66 @@
|
||||
#!/usr/bin/env bash
|
||||
# Publish the pullable multi-architecture development tags for Agent or Probe.
|
||||
set -euo pipefail
|
||||
|
||||
component="${1:?usage: publish-dev-node-index.sh <agent|probe>}"
|
||||
case "$component" in
|
||||
agent|probe) ;;
|
||||
*) echo "unsupported component: $component" >&2; exit 2 ;;
|
||||
esac
|
||||
[[ "${CI_PIPELINE_EVENT:-}" == push && "${CI_COMMIT_BRANCH:-}" == main && "${CI_COMMIT_MESSAGE:-}" == *"[CI]"* ]] || {
|
||||
echo "development node indexes require a main push with [CI] in the commit message" >&2
|
||||
exit 2
|
||||
}
|
||||
[[ "${CI_COMMIT_SHA:-}" =~ ^[0-9a-fA-F]{40}$ ]] || {
|
||||
echo "CI_COMMIT_SHA must be a full commit SHA" >&2
|
||||
exit 2
|
||||
}
|
||||
[[ -n "${ZOT_USERNAME:-}" && -n "${ZOT_SECRET:-}" ]] || {
|
||||
echo "Zot credentials are required" >&2
|
||||
exit 2
|
||||
}
|
||||
|
||||
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
source "$root/ci/version.sh"
|
||||
registry="${ZOT_REGISTRY:-registry.oeo.one}"
|
||||
repository="$registry/moshiro-dev/moshiro-$component"
|
||||
work="$root/.release/dev-image-index/$component"
|
||||
home="/home/justme/woodpecker/buildah-home/dev-node-index-$component"
|
||||
export HOME="$home"
|
||||
export REGISTRY_AUTH_FILE="$work/auth.json"
|
||||
mkdir -p "$work" "$home"
|
||||
|
||||
logged_in=false
|
||||
for attempt in 1 2 3 4; do
|
||||
if buildah login --tls-verify=true --username "$ZOT_USERNAME" --password-stdin "$registry" <<< "$ZOT_SECRET" >/dev/null; then
|
||||
logged_in=true
|
||||
break
|
||||
fi
|
||||
if [[ "$attempt" -lt 4 ]]; then
|
||||
echo "Zot login attempt $attempt failed; retrying in 3 seconds" >&2
|
||||
sleep 3
|
||||
fi
|
||||
done
|
||||
[[ "$logged_in" == true ]] || { echo "could not authenticate to Zot after 4 attempts" >&2; exit 1; }
|
||||
|
||||
manifest="localhost/moshiro-$component:$MOSHIRO_VERSION-multiarch"
|
||||
buildah manifest rm "$manifest" >/dev/null 2>&1 || true
|
||||
buildah manifest create "$manifest" >/dev/null
|
||||
buildah manifest add "$manifest" "docker://$repository:$MOSHIRO_VERSION-amd64" >/dev/null
|
||||
buildah manifest add "$manifest" "docker://$repository:$MOSHIRO_VERSION-arm64" >/dev/null
|
||||
|
||||
push_tag() {
|
||||
local tag="$1"
|
||||
buildah manifest push --all --format oci --digestfile "$work/$component.digest" \
|
||||
"$manifest" "docker://$repository:$tag" >/dev/null
|
||||
echo "published multi-architecture development image $repository:$tag"
|
||||
}
|
||||
|
||||
push_tag "$MOSHIRO_VERSION"
|
||||
push_tag latest
|
||||
buildah manifest rm "$manifest" >/dev/null
|
||||
|
||||
if [[ -n "${RELEASE_SIGNING_KEY:-}" ]]; then
|
||||
bash "$root/ci/publish-release-offer.sh" "$component" "$repository" \
|
||||
"$(cat "$work/$component.digest")" "$MOSHIRO_TAG" dev "$work/release"
|
||||
fi
|
||||
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Stage source and restore files for the Linux amd64 Agent or Probe image build."""
|
||||
"""Stage source and restore files for a Linux Agent or Probe image build."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
Reference in new issue
Block a user