2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-14 16:33:57 +00:00
pict-rs/docker/prod/deploy.sh

88 lines
2 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:"
2021-08-28 22:50:56 +00:00
echo " deploy.sh [tag] [branch] [push]"
2020-06-07 23:29:41 +00:00
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"
2021-08-28 22:50:56 +00:00
echo " push: Whether or not to push the image"
echo ""
echo "Examples:"
echo " ./deploy.sh v0.3.0-alpha.13 main true"
echo " ./deploy.sh v0.3.0-alpha.13-shell-out asonix/shell-out false"
2020-06-07 23:29:41 +00:00
}
2020-06-08 01:16:18 +00:00
function build_image() {
tag=$1
arch=$2
2021-08-28 22:50:56 +00:00
push=$3
2020-06-08 01:16:18 +00:00
2020-06-15 19:20:25 +00:00
./build-image.sh asonix/pictrs $tag $arch
2020-06-08 01:16:18 +00:00
sudo docker tag asonix/pictrs:$arch-$tag asonix/pictrs:$arch-latest
2020-06-28 22:19:55 +00:00
2021-08-28 22:50:56 +00:00
if [ "$push" == "true" ]; then
sudo docker push asonix/pictrs:$arch-$tag
sudo docker push asonix/pictrs:$arch-latest
fi
2020-06-08 01:16:18 +00:00
}
# Creating the new tag
new_tag="$1"
2020-06-24 16:58:46 +00:00
branch="$2"
2021-08-28 22:50:56 +00:00
push=$3
2020-06-07 23:29:41 +00:00
require "$new_tag" "tag"
2020-06-24 16:58:46 +00:00
require "$branch" "branch"
2021-08-28 22:50:56 +00:00
require "$push" "push"
2020-06-07 23:29:41 +00:00
if ! sudo docker run --rm -it arm64v8/alpine:3.11 /bin/sh -c 'echo "docker is configured correctly"'
2020-06-07 23:29:41 +00:00
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
2020-10-11 01:27:57 +00:00
# Build for arm64v8, arm32v7 and amd64
2021-08-28 22:50:56 +00:00
build_image $new_tag arm64v8 $push
build_image $new_tag arm32v7 $push
build_image $new_tag amd64 $push
2020-06-07 23:42:11 +00:00
2020-06-07 23:29:41 +00:00
# Build for other archs
# TODO
2021-08-28 22:50:56 +00:00
if [ "$push" == "true" ]; then
2021-09-06 20:26:30 +00:00
./manifest.sh pictrs $new_tag
./manifest.sh pictrs latest
2021-09-04 20:06:58 +00:00
2021-11-01 15:48:31 +00:00
# pushd ../../
# cargo publish
# popd
2021-08-28 22:50:56 +00:00
fi