GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — SpacetimeDB/tools/merge-docker-images.sh at master · oracle58/SpacetimeDB

Expand file tree

/

merge-docker-images.sh

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
executable file
·
51 lines (42 loc) · 1.8 KB
/

merge-docker-images.sh

Copy path

File metadata and controls

executable file
·
51 lines (42 loc) · 1.8 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
set -e
set -u
sanitize_docker_ref() {
echo "$1" | tr '[:upper:]' '[:lower:]' | sed -e 's/[^a-z0-9._-]/-/g' -e 's/^[.-]//g' -e 's/[.-]$//g'
}
IMAGE_NAME="$1"
# Docker tag to use for platform-specific images
TAG="$2"
# Docker tag to use for the "universal" image
FULL_TAG="$3"
# Check if images for both amd64 and arm64 exist
if docker pull "${IMAGE_NAME}":$TAG-amd64 --platform amd64 >/dev/null 2>&1 && docker pull "${IMAGE_NAME}":$TAG-arm64 --platform arm64 >/dev/null 2>&1; then
echo "Both images exist, preparing the merged manifest"
else
echo "One or both images do not exist. Exiting"
exit 0
fi
# Extract digests
AMD64_DIGEST=$(docker manifest inspect "${IMAGE_NAME}":$TAG-amd64 | jq -r '.manifests[0].digest')
ARM64_DIGEST=$(docker manifest inspect "${IMAGE_NAME}":$TAG-arm64 | jq -r '.manifests[0].digest')
# Create a new manifest using extracted digests
docker manifest create "${IMAGE_NAME}":$FULL_TAG \
"${IMAGE_NAME}"@$AMD64_DIGEST \
"${IMAGE_NAME}"@$ARM64_DIGEST
# Annotate the manifest with with proper platforms
docker manifest annotate "${IMAGE_NAME}":$FULL_TAG \
"${IMAGE_NAME}"@$ARM64_DIGEST --os linux --arch arm64
docker manifest annotate "${IMAGE_NAME}":$FULL_TAG \
"${IMAGE_NAME}"@$AMD64_DIGEST --os linux --arch amd64
docker manifest push "${IMAGE_NAME}":$FULL_TAG
# if undefined, use the empty string
GITHUB_REF="${GITHUB_REF-}"
# re-tag the manifest with the GitHub ref
echo "GITHUB_REF is ${GITHUB_REF}"
if [[ "${GITHUB_REF}" == refs/tags/* ]]; then
ORIGINAL_VERSION=${GITHUB_REF#refs/*/}
VERSION=$(sanitize_docker_ref "$ORIGINAL_VERSION")
echo "Tagging image with sanitized GITHUB_REF: $VERSION (original: $ORIGINAL_VERSION)"
docker buildx imagetools create "${IMAGE_NAME}":$FULL_TAG --tag "${IMAGE_NAME}":$VERSION
fi
echo "Image merging and tagging completed successfully."
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.