relay/docker/prod/deploy.sh

62 lines
1.3 KiB
Bash
Raw Normal View History

2020-06-10 22:45:59 +00:00
#!/usr/bin/env bash
TAG=$1
function require() {
if [ "$1" = "" ]; then
echo "input '$2' required"
print_help
exit 1
fi
}
function print_help() {
echo "build.sh"
echo ""
echo "Usage:"
2021-02-10 04:05:06 +00:00
echo " build.sh [tag]"
2020-06-10 22:45:59 +00:00
echo ""
echo "Args:"
echo " tag: The git tag to create and publish"
}
function build_image() {
repo=$1
tag=$2
arch=$3
2021-08-01 20:14:44 +00:00
sudo docker build \
2020-06-10 22:45:59 +00:00
--pull \
--build-arg TAG="${tag}" \
-f "Dockerfile.${arch}" \
-t "${repo}:${tag}-${arch}" \
-t "${repo}:latest-${arch}" \
2020-06-10 22:46:40 +00:00
.
2020-06-10 22:45:59 +00:00
2021-08-01 20:14:44 +00:00
sudo docker push "${repo}:${tag}-${arch}"
sudo docker push "${repo}:latest-${arch}"
2020-06-10 22:45:59 +00:00
}
require "$TAG" "tag"
2021-08-01 20:14:44 +00:00
if ! sudo docker run --rm -it arm64v8/ubuntu:19.10 /bin/bash -c 'echo "docker is configured correctly"'; then
echo "docker is not configured to run on qemu-emulated architectures"
2020-06-10 22:45:59 +00:00
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
fi
set -xe
2020-06-20 04:15:33 +00:00
git checkout main
2020-06-27 22:29:23 +00:00
git commit -m "Version $TAG" || true
2020-06-10 22:45:59 +00:00
git tag $TAG
git push origin $TAG
git push
build_image "asonix/relay" "$TAG" "arm64v8"
build_image "asonix/relay" "$TAG" "arm32v7"
build_image "asonix/relay" "$TAG" "amd64"
./manifest.sh "asonix/relay" "$TAG"
./manifest.sh "asonix/relay" "latest"