2024-01-19 10:01:49 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
set -u
|
|
|
|
# DEBUG
|
|
|
|
#set -x
|
|
|
|
|
|
|
|
common_start() {
|
2024-02-05 19:06:12 +00:00
|
|
|
figlet -w 100 "${target}"
|
2024-01-19 10:01:49 +00:00
|
|
|
|
|
|
|
deployment="${1:-${deployment:-}}"
|
|
|
|
action="${action:-deploy}"
|
2024-02-06 13:29:14 +00:00
|
|
|
persistence="${persistence:-y}"
|
2024-01-19 10:01:49 +00:00
|
|
|
|
|
|
|
# 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
|
2024-02-05 19:48:20 +00:00
|
|
|
idhub="${idhub:-idhub__${target}}"
|
2024-02-05 18:18:57 +00:00
|
|
|
idhub1="${idhub1:-idhub1__${target}}"
|
|
|
|
idhub2="${idhub2:-idhub2__${target}}"
|
2024-02-06 13:29:14 +00:00
|
|
|
|
|
|
|
if [ "${persistence}" = "n" ]; then
|
|
|
|
# no data persistence: cleanup previous possible data
|
|
|
|
rm -rf "./${idhub}"
|
|
|
|
fi
|
2024-01-19 10:01:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
common_end() {
|
|
|
|
|
2024-02-05 18:18:57 +00:00
|
|
|
dc_file="docker-compose__${target}.yml"
|
2024-02-06 13:29:14 +00:00
|
|
|
|
|
|
|
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
|
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
|
|
|
|
|
|
|
|
}
|