mirror of
https://github.com/ArchiveBox/ArchiveBox.git
synced 2026-09-12 19:50:57 +05:00
Fix multi-platform Docker release scripts
This commit is contained in:
parent
9814932d37
commit
28b890a2c7
@ -22,7 +22,13 @@ declare -a TAG_NAMES=("$@")
|
||||
BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}"
|
||||
VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
|
||||
GIT_SHA=sha-"$(git rev-parse --short HEAD)"
|
||||
SELECTED_PLATFORMS="${DOCKER_PLATFORMS:-${SELECTED_PLATFORMS:-linux/amd64}}"
|
||||
NATIVE_ARCH="$(docker info --format '{{.Architecture}}' 2>/dev/null || uname -m)"
|
||||
case "$NATIVE_ARCH" in
|
||||
x86_64|amd64) NATIVE_PLATFORM="linux/amd64" ;;
|
||||
aarch64|arm64) NATIVE_PLATFORM="linux/arm64" ;;
|
||||
*) NATIVE_PLATFORM="linux/$NATIVE_ARCH" ;;
|
||||
esac
|
||||
SELECTED_PLATFORMS="${DOCKER_PLATFORMS:-${SELECTED_PLATFORMS:-$NATIVE_PLATFORM}}"
|
||||
|
||||
# if not already in TAG_NAMES, add GIT_SHA and BRANCH_NAME
|
||||
if ! echo "${TAG_NAMES[@]}" | grep -q "$GIT_SHA"; then
|
||||
@ -94,4 +100,8 @@ echo "[+] Building archivebox:$VERSION docker image..."
|
||||
# docker build . --no-cache -t archivebox-dev \
|
||||
# replace --load with --push to deploy
|
||||
# shellcheck disable=SC2068
|
||||
if [[ "$SELECTED_PLATFORMS" == *,* ]]; then
|
||||
echo "[X] --load only supports a single platform. Use bin/release_docker.sh or set DOCKER_PLATFORMS to one platform." >&2
|
||||
exit 1
|
||||
fi
|
||||
docker buildx build --platform "$SELECTED_PLATFORMS" --load . ${FULL_TAG_NAMES[@]}
|
||||
|
||||
@ -17,7 +17,7 @@ declare -a TAG_NAMES=("$@")
|
||||
BRANCH_NAME="${1:-$(git rev-parse --abbrev-ref HEAD)}"
|
||||
VERSION="$(grep '^version = ' "${REPO_DIR}/pyproject.toml" | awk -F'"' '{print $2}')"
|
||||
GIT_SHA=sha-"$(git rev-parse --short HEAD)"
|
||||
SELECTED_PLATFORMS="${DOCKER_PLATFORMS:-${SELECTED_PLATFORMS:-linux/amd64}}"
|
||||
SELECTED_PLATFORMS="${DOCKER_PLATFORMS:-${SELECTED_PLATFORMS:-linux/amd64,linux/arm64}}"
|
||||
|
||||
# if not already in TAG_NAMES, add GIT_SHA and BRANCH_NAME
|
||||
if ! echo "${TAG_NAMES[@]}" | grep -q "$GIT_SHA"; then
|
||||
@ -50,8 +50,22 @@ mkdir -p "$HOME/.cache/docker/archivebox"
|
||||
|
||||
# https://docs.docker.com/build/cache/backends/
|
||||
# shellcheck disable=SC2068
|
||||
exec docker buildx build \
|
||||
docker buildx build \
|
||||
--platform "$SELECTED_PLATFORMS" \
|
||||
--cache-from type=local,src="$HOME/.cache/docker/archivebox" \
|
||||
--cache-to type=local,compression=zstd,mode=min,oci-mediatypes=true,dest="$HOME/.cache/docker/archivebox" \
|
||||
--push . ${FULL_TAG_NAMES[@]}
|
||||
|
||||
echo "[^] Verifying pushed Docker manifests include: $SELECTED_PLATFORMS"
|
||||
for TAG_NAME in "${TAG_NAMES[@]}"; do
|
||||
[[ "$TAG_NAME" == "" ]] && continue
|
||||
MANIFEST="$(docker buildx imagetools inspect "archivebox/archivebox:$TAG_NAME")"
|
||||
for REQUIRED_PLATFORM in ${SELECTED_PLATFORMS//,/$IFS}; do
|
||||
if ! echo "$MANIFEST" | grep -q "Platform: $REQUIRED_PLATFORM"; then
|
||||
echo "[X] archivebox/archivebox:$TAG_NAME is missing platform: $REQUIRED_PLATFORM" >&2
|
||||
echo "$MANIFEST" >&2
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
done
|
||||
echo "[√] Docker manifests include all requested platforms."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user