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