Stabilize Caddy generation
This commit is contained in:
Executable
+46
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
BASE_DIR="/opt/appfactory"
|
||||
CATALOG_FILE="$BASE_DIR/apps/catalog.yml"
|
||||
CADDY_FILE="$BASE_DIR/gateway/Caddyfile"
|
||||
|
||||
cat > "$CADDY_FILE" <<'EOF'
|
||||
:80 {
|
||||
handle /health {
|
||||
respond "AppFactory OK" 200
|
||||
}
|
||||
|
||||
handle /portal* {
|
||||
uri strip_prefix /portal
|
||||
reverse_proxy appfactory-portal:9100
|
||||
}
|
||||
|
||||
handle /apps {
|
||||
root * /srv/static
|
||||
rewrite * /apps.html
|
||||
file_server
|
||||
}
|
||||
|
||||
EOF
|
||||
|
||||
awk '
|
||||
/- id:/ { print " handle_path /apps/" $3 "/* {\n reverse_proxy " $3 ":8000\n }\n" }
|
||||
' "$CATALOG_FILE" >> "$CADDY_FILE"
|
||||
|
||||
cat >> "$CADDY_FILE" <<'EOF'
|
||||
handle_path /webhook/* {
|
||||
reverse_proxy appfactory-webhook:9000
|
||||
}
|
||||
|
||||
handle_path /registry/* {
|
||||
reverse_proxy registry:5000
|
||||
}
|
||||
|
||||
handle {
|
||||
respond "AppFactory gateway is running" 200
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
docker exec appfactory-caddy caddy reload --config /etc/caddy/Caddyfile || docker restart appfactory-caddy
|
||||
Reference in New Issue
Block a user