refactor: Improve deployment workflow with retry logic for image pushes and optimized build process #14
@ -51,24 +51,27 @@ jobs:
|
||||
echo "Using ACTOR: $ACTOR"
|
||||
echo "Using REPO_NAME: $REPO_NAME"
|
||||
|
||||
# Build with compression
|
||||
docker build --compress -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest ./be -f ./be/Dockerfile.prod
|
||||
# Build with compression and smaller layers
|
||||
docker build --compress --no-cache -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest ./be -f ./be/Dockerfile.prod
|
||||
|
||||
# Save image to tar file
|
||||
docker save git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest > backend.tar
|
||||
|
||||
# Split the tar file into smaller chunks (100MB each)
|
||||
split -b 100M backend.tar backend.tar.part_
|
||||
|
||||
# Push each chunk
|
||||
for chunk in backend.tar.part_*; do
|
||||
docker load < "$chunk"
|
||||
docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest
|
||||
sleep 5 # Add delay between pushes
|
||||
# Push with retries
|
||||
max_retries=3
|
||||
retry_count=0
|
||||
while [ $retry_count -lt $max_retries ]; do
|
||||
if docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-backend:latest; then
|
||||
break
|
||||
fi
|
||||
retry_count=$((retry_count + 1))
|
||||
if [ $retry_count -lt $max_retries ]; then
|
||||
echo "Push failed, retrying in 10 seconds... (Attempt $retry_count of $max_retries)"
|
||||
sleep 10
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
rm backend.tar backend.tar.part_*
|
||||
if [ $retry_count -eq $max_retries ]; then
|
||||
echo "Failed to push after $max_retries attempts"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
- name: Build and push frontend image
|
||||
env:
|
||||
@ -93,21 +96,24 @@ jobs:
|
||||
echo "Using ACTOR: $ACTOR"
|
||||
echo "Using REPO_NAME: $REPO_NAME"
|
||||
|
||||
# Build with compression
|
||||
docker build --compress -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest ./fe -f ./fe/Dockerfile.prod
|
||||
# Build with compression and smaller layers
|
||||
docker build --compress --no-cache -t git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest ./fe -f ./fe/Dockerfile.prod
|
||||
|
||||
# Save image to tar file
|
||||
docker save git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest > frontend.tar
|
||||
|
||||
# Split the tar file into smaller chunks (100MB each)
|
||||
split -b 100M frontend.tar frontend.tar.part_
|
||||
|
||||
# Push each chunk
|
||||
for chunk in frontend.tar.part_*; do
|
||||
docker load < "$chunk"
|
||||
docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest
|
||||
sleep 5 # Add delay between pushes
|
||||
# Push with retries
|
||||
max_retries=3
|
||||
retry_count=0
|
||||
while [ $retry_count -lt $max_retries ]; do
|
||||
if docker push git.vinylnostalgia.com/$ACTOR/$REPO_NAME-frontend:latest; then
|
||||
break
|
||||
fi
|
||||
retry_count=$((retry_count + 1))
|
||||
if [ $retry_count -lt $max_retries ]; then
|
||||
echo "Push failed, retrying in 10 seconds... (Attempt $retry_count of $max_retries)"
|
||||
sleep 10
|
||||
fi
|
||||
done
|
||||
|
||||
# Cleanup
|
||||
rm frontend.tar frontend.tar.part_*
|
||||
if [ $retry_count -eq $max_retries ]; then
|
||||
echo "Failed to push after $max_retries attempts"
|
||||
exit 1
|
||||
fi
|
Loading…
Reference in New Issue
Block a user