traccar: resolve Caddy local/remote mode like configure_caddy_for_service does
The caddy_net wiring for the new db/traccar containers was gated only on whether ~/docker/caddy exists locally, so it didn't account for a site where Caddy runs on a different box (CADDY_MODE=remote or the legacy CADDY_REMOTE_HOST var, set with no local Caddy directory). Resolve the mode the same way configure_caddy_for_service does — explicit CADDY_MODE first, then the local directory, then CADDY_REMOTE_HOST — so caddy_net is only joined when Caddy is actually local. A remote Caddy reaches Traccar via this host's published 8082 port regardless, so no other change is needed for that path.
This commit is contained in:
+12
-5
@@ -216,15 +216,22 @@ install_traccar() {
|
||||
|
||||
local TZ_VAL="${SITE_TZ:-$(cat /etc/timezone 2>/dev/null || echo UTC)}"
|
||||
|
||||
# Mirrors configure_caddy_for_service's own mode resolution (lib/common.sh)
|
||||
# so this matches whatever Caddy setup the site actually has: an explicit
|
||||
# CADDY_MODE from the site config wins, then a local ~/docker/caddy, then
|
||||
# the legacy CADDY_REMOTE_HOST var. Only "local" joins caddy_net — a remote
|
||||
# Caddy box can't resolve container names on this host's bridge network
|
||||
# anyway, it reaches Traccar via this host's published 8082 port instead.
|
||||
local _CADDY_MODE="${CADDY_MODE:-none}"
|
||||
[ "$_CADDY_MODE" = "none" ] && [ -d "$DOCKER_DIR/caddy" ] && _CADDY_MODE="local"
|
||||
[ "$_CADDY_MODE" = "none" ] && [ -n "${CADDY_REMOTE_HOST:-}" ] && _CADDY_MODE="remote"
|
||||
|
||||
local _CADDY_NET_BLOCK=""
|
||||
if [ -d "$DOCKER_DIR/caddy" ]; then
|
||||
local _CADDY_NET_SECTION=""
|
||||
if [ "$_CADDY_MODE" = "local" ]; then
|
||||
_CADDY_NET_BLOCK=" networks:
|
||||
- caddy_net
|
||||
"
|
||||
fi
|
||||
|
||||
local _CADDY_NET_SECTION=""
|
||||
if [ -d "$DOCKER_DIR/caddy" ]; then
|
||||
_CADDY_NET_SECTION="
|
||||
networks:
|
||||
caddy_net:
|
||||
|
||||
Reference in New Issue
Block a user