fix: make deploy step resilient to transient Docker network failures
- Remove set -e from deploy step, handle errors explicitly - Allow docker compose up to succeed even if network connect transiently fails - Verify container exists and connect networks manually after compose - Add network connection verification step Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -214,7 +214,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Deploy dev
|
- name: Deploy dev
|
||||||
run: |
|
run: |
|
||||||
set -euo pipefail
|
set -u
|
||||||
export DOCKER_API_VERSION=1.43
|
export DOCKER_API_VERSION=1.43
|
||||||
|
|
||||||
cd /volume1/docker/nas-dashboard
|
cd /volume1/docker/nas-dashboard
|
||||||
@@ -228,11 +228,32 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Deploy with compose (without --build since we already built the image)
|
# Deploy with compose (without --build since we already built the image)
|
||||||
docker compose -f docker-compose.dev.yml -p nas-dashboard-dev up -d --pull never
|
# Network connection during compose can transiently fail on Docker 24;
|
||||||
|
# we catch it and connect networks manually below.
|
||||||
|
docker compose -f docker-compose.dev.yml -p nas-dashboard-dev up -d --pull never || true
|
||||||
|
|
||||||
# Manually connect to networks after container is created
|
# Verify the container exists before proceeding
|
||||||
docker network connect nas-dashboard_internal nas-dashboard-dev || true
|
if ! docker inspect nas-dashboard-dev >/dev/null 2>&1; then
|
||||||
docker network connect gitea_gitea nas-dashboard-dev || true
|
echo "❌ Container was not created by compose"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Manually connect to networks (idempotent, handles compose failure)
|
||||||
|
docker network connect nas-dashboard_internal nas-dashboard-dev 2>/dev/null || true
|
||||||
|
docker network connect gitea_gitea nas-dashboard-dev 2>/dev/null || true
|
||||||
|
|
||||||
|
# Verify both connections
|
||||||
|
echo "=== Network connections ==="
|
||||||
|
docker inspect nas-dashboard-dev --format '{{json .NetworkSettings.Networks}}' | python3 -c "
|
||||||
|
import json,sys
|
||||||
|
nets = json.load(sys.stdin)
|
||||||
|
for n in nets:
|
||||||
|
print(f' ✅ Connected to {n}')
|
||||||
|
if 'nas-dashboard_internal' not in nets or 'gitea_gitea' not in nets:
|
||||||
|
print('❌ Not connected to required networks')
|
||||||
|
sys.exit(1)
|
||||||
|
print('✅ All network connections established')
|
||||||
|
"
|
||||||
|
|
||||||
- name: Wait for container to be healthy
|
- name: Wait for container to be healthy
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
Reference in New Issue
Block a user