49 lines
1.4 KiB
Bash
Executable file
49 lines
1.4 KiB
Bash
Executable file
#!/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-2021-10-26.pem ]; then
|
|
echo
|
|
echo "Couldn't find required CURL_CA_BUNDLE env variable..."
|
|
echo "Downloading https://curl.se/ca/cacert-2021-10-26.pem to ~/Downloads/cacert-2021-10-26.pem"
|
|
echo
|
|
curl https://curl.se/ca/cacert-2021-10-26.pem -o ~/Downloads/cacert-2021-10-26.pem
|
|
fi
|
|
export CURL_CA_BUNDLE=~/Downloads/cacert-2021-10-26.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 hub.greenbaum.cloud/miom.space:"$TAG" .
|
|
|
|
# login to Greenbaum's private docker registry and push the image
|
|
docker login hub.greenbaum.cloud
|
|
docker push hub.greenbaum.cloud/miom.space:"$TAG"
|
|
|
|
# change DOCKER_HOST env var to remote docker host (Greenbaum's docker API)
|
|
eval "$(triton --account=pub_solar env)"
|
|
|
|
# use our tag for docker-compose
|
|
export DEPLOY_TAG="$TAG"
|
|
|
|
# deploy on Greenbaum Cloud
|
|
docker-compose up -d
|