This commit is contained in:
@@ -36,14 +36,20 @@ jobs:
|
|||||||
# --- Build image ---
|
# --- Build image ---
|
||||||
- name: Build image
|
- name: Build image
|
||||||
run: |
|
run: |
|
||||||
|
echo "Starting Docker build..."
|
||||||
docker build \
|
docker build \
|
||||||
--pull \
|
--pull \
|
||||||
-t registry.infra.mintel.me/mintel/mb-grid-solutions.com:latest .
|
-t registry.infra.mintel.me/mintel/mb-grid-solutions:latest .
|
||||||
|
echo "Docker build completed successfully"
|
||||||
|
echo "Built image:"
|
||||||
|
docker images registry.infra.mintel.me/mintel/mb-grid-solutions:latest --format "table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}"
|
||||||
|
|
||||||
# --- Push image ---
|
# --- Push image ---
|
||||||
- name: Push image
|
- name: Push image
|
||||||
run: |
|
run: |
|
||||||
docker push registry.infra.mintel.me/mintel/mb-grid-solutions.com:latest
|
echo "Starting Docker push..."
|
||||||
|
docker push registry.infra.mintel.me/mintel/mb-grid-solutions:latest
|
||||||
|
echo "Docker push completed successfully"
|
||||||
|
|
||||||
# --- SSH setup ---
|
# --- SSH setup ---
|
||||||
- name: Setup SSH
|
- name: Setup SSH
|
||||||
@@ -56,10 +62,13 @@ jobs:
|
|||||||
# --- Sync files ---
|
# --- Sync files ---
|
||||||
- name: Sync files to server
|
- name: Sync files to server
|
||||||
run: |
|
run: |
|
||||||
|
echo "Starting file sync to server..."
|
||||||
|
echo "Syncing docker-compose.yaml to alpha.mintel.me..."
|
||||||
# Use tar to bundle files and send them via SSH in a single connection
|
# 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/"
|
"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/"
|
||||||
|
echo "File sync completed"
|
||||||
|
|
||||||
# --- Deploy ---
|
# --- Deploy ---
|
||||||
- name: Deploy on server
|
- name: Deploy on server
|
||||||
@@ -67,24 +76,58 @@ jobs:
|
|||||||
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
REGISTRY_USER: ${{ secrets.REGISTRY_USER }}
|
||||||
REGISTRY_PASS: ${{ secrets.REGISTRY_PASS }}
|
REGISTRY_PASS: ${{ secrets.REGISTRY_PASS }}
|
||||||
run: |
|
run: |
|
||||||
|
echo "Starting deployment on server..."
|
||||||
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 "
|
||||||
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'
|
||||||
|
|
||||||
cd /home/deploy/sites/mb-grid-solutions.com
|
cd /home/deploy/sites/mb-grid-solutions.com
|
||||||
|
|
||||||
echo 'Pulling latest image...'
|
echo ''
|
||||||
docker compose pull app || echo 'Pull failed - continuing anyway...'
|
echo '=== Checking current container status ==='
|
||||||
|
docker compose ps app || echo 'No running containers found'
|
||||||
|
|
||||||
echo 'Force recreating and restarting app container...'
|
echo ''
|
||||||
docker compose up -d --force-recreate --no-deps app
|
echo '=== Checking current 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'
|
||||||
|
|
||||||
echo 'Pruning old images (keep last 24h)...'
|
echo ''
|
||||||
|
echo '=== Pulling latest image ==='
|
||||||
|
docker compose pull app
|
||||||
|
echo 'Image pull completed'
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo '=== Checking pulled image ==='
|
||||||
|
docker images registry.infra.mintel.me/mintel/mb-grid-solutions:latest --format 'table {{.Repository}}:{{.Tag}}\t{{.ID}}\t{{.CreatedSince}}'
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo '=== Force recreating and restarting app container ==='
|
||||||
|
docker compose up -d --force-recreate app
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo '=== Waiting for container to be healthy (10 seconds) ==='
|
||||||
|
sleep 10
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo '=== Checking container status after deployment ==='
|
||||||
|
docker compose ps app
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo '=== Checking container logs (last 30 lines) ==='
|
||||||
|
docker compose logs --tail=30 app
|
||||||
|
|
||||||
|
echo ''
|
||||||
|
echo '=== Pruning old images (keep last 24h) ==='
|
||||||
docker image prune -f --filter 'until=24h'
|
docker image prune -f --filter 'until=24h'
|
||||||
|
|
||||||
echo 'Deployment finished. Checking status...'
|
echo ''
|
||||||
|
echo '=== Final status check ==='
|
||||||
docker compose ps app
|
docker compose ps app
|
||||||
docker compose logs --tail=20 app
|
|
||||||
"
|
echo ''
|
||||||
|
echo '=== Deployment completed successfully ==='
|
||||||
|
"
|
||||||
|
echo "Deployment process finished"
|
||||||
@@ -15,8 +15,6 @@ services:
|
|||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 2s
|
timeout: 2s
|
||||||
retries: 10
|
retries: 10
|
||||||
deploy:
|
|
||||||
replicas: 2
|
|
||||||
networks:
|
networks:
|
||||||
- infra
|
- infra
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user