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