perf: optimize deploy-dev workflow
Deploy Dashboard (Dev) / deploy-dev (push) Successful in 1m54s
Run Tests / Frontend Tests (push) Has been cancelled
Run Tests / Test Summary (push) Has been cancelled
Run Tests / Backend Tests (push) Has been cancelled

- Skip base image pre-pull if images already exist locally
- Reduce timeout from 60s to 30s for mirror pulls
- Remove redundant --build flag (image already built)
- Remove unnecessary cleanup steps (docker rm -f, network disconnect)
- Simplify to just docker compose down before up
This commit is contained in:
Gan, Jimmy
2026-04-06 22:07:53 +08:00
parent a86f11a3db
commit c17bcd8444
+12 -21
View File
@@ -24,25 +24,21 @@ jobs:
set -u set -u
mirror_host="127.0.0.1:5501" mirror_host="127.0.0.1:5501"
if command -v curl >/dev/null 2>&1; then
if curl -fsS "http://${mirror_host}/v2/" >/dev/null; then
echo "Registry mirror is healthy at ${mirror_host}"
else
echo "Warning: registry mirror health check failed at ${mirror_host}; continuing with normal pull path"
fi
else
echo "Warning: curl is unavailable; skipping explicit mirror health check"
fi
prewarm_base_image() { prewarm_base_image() {
image_ref="$1" 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
fi
mirror_ref="${mirror_host}/library/${image_ref}" mirror_ref="${mirror_host}/library/${image_ref}"
echo "Attempting mirror pre-pull: ${mirror_ref}" echo "Attempting mirror pre-pull: ${mirror_ref}"
if timeout 60 docker pull "${mirror_ref}"; then if timeout 30 docker pull "${mirror_ref}" 2>/dev/null; then
docker tag "${mirror_ref}" "${image_ref}" docker tag "${mirror_ref}" "${image_ref}"
echo "Mirror pre-pull succeeded for ${image_ref}" echo "Mirror pre-pull succeeded for ${image_ref}"
else else
echo "Warning: mirror pre-pull failed for ${image_ref}; continuing with normal pull during build" echo "Mirror pre-pull failed for ${image_ref}, will pull during build"
fi fi
} }
@@ -64,21 +60,16 @@ jobs:
cd /volume1/docker/nas-dashboard cd /volume1/docker/nas-dashboard
# Stop and remove any existing container # Stop existing container if running
docker compose -f docker-compose.dev.yml -p nas-dashboard-dev down --remove-orphans || true docker compose -f docker-compose.dev.yml -p nas-dashboard-dev down || true
docker rm -f nas-dashboard-dev 2>/dev/null || true
# Disconnect from networks if still connected
docker network disconnect nas-dashboard_internal nas-dashboard-dev 2>/dev/null || true
docker network disconnect gitea_gitea nas-dashboard-dev 2>/dev/null || true
# Ensure network exists (create only if it doesn't exist) # Ensure network exists (create only if it doesn't exist)
if ! docker network inspect nas-dashboard_internal >/dev/null 2>&1; then if ! docker network inspect nas-dashboard_internal >/dev/null 2>&1; then
docker network create nas-dashboard_internal docker network create nas-dashboard_internal
fi fi
# Deploy with compose (without networks in compose file) # Deploy with compose (without --build since we already built the image)
docker compose -f docker-compose.dev.yml -p nas-dashboard-dev up -d --build --pull never docker compose -f docker-compose.dev.yml -p nas-dashboard-dev up -d --pull never
# Manually connect to networks after container is created # Manually connect to networks after container is created
docker network connect nas-dashboard_internal nas-dashboard-dev || true docker network connect nas-dashboard_internal nas-dashboard-dev || true