This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
idhub-docker/build__common.sh

60 lines
1.5 KiB
Bash
Raw Normal View History

#!/bin/sh
set -e
set -u
# DEBUG
#set -x
common_start() {
figlet -w 100 "${target}"
deployment="${1:-${deployment:-}}"
action="${action:-deploy}"
persistence="${persistence:-y}"
# detach on production deployment
if [ "${deployment}" = 'prod' ]; then
detach='-d'
fi
# ensure uses main branch branch and that it is up to date
(
cd ./IdHub
if [ -d .git ]; then
git checkout main
git pull
fi
)
# some targets might use idhub1 and/or idhub2
idhub="${idhub:-idhub__${target}}"
idhub1="${idhub1:-idhub1__${target}}"
idhub2="${idhub2:-idhub2__${target}}"
if [ "${persistence}" = "n" ]; then
# no data persistence: cleanup previous possible data
rm -rf "./${idhub}"
fi
}
common_end() {
dc_file="docker-compose__${target}.yml"
if [ "${persistence}" = "n" ]; then
# no data persistence, then cleanup docker volume
vol_arg='-v'
fi
docker compose -p ${target} -f ${dc_file} down ${vol_arg:-} || true
make idhub_build
if [ "${action:-}" = "deploy" ]; then
docker compose -p ${target} -f ${dc_file} up ${detach:-}
wait_seconds="${wait_seconds:-20}"
echo "Give ${wait_seconds} seconds to this new deployment to be setted up"
sleep "${wait_seconds}"
fi
}