Enhance runtime override generation: add app image retrieval and improve port handling

This commit is contained in:
2026-04-28 20:55:58 +02:00
parent 0d7fa2c511
commit 6cc8dabf72
+15 -8
View File
@@ -24,31 +24,38 @@ parse_port_list() {
write_runtime_override() { write_runtime_override() {
local current_ports="" local current_ports=""
local app_image=""
local ports=() local ports=()
local ports_csv=""
if [ -f "$ENV_FILE" ]; then if [ -f "$ENV_FILE" ]; then
app_image="$(awk -F= '/^INVENTAR_APP_IMAGE=/{print $2; exit}' "$ENV_FILE" | tr -d ' ' || true)"
current_ports="$(awk -F= '/^INVENTAR_HTTP_PORTS=/{print $2; exit}' "$ENV_FILE" | tr -d ' ' || true)" current_ports="$(awk -F= '/^INVENTAR_HTTP_PORTS=/{print $2; exit}' "$ENV_FILE" | tr -d ' ' || true)"
if [ -z "$current_ports" ]; then if [ -z "$current_ports" ]; then
current_ports="$(awk -F= '/^INVENTAR_HTTP_PORT=/{print $2; exit}' "$ENV_FILE" | tr -d ' ' || true)" current_ports="$(awk -F= '/^INVENTAR_HTTP_PORT=/{print $2; exit}' "$ENV_FILE" | tr -d ' ' || true)"
fi fi
fi fi
if [ -n "$current_ports" ]; then if [ -n "$app_image" ]; then
mapfile -t ports < <(parse_port_list "$current_ports") if [ -n "$current_ports" ]; then
fi mapfile -t ports < <(parse_port_list "$current_ports")
fi
if [ ${#ports[@]} -gt 1 ]; then
cat > "$RUNTIME_COMPOSE_OVERRIDE_FILE" <<EOF cat > "$RUNTIME_COMPOSE_OVERRIDE_FILE" <<EOF
services: services:
app: app:
image: $app_image
build: null
EOF
if [ ${#ports[@]} -gt 1 ]; then
cat >> "$RUNTIME_COMPOSE_OVERRIDE_FILE" <<EOF
ports: ports:
EOF EOF
for port in "${ports[@]}"; do for port in "${ports[@]}"; do
cat >> "$RUNTIME_COMPOSE_OVERRIDE_FILE" <<EOF cat >> "$RUNTIME_COMPOSE_OVERRIDE_FILE" <<EOF
- "$port:8000" - "$port:8000"
EOF EOF
done done
fi
else else
rm -f "$RUNTIME_COMPOSE_OVERRIDE_FILE" rm -f "$RUNTIME_COMPOSE_OVERRIDE_FILE"
fi fi