diff --git a/.gitea/workflows/deploy-dev.yml b/.gitea/workflows/deploy-dev.yml index be5e090..f31c1b5 100644 --- a/.gitea/workflows/deploy-dev.yml +++ b/.gitea/workflows/deploy-dev.yml @@ -180,7 +180,6 @@ jobs: prewarm_base_image() { image_ref="$1" - # Skip if image already exists locally if docker image inspect "${image_ref}" >/dev/null 2>&1; then echo "Image ${image_ref} already exists locally, skipping pre-pull" return 0 @@ -203,11 +202,6 @@ jobs: run: | set -e export DOCKER_API_VERSION=1.43 - # DOCKER_BUILDKIT=0 is required for Synology ContainerManager's Docker daemon, - # which does not support BuildKit syntax. Remove when Synology updates to a - # Docker Engine version with full BuildKit support (currently 24.x, needs 23+). - # --cache-to type=inline is a no-op while BuildKit is disabled; it activates - # automatically when DOCKER_BUILDKIT=0 is removed. if ! DOCKER_BUILDKIT=0 docker build --cache-from nas-dashboard-dev:latest -t nas-dashboard-dev:latest dashboard/; then echo "Build failed. Checking for network issues..." curl -I https://registry.npmmirror.com || echo "npmmirror unreachable" @@ -237,42 +231,36 @@ jobs: # Docker 24 compose fails when it can't connect external networks # during container creation. Try compose first; if the container - # isn't created, strip networks from the resolved config via - # docker compose config output (processed with Python json). + # isn't created, strip networks from compose file and retry. docker compose -f docker-compose.dev.yml -p nas-dashboard-dev up -d --pull never 2>&1 || true - if ! docker inspect nas-dashboard-dev >/dev/null 2>&1; then - echo "Compose failed to create container, stripping networks from config..." - docker compose -f docker-compose.dev.yml config --format json 2>/dev/null | python3 -c " -import json, sys -cfg = json.load(sys.stdin) -cfg['services']['dashboard-dev']['networks'] = {} -cfg['networks'] = {} -with open('/tmp/no-network.yml', 'w') as f: - for k, v in cfg.items(): - if k == 'services': - f.write('services:\n') - for svc, svc_cfg in v.items(): - f.write(f' {svc}:\n') - for sk, sv in svc_cfg.items(): - if sk == 'networks': - continue - elif isinstance(sv, dict): - f.write(f' {sk}:\n') - for dk, dv in sv.items(): - f.write(f' {dk}: {json.dumps(dv) if not isinstance(dv, str) else dv}\n') - elif isinstance(sv, list): - f.write(f' {sk}:\n') - for e in sv: - f.write(f' {json.dumps(e) if not isinstance(e, str) else e}\n') - else: - f.write(f' {sk}: {json.dumps(sv) if not isinstance(sv, str) else sv}\n') - elif k == 'networks': - continue - else: - f.write(f'{k}: {json.dumps(v) if not isinstance(v, str) else v}\n') -" - docker compose -f /tmp/no-network.yml -p nas-dashboard-dev up -d --pull never + if ! docker container inspect nas-dashboard-dev >/dev/null 2>&1; then + echo "Compose failed to create container, stripping networks from compose file..." + python3 -c " + import os + lines = open('docker-compose.dev.yml').readlines() + out = [] + skip_net = False + for l in lines: + stripped = l.strip() + if stripped == 'networks:' and not l[0].isspace(): + skip_net = True + continue + if skip_net: + if l[0].isspace(): + continue + skip_net = False + if stripped == 'networks:' and l[:4].strip() == '': + skip_net = True + continue + if skip_net: + if l.startswith(' '): + continue + skip_net = False + out.append(l) + open('/tmp/ci.yml','w').writelines(out) + " + docker compose -f /tmp/ci.yml -p nas-dashboard-dev up -d --pull never fi # Connect networks after container is created (idempotent) @@ -295,7 +283,6 @@ with open('/tmp/no-network.yml', 'w') as f: echo "Waiting... ($i/30) Status: $STATUS" sleep 2 done - # Final check STATUS=$(docker inspect --format='{{.State.Health.Status}}' nas-dashboard-dev 2>/dev/null || echo "unknown") if [ "$STATUS" != "healthy" ]; then echo "❌ Container failed to become healthy: $STATUS"