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