Fix broken Caddyfile generation
This commit is contained in:
@@ -7,7 +7,9 @@ source "$CONFIG_FILE"
|
||||
CATALOG_FILE="$APPFACTORY_DIR/apps/catalog.yml"
|
||||
CADDY_FILE="$APPFACTORY_DIR/gateway/Caddyfile"
|
||||
|
||||
cat > "$CADDY_FILE" <<'EOF_CADDY'
|
||||
mkdir -p "$(dirname "$CADDY_FILE")"
|
||||
|
||||
cat > "$CADDY_FILE" <<EOF_CADDY
|
||||
:80 {
|
||||
handle /health {
|
||||
respond "AppFactory OK" 200
|
||||
@@ -26,22 +28,26 @@ cat > "$CADDY_FILE" <<'EOF_CADDY'
|
||||
|
||||
EOF_CADDY
|
||||
|
||||
awk '
|
||||
if [ -f "$CATALOG_FILE" ]; then
|
||||
awk '
|
||||
/^[[:space:]]*-[[:space:]]id:/ {
|
||||
print " handle_path /apps/" $3 "/* {"
|
||||
print " reverse_proxy " $3 ":8000"
|
||||
app=$3
|
||||
|
||||
print " handle_path /apps/" app "/* {"
|
||||
print " reverse_proxy " app ":8000"
|
||||
print " }"
|
||||
print ""
|
||||
}
|
||||
' "$CATALOG_FILE" >> "$CADDY_FILE"
|
||||
' "$CATALOG_FILE" >> "$CADDY_FILE"
|
||||
fi
|
||||
|
||||
cat >> "$CADDY_FILE" <<'EOF_CADDY'
|
||||
cat >> "$CADDY_FILE" <<EOF_CADDY
|
||||
handle_path /webhook/* {
|
||||
reverse_proxy appfactory-webhook:9000
|
||||
}
|
||||
|
||||
handle_path /registry/* {
|
||||
reverse_proxy registry:5000
|
||||
reverse_proxy appfactory-registry:5000
|
||||
}
|
||||
|
||||
handle {
|
||||
@@ -50,11 +56,8 @@ cat >> "$CADDY_FILE" <<'EOF_CADDY'
|
||||
}
|
||||
EOF_CADDY
|
||||
|
||||
echo "Generated: $CADDY_FILE"
|
||||
|
||||
docker exec appfactory-caddy caddy validate --config /etc/caddy/Caddyfile
|
||||
|
||||
if docker ps --format '{{.Names}}' | grep -q '^appfactory-caddy$'; then
|
||||
docker exec appfactory-caddy caddy reload --config /etc/caddy/Caddyfile || docker restart appfactory-caddy
|
||||
else
|
||||
cd "$APPFACTORY_DIR/deploy"
|
||||
docker compose -f docker-compose.yml up -d caddy
|
||||
fi
|
||||
docker exec appfactory-caddy caddy reload --config /etc/caddy/Caddyfile
|
||||
|
||||
Reference in New Issue
Block a user