lab-ansible/roles/apps/templates/scripts/deploy.sh.j2

42 lines
1,010 B
Plaintext
Raw Normal View History

2024-02-04 17:03:15 +00:00
{# code: language=ansible-jinja #}
# THIS FILE IS MANAGED BY ANSIBLE
#!/usr/bin/env bash
2023-11-11 15:21:29 +00:00
ARG="$1"
APPS_DIR="{{ apps_data_root }}"
case $ARG in
start)
for app in $APPS_DIR/*; do
docker compose -f $app/docker-compose.yml up --remove-orphans -d
done
;;
stop)
for app in $APPS_DIR/*; do
docker compose -f $app/docker-compose.yml down --remove-orphans
done
;;
restart)
for app in $APPS_DIR/*; do
docker compose -f $app/docker-compose.yml restart
done
;;
2024-02-04 17:03:15 +00:00
{% if 'caddy' in apps_include %}
reload-proxy)
CADDYFILE="/etc/caddy/Caddyfile"
docker compose -f $APPS_DIR/caddy/docker-compose.yml exec web \
sh -c "caddy validate -c $CADDYFILE && caddy reload -c $CADDYFILE" \
2>/dev/null
;;
{% elif 'nginx' in apps_include %}
2023-12-31 17:20:28 +00:00
reload-proxy)
docker compose -f $APPS_DIR/nginx/docker-compose.yml exec web \
sh -c "nginx -t && nginx -s reload"
;;
2024-02-04 17:03:15 +00:00
{% endif %}
2023-11-11 15:21:29 +00:00
*)
echo "Unrecognized argument"
exit 1
;;
esac