From c44bc1b4b4a6bcbfb6227f4657496d12bd490914 Mon Sep 17 00:00:00 2001 From: happybell80 Date: Mon, 7 Jul 2025 23:50:39 +0900 Subject: [PATCH] Fix Docker Compose cache issue with proper cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Use docker-compose down to clear old service definitions - Use docker system prune -f to remove cached metadata - Verify new compose file is deployed correctly - Force rebuild with --build flag - This ensures new nginx-only config is used instead of cached old stack 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .github/workflows/deploy.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 22be12c..54072f8 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -56,32 +56,33 @@ jobs: ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} \ "ls -la /var/run/docker.sock && id" - - name: Clean up old containers + - name: Deploy with fresh Docker Compose run: | ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF' cd /volume1/homes/admin/nginx-infra - # Stop and remove old containers + # 1) Tear down everything so old services & networks go away if ! docker ps > /dev/null 2>&1; then echo "Using sudo for docker commands..." - sudo docker-compose down --remove-orphans 2>/dev/null || true + sudo docker-compose down 2>/dev/null || true + # 2) Prune out any stopped containers, unused networks, images, and build cache + sudo docker system prune -f else echo "Direct docker access available..." - docker-compose down --remove-orphans 2>/dev/null || true + docker-compose down 2>/dev/null || true + # 2) Prune out any stopped containers, unused networks, images, and build cache + docker system prune -f fi - EOF - - - name: Remote docker-compose up - run: | - ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF' - cd /volume1/homes/admin/nginx-infra - # Start new containers + # 3) Double-check you're seeing the new compose file + echo "---- current compose file ----" + cat docker-compose.yml + echo "------------------------------" + + # 4) Rebuild from that file and bring up only your nginx service if ! docker ps > /dev/null 2>&1; then - echo "Using sudo for docker commands..." sudo docker-compose up -d --build else - echo "Direct docker access available..." docker-compose up -d --build fi EOF \ No newline at end of file