-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
3 changed files
with
141 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
if [[ "$#" -lt "2" ]]; then | ||
>&2 echo "Usage: $0 <image name> <tag1> ..." | ||
>&2 echo "Example: $0 ghcr.io/zhaofengli/attic main abcd123" | ||
exit 1 | ||
fi | ||
|
||
cleanup() { | ||
if [[ -f "${manifest_spec}" ]]; then | ||
rm "${manifest_spec}" | ||
fi | ||
} | ||
trap cleanup EXIT | ||
|
||
image_name="$1" | ||
tags=("${@:2}") | ||
|
||
manifest_spec="$(mktemp -t attic-manifest-spec.XXXXXXXXXX)" | ||
|
||
declare -a digests | ||
|
||
emit_header() { | ||
echo "image: ${image_name}" | ||
echo "tags:" | ||
for tag in "${tags[@]}"; do | ||
echo "- ${tag}" | ||
done | ||
echo "manifests:" | ||
} | ||
|
||
push_digest() { | ||
source_image="docker-archive:$1" | ||
digest="$(skopeo inspect "${source_image}" | jq -r .Digest)" | ||
target_image="docker://${image_name}@${digest}" | ||
|
||
>&2 echo "${source_image} ▸ ${target_image}" | ||
>&2 skopeo copy --insecure-policy "${source_image}" "${target_image}" | ||
|
||
echo -n "- " | ||
skopeo inspect "${source_image}" | \ | ||
jq '{platform: {architecture: .Architecture, os: .Os}, image: ($image_name + "@" + .Digest)}' \ | ||
--arg image_name "${image_name}" | ||
} | ||
|
||
>>"${manifest_spec}" emit_header | ||
|
||
nix build .#attic-server-image .#attic-server-image-aarch64 -L --print-out-paths | \ | ||
while read -r output; do | ||
>>"${manifest_spec}" push_digest "${output}" | ||
done | ||
|
||
>&2 echo "----------" | ||
>&2 echo "Generated manifest-tool spec:" | ||
>&2 echo "----------" | ||
cat "${manifest_spec}" | ||
>&2 echo "----------" | ||
|
||
manifest-tool push from-spec "${manifest_spec}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters