docker-restic-cron/hooks/post_push

56 lines
1.4 KiB
Plaintext
Raw Permalink Normal View History

2020-02-11 01:49:39 +00:00
#!/bin/bash
# Use manifest-tool to create the manifest, given the experimental
# "docker manifest" command isn't available yet on Docker Hub.
2020-02-11 02:36:33 +00:00
TAG_ROOT=${DOCKER_TAG%-*}
2020-02-11 02:46:44 +00:00
TARGET_ARCH=""
case "$DOCKER_TAG" in
*amd64)
TARGET_ARCH="amd64"
;;
*arm32v5)
TARGET_ARCH="arm/v5"
2020-02-11 02:46:44 +00:00
;;
*arm32v6)
TARGET_ARCH="arm/v6"
2020-02-11 02:46:44 +00:00
;;
*arm32v7)
TARGET_ARCH="arm/v7"
2020-02-11 02:46:44 +00:00
;;
*arm64v8)
TARGET_ARCH="arm64/v8"
2020-02-11 02:46:44 +00:00
;;
*i386)
TARGET_ARCH="i386"
;;
*ppc64le)
TARGET_ARCH="ppc64le"
;;
*s390x)
TARGET_ARCH="s390x"
;;
*)
echo "Unknown target arch, skip manifest push"
exit 0
;;
esac
# If the tag is essentially only the arch, we use latest
if [[ "$TAG_ROOT" == "$TARGET_ARCH" ]]; then
TAG_ROOT="latest"
2020-02-11 02:36:33 +00:00
fi
curl -Lo manifest-tool https://github.com/estesp/manifest-tool/releases/download/v1.0.0/manifest-tool-linux-amd64
2020-02-11 01:49:39 +00:00
chmod +x manifest-tool
# Generate manifest file for this repo and tag root
sed "s#{DOCKER_REPO}#${DOCKER_REPO%:*}#;s#{TAG_ROOT}#${TAG_ROOT}#" multi-arch-manifest-tmpl.yml > multi-arch-manifest.yml
./manifest-tool push from-spec --ignore-missing multi-arch-manifest.yml
# Fix arch for image tags
2020-02-11 02:36:33 +00:00
./manifest-tool push from-args \
--platforms "linux/$TARGET_ARCH" \
2020-02-11 02:46:44 +00:00
--template "$DOCKER_REPO:$DOCKER_TAG" \
--target "$DOCKER_REPO:$DOCKER_TAG"