pict-rs/docker/prod/deploy.sh

71 lines
1.4 KiB
Bash
Raw Normal View History

2020-06-07 23:29:41 +00:00
#!/usr/bin/env bash
function require() {
if [ "$1" = "" ]; then
echo "input '$2' required"
print_help
exit 1
fi
}
function print_help() {
echo "deploy.sh"
echo ""
echo "Usage:"
echo " deploy.sh [tag]"
echo ""
echo "Args:"
echo " tag: The git tag to be applied to the repository and docker build"
2020-06-24 16:58:46 +00:00
echo " branch: The git branch to use for tagging and publishing"
2020-06-07 23:29:41 +00:00
}
2020-06-08 01:16:18 +00:00
function build_image() {
tag=$1
arch=$2
2020-06-15 19:20:25 +00:00
./build-image.sh asonix/pictrs $tag $arch
2020-06-08 01:16:18 +00:00
docker push asonix/pictrs:$arch-$tag
docker push asonix/pictrs:$arch-latest
}
# Creating the new tag
new_tag="$1"
2020-06-24 16:58:46 +00:00
branch="$2"
2020-06-07 23:29:41 +00:00
require "$new_tag" "tag"
2020-06-24 16:58:46 +00:00
require "$branch" "branch"
2020-06-07 23:29:41 +00:00
if ! docker run --rm -it arm64v8/alpine:3.11 /bin/sh -c 'echo "docker is configured correctly"'
then
echo "docker is not configured to run on qemu-emulated architectures, fixing will require sudo"
sudo docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
fi
set -xe
2020-06-24 16:58:46 +00:00
git checkout $branch
2020-06-07 23:29:41 +00:00
# Changing the docker-compose prod
2020-06-08 20:31:25 +00:00
sed -i "s/asonix\/pictrs:.*/asonix\/pictrs:$new_tag/" docker-compose.yml
git add ../prod/docker-compose.yml
# The commit
git commit -m"Version $new_tag"
git tag $new_tag
2020-06-07 23:29:41 +00:00
# Push
git push origin $new_tag
git push
# Build for arm64v8, arm32v7, and amd64
2020-06-08 01:16:18 +00:00
build_image $new_tag arm64v8
2020-06-16 23:38:52 +00:00
build_image $new_tag arm32v7
2020-06-08 01:28:16 +00:00
build_image $new_tag amd64
2020-06-07 23:42:11 +00:00
2020-06-07 23:29:41 +00:00
# Build for other archs
# TODO
2020-06-08 20:31:25 +00:00
./manifest.sh $new_tag
2020-06-08 20:34:35 +00:00
./manifest.sh latest