52 lines
1000 B
Bash
Executable File
52 lines
1000 B
Bash
Executable File
#!/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_CADDY'
|
|
: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_CADDY
|
|
|
|
awk '
|
|
/- id:/ {
|
|
print " handle_path /apps/" $3 "/* {"
|
|
print " reverse_proxy " $3 ":8000"
|
|
print " }"
|
|
print ""
|
|
}
|
|
' "$CATALOG_FILE" >> "$CADDY_FILE"
|
|
|
|
cat >> "$CADDY_FILE" <<'EOF_CADDY'
|
|
handle_path /webhook/* {
|
|
reverse_proxy appfactory-webhook:9000
|
|
}
|
|
|
|
handle_path /registry/* {
|
|
reverse_proxy registry:5000
|
|
}
|
|
|
|
handle {
|
|
respond "AppFactory gateway is running" 200
|
|
}
|
|
}
|
|
EOF_CADDY
|
|
|
|
docker exec appfactory-caddy caddy reload --config /etc/caddy/Caddyfile
|