Skip to content

Commit d44ebd8

Browse files
fix(deploy): explicitly create redis service and app_network in swarm deployment script
1 parent 610094b commit d44ebd8

1 file changed

Lines changed: 24 additions & 2 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,33 @@ jobs:
6565
# 登入 GHCR
6666
echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
6767
68-
# 使用明確 SHA tag 更新服務 (避免 latest 不觸發更新的問題)
68+
# 確保 overlay 網路存在
69+
docker network create -d overlay app_network || true
70+
71+
# 使用明確 SHA tag 更新應用程式服務 (避免 latest 不觸發更新的問題)
6972
docker service update \
7073
--with-registry-auth \
7174
--image ghcr.io/${{ github.repository }}:sha-${{ github.sha }} \
72-
school_grades_app
75+
--network-add app_network \
76+
school_grades_app || \
77+
docker service create \
78+
--with-registry-auth \
79+
--name school_grades_app \
80+
--network app_network \
81+
ghcr.io/${{ github.repository }}:sha-${{ github.sha }}
82+
83+
# 確保 Redis 服務啟動並加入網路
84+
docker service update \
85+
--image redis:7-alpine \
86+
--network-add app_network \
87+
redis || \
88+
docker service create \
89+
--name redis \
90+
--network app_network \
91+
redis:7-alpine
92+
93+
# 確保 Tunnel 也加入此網路 (如果您原本有啟動 tunnel)
94+
docker service update --network-add app_network school_grades_tunnel || true
7395
7496
# 等待更新完成並檢查狀態
7597
docker service ps school_grades_app --no-trunc --format "{{.CurrentState}}" | head -1

0 commit comments

Comments
 (0)