Fix Docker Compose cache issue with proper cleanup
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
f5253ac3e5
commit
c44bc1b4b4
25
.github/workflows/deploy.yml
vendored
25
.github/workflows/deploy.yml
vendored
@ -56,32 +56,33 @@ jobs:
|
|||||||
ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} \
|
ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} \
|
||||||
"ls -la /var/run/docker.sock && id"
|
"ls -la /var/run/docker.sock && id"
|
||||||
|
|
||||||
- name: Clean up old containers
|
- name: Deploy with fresh Docker Compose
|
||||||
run: |
|
run: |
|
||||||
ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF'
|
ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF'
|
||||||
cd /volume1/homes/admin/nginx-infra
|
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
|
if ! docker ps > /dev/null 2>&1; then
|
||||||
echo "Using sudo for docker commands..."
|
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
|
else
|
||||||
echo "Direct docker access available..."
|
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
|
fi
|
||||||
EOF
|
|
||||||
|
|
||||||
- name: Remote docker-compose up
|
# 3) Double-check you're seeing the new compose file
|
||||||
run: |
|
echo "---- current compose file ----"
|
||||||
ssh -p ${{ secrets.NAS_PORT }} admin@${{ secrets.NAS_HOST }} << 'EOF'
|
cat docker-compose.yml
|
||||||
cd /volume1/homes/admin/nginx-infra
|
echo "------------------------------"
|
||||||
|
|
||||||
# Start new containers
|
# 4) Rebuild from that file and bring up only your nginx service
|
||||||
if ! docker ps > /dev/null 2>&1; then
|
if ! docker ps > /dev/null 2>&1; then
|
||||||
echo "Using sudo for docker commands..."
|
|
||||||
sudo docker-compose up -d --build
|
sudo docker-compose up -d --build
|
||||||
else
|
else
|
||||||
echo "Direct docker access available..."
|
|
||||||
docker-compose up -d --build
|
docker-compose up -d --build
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
Loading…
x
Reference in New Issue
Block a user