From f5253ac3e5b8fab51d6c4c304b9779e471737f3c Mon Sep 17 00:00:00 2001 From: happybell80 Date: Mon, 7 Jul 2025 23:47:39 +0900 Subject: [PATCH] Add container cleanup step before deployment MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Stop and remove old containers with docker-compose down - Prevents conflicts with cached old configurations - Ensures clean deployment of new nginx-only setup 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/deploy.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 1ce1e8b..22be12c 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,12 +56,27 @@ jobs: ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} \ "ls -la /var/run/docker.sock && id" + - name: Clean up old containers + run: | + ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF' + cd /volume1/homes/admin/nginx-infra + + # Stop and remove old containers + if ! docker ps > /dev/null 2>&1; then + echo "Using sudo for docker commands..." + sudo docker-compose down --remove-orphans 2>/dev/null || true + else + echo "Direct docker access available..." + docker-compose down --remove-orphans 2>/dev/null || true + fi + EOF + - name: Remote docker-compose up run: | ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF' cd /volume1/homes/admin/nginx-infra - # Try with sudo if direct access fails + # Start new containers if ! docker ps > /dev/null 2>&1; then echo "Using sudo for docker commands..." sudo docker-compose up -d --build