81 lines
2.3 KiB
Bash
81 lines
2.3 KiB
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
set -u
|
|
# DEBUG
|
|
#set -x
|
|
|
|
common_start() {
|
|
figlet -w 120 "${target}"
|
|
|
|
deployment="${1:-${deployment:-}}"
|
|
action="${action:-deploy}"
|
|
persistence="${persistence:-y}"
|
|
idhub_branch="${idhub_branch:-main}"
|
|
|
|
# detach on production deployment
|
|
if [ "${deployment}" = 'prod' ]; then
|
|
detach='-d'
|
|
fi
|
|
|
|
# TODO at some point it would be better to use pull-repos.sh
|
|
# ensure uses main branch branch and that it is up to date
|
|
(
|
|
cd ./IdHub
|
|
if [ -d .git ]; then
|
|
git checkout ${idhub_branch}
|
|
git pull
|
|
fi
|
|
)
|
|
|
|
(
|
|
cd ./ssikit_trustchain
|
|
if [ -d .git ]; then
|
|
git checkout master
|
|
git pull
|
|
fi
|
|
)
|
|
|
|
# process idhubs instances for the purpose
|
|
for idhub in ${idhubs}; do
|
|
idhub_dir="${idhub}__${target}"
|
|
if [ "${persistence}" = "n" ]; then
|
|
# no data persistence: cleanup previous possible data
|
|
rm -rf "./${idhub_dir}"
|
|
fi
|
|
|
|
# detect existing deployment
|
|
if [ -d "./${idhub_dir}" ]; then
|
|
git -C "${idhub_dir}" pull
|
|
# looks new
|
|
else
|
|
echo "Detected new deployment, recreating git repos ${idhub_dir}"
|
|
cp -rp IdHub "${idhub_dir}"
|
|
# ensure the copy does not contain a DB
|
|
rm -f "${idhub_dir}/db.sqlite3"
|
|
fi
|
|
done
|
|
|
|
}
|
|
|
|
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:0}"
|
|
echo "Give ${wait_seconds} seconds to this new deployment to be setted up"
|
|
sleep "${wait_seconds}"
|
|
fi
|
|
|
|
}
|