Add container cleanup step before deployment
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
f95115b275
commit
f5253ac3e5
17
.github/workflows/deploy.yml
vendored
17
.github/workflows/deploy.yml
vendored
@ -56,12 +56,27 @@ 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
|
||||||
|
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
|
- name: Remote docker-compose up
|
||||||
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
|
||||||
|
|
||||||
# Try with sudo if direct access fails
|
# Start new containers
|
||||||
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 up -d --build
|
sudo docker-compose up -d --build
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user