miom.space/deploy.sh

55 lines
1.6 KiB
Bash
Raw Normal View History

2022-01-16 18:32:04 +00:00
#!/usr/bin/env bash
2023-02-26 19:21:34 +00:00
# Abort on first error
2022-01-16 18:32:04 +00:00
set -e
TAG="$1"
if [[ -z "$TAG" ]]; then
echo
2022-01-17 09:51:34 +00:00
echo "Error: please provide a version as docker image tag as first argument, e.g.:"
2022-01-16 18:32:04 +00:00
echo "./deploy.sh 1.0.0"
echo
2022-01-16 21:02:12 +00:00
echo "You can check the currently deployed tag with"
2022-01-17 09:51:34 +00:00
echo 'docker ps --format "{{.Names}}: {{.Image}}"'
2022-01-16 21:02:12 +00:00
echo
2022-01-16 18:32:04 +00:00
exit 1
fi
2023-02-26 19:21:34 +00:00
# Workaround for SSL: CERTIFICATE_VERIFY_FAILED error with docker-compose
2022-01-16 18:32:04 +00:00
if [ -z "$CURL_CA_BUNDLE" ]; then
2022-03-31 17:11:07 +00:00
if [ ! -f ~/Downloads/cacert-2022-03-29.pem ]; then
2022-01-17 09:51:34 +00:00
echo
echo "Couldn't find required CURL_CA_BUNDLE env variable..."
2022-03-31 17:11:07 +00:00
echo "Downloading https://curl.se/ca/cacert-2022-03-29.pem to ~/Downloads/cacert-2022-03-29.pem"
2022-01-17 09:51:34 +00:00
echo
2022-03-31 17:11:07 +00:00
curl https://curl.se/ca/cacert-2022-03-29.pem -o ~/Downloads/cacert-2022-03-29.pem
2022-01-16 18:32:04 +00:00
fi
2022-03-31 17:11:07 +00:00
export CURL_CA_BUNDLE=~/Downloads/cacert-2022-03-29.pem
2022-01-16 18:32:04 +00:00
fi
2023-02-26 19:21:34 +00:00
# Make sure we're using the local docker host for building our image
2022-01-16 18:32:04 +00:00
eval "$(triton env --unset)"
2023-02-26 19:21:34 +00:00
# Build the image locally
docker build --tag registry.greenbaum.cloud/pub_solar/miom.space:"$TAG" .
2022-01-16 18:32:04 +00:00
2023-02-26 19:21:34 +00:00
# Login to Greenbaum's private docker registry and push the image
docker login registry.greenbaum.cloud
docker push registry.greenbaum.cloud/pub_solar/miom.space:"$TAG"
2022-01-16 18:32:04 +00:00
2023-02-26 19:21:34 +00:00
# Change DOCKER_HOST env var to remote docker host (Greenbaum's docker API)
2022-04-01 09:00:49 +00:00
eval "$(triton --account=pub_solar --url=https://lev-1.api.greenbaum.cloud env)"
2023-02-26 19:21:34 +00:00
#
# Login to Greenbaum's private docker registry with Triton, too
docker login registry.greenbaum.cloud
2022-01-16 18:32:04 +00:00
2023-02-26 19:21:34 +00:00
# Use our tag for docker-compose
2022-01-16 18:32:04 +00:00
export DEPLOY_TAG="$TAG"
2023-02-26 19:21:34 +00:00
# Pull the latest image
docker pull registry.greenbaum.cloud/pub_solar/miom.space:"$DEPLOY_TAG"
# Deploy on Greenbaum Cloud
2022-01-16 18:32:04 +00:00
docker-compose up -d