transfer.sh/hooks/.config
Andrea Spacca 7b00a41d49 ISSUE-313
2020-06-14 16:55:57 +02:00

54 lines
No EOL
1.6 KiB
Bash

#!/usr/bin/env bash
set +u
echo "variables (see https://docs.docker.com/docker-hub/builds/advanced/):"
echo "SOURCE_BRANCH: $SOURCE_BRANCH"
echo "SOURCE_COMMIT: $SOURCE_COMMIT"
echo "COMMIT_MSG: $COMMIT_MSG"
echo "DOCKER_REPO: $DOCKER_REPO"
echo "DOCKERFILE_PATH: $DOCKERFILE_PATH"
echo "CACHE_TAG: $CACHE_TAG"
echo "IMAGE_NAME: $IMAGE_NAME"
echo
: "${DOCKERFILE_PATH:=./Dockerfile}"
: "${IMAGE_NAME:=dutchcoders/transer.sh}"
echo "variables after applying defaults:"
echo "DOCKERFILE_PATH: $DOCKERFILE_PATH"
echo "IMAGE_NAME: $IMAGE_NAME"
echo
export PATH="$PWD/docker:$PATH"
# =>
# https://hub.docker.com/u/arm64v8/
# https://hub.docker.com/u/arm32v7/
# https://hub.docker.com/u/arm32v6/
# https://hub.docker.com/u/arm32v5/
declare -A base_image_prefix_map=( ["aarch64"]="arm64v8/" ["arm"]="arm32v5/" ["amd64"]="")
# => dpkg -L qemu-user-static | grep /usr/bin/
declare -A docker_qemu_arch_map=( ["aarch64"]="aarch64" ["arm"]="arm" ["amd64"]="x86_64")
# => https://github.com/docker/docker-ce/blob/76ac3a4952a9c03f04f26fc88d3160acd51d1702/components/cli/cli/command/manifest/util.go#L22
declare -A docker_to_manifest_map=( ["aarch64"]="arm64" ["arm"]="arm" ["amd64"]="amd64")
# what we want to build
build_architectures=(amd64 aarch64 arm)
verified_build_architectures=()
verified_build_architectures+=("$(docker version -f '{{.Server.Arch}}')")
# what we can build
for arch in ${build_architectures[@]}; do
if [ -f "qemu-${docker_qemu_arch_map[${arch}]}-static" ]; then
echo "qemu binary for $arch found";
verified_build_architectures+=($arch)
fi
done
echo $verified_build_architectures
set -u
docker -v
echo