Stabilize Caddy generation

This commit is contained in:
2026-05-21 11:51:55 +02:00
parent 8ecdf2d4eb
commit 7cb50fc496
2 changed files with 67 additions and 18 deletions
+21 -18
View File
@@ -56,24 +56,24 @@ EOF
fi fi
if ! grep -q "apps/$APP_ID" "$BASE_DIR/gateway/Caddyfile"; then #if ! grep -q "apps/$APP_ID" "$BASE_DIR/gateway/Caddyfile"; then
#
TMP_FILE=$(mktemp) #TMP_FILE=$(mktemp)
#
sed '$d' "$CADDY_FILE" > "$TMP_FILE" #sed '$d' "$CADDY_FILE" > "$TMP_FILE"
#
cat >> "$TMP_FILE" <<EOF #cat >> "$TMP_FILE" <<EOF
#
handle_path /apps/$APP_ID/* { # handle_path /apps/$APP_ID/* {
reverse_proxy $APP_ID:8000 # reverse_proxy $APP_ID:8000
} # }
#
} #}
EOF #EOF
#
mv "$TMP_FILE" "$CADDY_FILE" #mv "$TMP_FILE" "$CADDY_FILE"
#
fi #fi
echo "Restarting stack..." echo "Restarting stack..."
@@ -99,6 +99,9 @@ cat >> "$CATALOG_FILE" <<EOF
EOF EOF
fi fi
"$HOME/workspace/appfactory-tools/scripts/generate-caddyfile.sh"
"$HOME/workspace/appfactory-tools/scripts/generate-apps-page.sh"
echo "" echo ""
echo "DONE" echo "DONE"
echo "" echo ""
+46
View File
@@ -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