fix: add retry logic for docker compose pull transient errors
GitHub Container Registry pulls occasionally fail with 'connection reset by peer'. Adding a 3-attempt retry loop with 5s backoff between pulls to handle transient network errors gracefully. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
655380dd8d
commit
c371317755
@@ -6,6 +6,11 @@ on:
|
|||||||
- master
|
- master
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
|
# Prevent concurrent deployments from racing
|
||||||
|
concurrency:
|
||||||
|
group: deploy-vps-${{ github.ref }}
|
||||||
|
cancel-in-progress: false
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
@@ -20,6 +25,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
max-parallel: 2
|
||||||
matrix:
|
matrix:
|
||||||
service: [frontend, backend, discord-gateway, proxy]
|
service: [frontend, backend, discord-gateway, proxy]
|
||||||
steps:
|
steps:
|
||||||
@@ -47,8 +53,8 @@ jobs:
|
|||||||
tags: |
|
tags: |
|
||||||
${{ env.REGISTRY }}/${{ env.OWNER }}/bete-${{ matrix.service }}:latest
|
${{ env.REGISTRY }}/${{ env.OWNER }}/bete-${{ matrix.service }}:latest
|
||||||
${{ env.REGISTRY }}/${{ env.OWNER }}/bete-${{ matrix.service }}:${{ github.sha }}
|
${{ env.REGISTRY }}/${{ env.OWNER }}/bete-${{ matrix.service }}:${{ github.sha }}
|
||||||
cache-from: type=gha
|
cache-from: type=gha,scope=bete-${{ matrix.service }}
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max,scope=bete-${{ matrix.service }}
|
||||||
build-args: |
|
build-args: |
|
||||||
VITE_BE_API_URL=https://imphnen.asepharyana.my.id
|
VITE_BE_API_URL=https://imphnen.asepharyana.my.id
|
||||||
VITE_BE_WS_URL=wss://imphnen.asepharyana.my.id
|
VITE_BE_WS_URL=wss://imphnen.asepharyana.my.id
|
||||||
@@ -96,13 +102,32 @@ jobs:
|
|||||||
mkdir -p infra/docker/recordings
|
mkdir -p infra/docker/recordings
|
||||||
# Set permissions for recordings directory (writable by container app user UID 100)
|
# Set permissions for recordings directory (writable by container app user UID 100)
|
||||||
chmod -R 777 infra/docker/recordings
|
chmod -R 777 infra/docker/recordings
|
||||||
printf '%s\n' "$ENV_FILE" > infra/docker/.env
|
|
||||||
|
# Write env file — strip \r to avoid configuration issues
|
||||||
|
printf '%s\n' "$ENV_FILE" | tr -d '\r' > infra/docker/.env
|
||||||
|
|
||||||
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin
|
echo "$GHCR_TOKEN" | docker login ghcr.io -u "$GHCR_USERNAME" --password-stdin
|
||||||
|
|
||||||
# Force stop any stale containers from previous deployments
|
# Force stop any stale containers from previous deployments
|
||||||
docker rm -f imphenbot-proxy imphenbot-backend imphenbot-frontend imphenbot-discord-gateway 2>/dev/null || true
|
docker rm -f imphenbot-proxy imphenbot-backend imphenbot-frontend imphenbot-discord-gateway 2>/dev/null || true
|
||||||
|
|
||||||
docker compose -f infra/docker/docker-compose.yml pull
|
# Retry docker pull up to 3 times on transient network errors
|
||||||
docker compose -f infra/docker/docker-compose.yml up -d --remove-orphans
|
RETRIES=3
|
||||||
|
for i in $(seq 1 $RETRIES); do
|
||||||
|
echo "docker compose pull (attempt $i/$RETRIES)"
|
||||||
|
if docker compose -f infra/docker/docker-compose.yml pull; then
|
||||||
|
echo "Pull succeeded"
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Pull failed (attempt $i/$RETRIES)"
|
||||||
|
if [ "$i" -eq "$RETRIES" ]; then
|
||||||
|
echo "All pull attempts failed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
sleep 5
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# --wait waits for containers to become healthy before returning
|
||||||
|
docker compose -f infra/docker/docker-compose.yml up -d --remove-orphans --wait --wait-timeout 90
|
||||||
docker image prune -f
|
docker image prune -f
|
||||||
|
|||||||
Reference in New Issue
Block a user