deploy
All checks were successful
Build & Deploy / deploy (push) Successful in 30s

This commit is contained in:
2026-01-21 12:54:00 +01:00
parent 8ca85c9530
commit d1c26efea8
2 changed files with 34 additions and 26 deletions

View File

@@ -64,7 +64,6 @@ jobs:
run: | run: |
echo "Starting file sync to server..." echo "Starting file sync to server..."
echo "Syncing docker-compose.yaml to alpha.mintel.me..." echo "Syncing docker-compose.yaml to alpha.mintel.me..."
# Use tar to bundle files and send them via SSH in a single connection
tar czf - docker-compose.yaml | \ tar czf - docker-compose.yaml | \
ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 deploy@alpha.mintel.me \ ssh -i ~/.ssh/id_ed25519 -o StrictHostKeyChecking=no -o IPQoS=0x00 deploy@alpha.mintel.me \
"mkdir -p /home/deploy/sites/mb-grid-solutions.com/ && tar xzf - -C /home/deploy/sites/mb-grid-solutions.com/ && echo 'Files synced successfully' && ls -la /home/deploy/sites/mb-grid-solutions.com/" "mkdir -p /home/deploy/sites/mb-grid-solutions.com/ && tar xzf - -C /home/deploy/sites/mb-grid-solutions.com/ && echo 'Files synced successfully' && ls -la /home/deploy/sites/mb-grid-solutions.com/"
@@ -81,53 +80,60 @@ jobs:
set -e set -e
echo '=== Logging in to registry on server ===' echo '=== Logging in to registry on server ==='
echo '$REGISTRY_PASS' | docker login registry.infra.mintel.me -u '$REGISTRY_USER' --password-stdin echo \"\$REGISTRY_PASS\" | docker login registry.infra.mintel.me -u \"\$REGISTRY_USER\" --password-stdin
echo 'Registry login successful' echo 'Registry login successful'
cd /home/deploy/sites/mb-grid-solutions.com cd /home/deploy/sites/mb-grid-solutions.com || { echo 'Directory not found!'; exit 1; }
echo '' echo ''
echo '=== Checking current container status ===' echo '=== Current status before deploy ==='
docker compose ps app || echo 'No running containers found' docker compose ps -a || true
echo '' echo ''
echo '=== Checking current image ===' echo '=== Current local image ==='
docker images registry.infra.mintel.me/mintel/mb-grid-solutions:latest --format 'table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}' || echo 'No local image found' docker images registry.infra.mintel.me/mintel/mb-grid-solutions:latest --format 'table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}' || echo 'No image found'
echo '' echo ''
echo '=== Pulling latest image ===' echo '=== Pulling latest image (force) ==='
docker compose pull app docker compose pull app || { echo 'Pull failed!'; exit 1; }
echo 'Image pull completed'
echo '' echo ''
echo '=== Checking pulled image ===' echo '=== Stopping and removing old containers ==='
docker images registry.infra.mintel.me/mintel/mb-grid-solutions:latest --format 'table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}' docker compose down app --remove-orphans || true
docker compose rm -f app || true
echo '' echo ''
echo '=== Starting app container with new image (zero-downtime) ===' echo '=== Starting services with force-recreate and no-build ==='
docker compose up -d --pull always --force-recreate --no-build app docker compose up -d --pull always --force-recreate --no-build --no-deps app
echo '' echo ''
echo '=== Waiting for container to be healthy (10 seconds) ===' echo '=== Waiting for containers to become healthy (max 30s) ==='
sleep 10 for i in {1..6}; do
echo \"Attempt \$i/6...\"
if docker compose ps --format '{{.Status}}' | grep -q 'healthy'; then
echo 'All containers healthy!'
break
fi
sleep 5
done
echo '' echo ''
echo '=== Checking container status after deployment ===' echo '=== Final status ==='
docker compose ps app docker compose ps -a
echo '' echo ''
echo '=== Checking container logs (last 30 lines) ===' echo '=== Image now in use ==='
docker compose logs --tail=30 app docker compose ps --format '{{.Name}}\t{{.Image}}\t{{.Status}}'
echo '' echo ''
echo '=== Pruning old images (keep last 24h) ===' echo '=== Last 40 lines of logs ==='
docker image prune -f --filter 'until=24h' docker compose logs --tail=40 app || true
echo '' echo ''
echo '=== Final status check ===' echo '=== Pruning dangling & old images (keep last 24h) ==='
docker compose ps app docker image prune -f --filter 'until=24h' || true
echo '' echo ''
echo '=== Deployment completed successfully ===' echo '=== Deployment completed ==='
" "
echo "Deployment process finished" echo "Deployment process finished"

View File

@@ -15,9 +15,11 @@ services:
interval: 5s interval: 5s
timeout: 2s timeout: 2s
retries: 10 retries: 10
deploy:
replicas: 2
networks: networks:
- infra - infra
networks: networks:
infra: infra:
external: true external: true