AutoDevReverseProxy/templates/caddy.sh

33 lines
833 B
Bash

#!/usr/bin/env bash
set -e
DOCKER_SOCK_PATH="${DOCKER_SOCK_PATH:-/tmp/docker.sock}"
DOCKER_CADDY_NAME="${DOCKER_CADDY_NAME:-proxy}"
DOCKER_CADDY_PORT="${DOCKER_CADDY_PORT:-2020}"
WRAP_START='{\n admin :2020\n}\n'
WRAP_END='\n'
TEMPLATE='${LOCAL_WEB_HOST} {\n reverse_proxy ${LOCAL_IP}:$LOCAL_WEB_PORT\n}'
SEPARATOR='\n'
OUT='/config/Caddyfile'
label_hook() {
LOCAL_WEB_PORT="${LOCAL_WEB_PORT:-80}"
}
template_hook() {
printf "%s" "${PARTIAL_RESULT}"
if grep '^[^ ]\+ {\\n reverse_proxy \(?::\|[.0-9a-e]\)\+\:[0-9]\+\\n}$' <<< "${PARTIAL_RESULT}"
then
return 0;
fi
return 1;
}
# finally_hook() {
# if curl --silent -g "${DOCKER_CADDY_NAME}:${DOCKER_CADDY_PORT}/load"
# then
# printf "Updated Caddy Config"
# else
# printf "Failed to update Caddy Config"
# fi
# }