[PROMOTE] 晉升 demo 至 main

1. [FEAT] 調整部署工作流以保留 Docker 建置快取
2. [FEAT] 調整生產環境部署流程的容器健康檢查等待邏輯與清理策略
This commit is contained in:
sky121113 2026-06-04 08:27:52 +08:00
commit 6fb9c9c7ec
2 changed files with 24 additions and 3 deletions

View File

@ -80,4 +80,4 @@ jobs:
docker restart star-cloud-mqtt-worker
- name: Step 5 - Cleanup
run: docker image prune -f
run: docker image prune -f --filter "until=168h"

View File

@ -33,7 +33,28 @@ jobs:
- name: Step 1 - Build & Deploy Containers
run: |
WWWGROUP=1001 WWWUSER=1001 docker-compose up -d --build --wait
WWWGROUP=1001 WWWUSER=1001 docker-compose up -d --build
for container in star-cloud-mysql star-cloud-redis star-cloud-emqx; do
echo ">>> Waiting for ${container} to become healthy..."
for i in $(seq 1 60); do
status=$(docker inspect -f '{{if .State.Health}}{{.State.Health.Status}}{{else}}{{.State.Status}}{{end}}' "${container}" 2>/dev/null || echo "missing")
if [ "${status}" = "healthy" ]; then
echo ">>> ${container} is healthy."
break
fi
if [ "${i}" -eq 60 ]; then
echo ">>> ${container} did not become healthy. Current status: ${status}"
docker logs --tail 80 "${container}" || true
exit 1
fi
sleep 2
done
done
- name: Step 2 - Deploy Code
run: |
@ -75,4 +96,4 @@ jobs:
echo "✅ MQTT Worker 已重啟"
- name: Step 5 - Cleanup
run: docker image prune -f
run: docker image prune -f --filter "until=168h"