From 7cb50fc4968d27b05c933da6e208d4f74e5224a5 Mon Sep 17 00:00:00 2001 From: Jiri Uhlir Date: Thu, 21 May 2026 11:51:55 +0200 Subject: [PATCH] Stabilize Caddy generation --- scripts/deploy-app.sh | 39 +++++++++++++++-------------- scripts/generate-caddyfile.sh | 46 +++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 18 deletions(-) create mode 100755 scripts/generate-caddyfile.sh diff --git a/scripts/deploy-app.sh b/scripts/deploy-app.sh index 67035ff..c02f167 100755 --- a/scripts/deploy-app.sh +++ b/scripts/deploy-app.sh @@ -56,24 +56,24 @@ EOF fi -if ! grep -q "apps/$APP_ID" "$BASE_DIR/gateway/Caddyfile"; then - -TMP_FILE=$(mktemp) - -sed '$d' "$CADDY_FILE" > "$TMP_FILE" - -cat >> "$TMP_FILE" < "$TMP_FILE" +# +#cat >> "$TMP_FILE" <> "$CATALOG_FILE" < "$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