feat: enhance network configuration handling in updater script
Docker images / backend-image (push) Successful in 39s
Docker images / frontend-image (push) Successful in 40s
Docker images / updater-image (push) Successful in 45s
Docker images / notify-webhook (push) Has been skipped

- Improved network mode handling by introducing a variable for network names, allowing for better management of custom networks.
- Added support for network aliases, enabling the specification of multiple aliases for a given network in the snapshot.
- Enhanced health check logging to include the last HTTP status received, providing better visibility into health check failures.
This commit is contained in:
Denozordec
2026-05-12 16:42:00 +07:00
parent 40e2040fb0
commit f282585b52
+19 -6
View File
@@ -248,19 +248,30 @@ build_run_args_from_snapshot() {
' "$snapshot_file")
local network_mode
local network_name=""
network_mode="$(jq -r '.HostConfig.NetworkMode // empty' "$snapshot_file")"
if [[ "$network_mode" == "host" ]]; then
args+=(--network host)
elif [[ -n "$network_mode" && "$network_mode" != "default" && "$network_mode" != "bridge" ]]; then
args+=(--network "$network_mode")
network_name="$network_mode"
args+=(--network "$network_name")
else
local custom_network
custom_network="$(jq -r '.NetworkSettings.Networks // {} | keys[0] // empty' "$snapshot_file")"
if [[ -n "$custom_network" && "$custom_network" != "bridge" ]]; then
args+=(--network "$custom_network")
network_name="$(jq -r '.NetworkSettings.Networks // {} | keys[0] // empty' "$snapshot_file")"
if [[ -n "$network_name" && "$network_name" != "bridge" ]]; then
args+=(--network "$network_name")
fi
fi
if [[ -n "$network_name" ]]; then
while IFS= read -r alias; do
[[ -n "$alias" ]] || continue
args+=(--network-alias "$alias")
done < <(jq -r --arg net "$network_name" '
.NetworkSettings.Networks[$net].Aliases // []
| .[]
' "$snapshot_file")
fi
if [[ "$(jq -r '.HostConfig.Privileged // false' "$snapshot_file")" == "true" ]]; then
args+=(--privileged)
fi
@@ -289,11 +300,13 @@ wait_for_health() {
local health_url="$3"
local expect_status="$4"
local deadline=$((SECONDS + HEALTH_TIMEOUT_SECONDS))
local last_status=""
while (( SECONDS < deadline )); do
if [[ "$health_type" == "http" ]]; then
local status
status="$(curl --silent --output /dev/null --write-out '%{http_code}' --max-time 5 "$health_url" || true)"
last_status="$status"
if [[ "$status" == "$expect_status" ]]; then
log info "target=${target_id} action=health_ok status=${status}"
return 0
@@ -305,7 +318,7 @@ wait_for_health() {
sleep 2
done
log error "target=${target_id} action=health_fail reason=timeout seconds=${HEALTH_TIMEOUT_SECONDS}"
log error "target=${target_id} action=health_fail reason=timeout seconds=${HEALTH_TIMEOUT_SECONDS} url=${health_url} last_status=${last_status:-none}"
return 1
}