[FEAT] 調整生產環境部署流程的容器健康檢查等待邏輯與清理策略
1. 修改 .gitea/workflows/deploy-prod.yaml 的 Step 1,將 docker-compose --wait 改為手動 shell 迴圈,動態輪詢 star-cloud-mysql、star-cloud-redis、star-cloud-emqx 的健康狀態,並在超時 (120秒) 時輸出日誌以提升部署強固性。 2. 調整 Step 5 - Cleanup,將 docker image prune -f 限制為只清理超過一週 (168h) 的過期映像檔,以保留 Docker 建置快取。
This commit is contained in:
parent
1864df0fc2
commit
6a251df81b
@ -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"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user