2024-01-19 10:01:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
# DEBUG
|
|
|
|
#set -x
|
|
|
|
|
|
|
|
common_start() {
|
2024-02-05 18:18:57 +00:00
|
|
|
figlet "${target}"
|
2024-01-19 10:01:49 +00:00
|
|
|
|
|
|
|
deployment="${1:-${deployment:-}}"
|
|
|
|
action="${action:-deploy}"
|
|
|
|
|
|
|
|
# detach on production deployment
|
|
|
|
if [ "${deployment}" = 'prod' ]; then
|
|
|
|
detach='-d'
|
|
|
|
fi
|
|
|
|
|
2024-02-05 18:18:57 +00:00
|
|
|
# ensure uses main branch branch and that it is up to date
|
2024-01-19 10:01:49 +00:00
|
|
|
(
|
|
|
|
cd ./IdHub
|
2024-01-23 09:42:42 +00:00
|
|
|
if [ -d .git ]; then
|
|
|
|
git checkout main
|
|
|
|
git pull
|
|
|
|
fi
|
2024-01-19 10:01:49 +00:00
|
|
|
)
|
|
|
|
|
2024-02-05 18:18:57 +00:00
|
|
|
# some targets might use idhub1 and/or idhub2
|
|
|
|
idhub1="${idhub1:-idhub1__${target}}"
|
|
|
|
idhub2="${idhub2:-idhub2__${target}}"
|
2024-01-19 10:01:49 +00:00
|
|
|
|
|
|
|
# force recreate
|
|
|
|
rm -rf "./${idhub1}" "./${idhub2}"
|
|
|
|
}
|
|
|
|
|
|
|
|
common_end() {
|
|
|
|
|
2024-02-05 18:18:57 +00:00
|
|
|
dc_file="docker-compose__${target}.yml"
|
|
|
|
docker compose -p ${target} -f ${dc_file} down -v || true
|
2024-01-19 10:01:49 +00:00
|
|
|
make idhub_build
|
|
|
|
|
|
|
|
if [ "${action:-}" = "deploy" ]; then
|
2024-02-05 18:18:57 +00:00
|
|
|
docker compose -p ${target} -f ${dc_file} up ${detach:-}
|
2024-01-25 14:57:20 +00:00
|
|
|
wait_seconds="${wait_seconds:-20}"
|
|
|
|
echo "Give ${wait_seconds} seconds to this new deployment to be setted up"
|
|
|
|
sleep "${wait_seconds}"
|
2024-01-19 10:01:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
}
|