Skip to content

Instantly share code, notes, and snippets.

@markshust
Created January 31, 2025 21:29
Show Gist options
  • Save markshust/ecd23b11276fdb0930d617d390d3c6ad to your computer and use it in GitHub Desktop.
Save markshust/ecd23b11276fdb0930d617d390d3c6ad to your computer and use it in GitHub Desktop.
bash function to build & push multi-architecture docker images upstream
dbx() {
echo "Enter the tag (e.g., markoshust/magento-php:8.4-fpm-0):"
read -r tag
if [ -z "$tag" ]; then
echo "Error: Tag cannot be empty"
return 1
fi
echo "You entered: $tag"
echo "Is this correct? (y/n)"
read -r confirm
if [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]]; then
echo "Starting build process..."
if ! docker build --platform linux/amd64,linux/arm64 --tag "$tag" .; then
echo "Error: Docker build failed"
return 1
fi
echo "Build completed successfully!"
echo "Do you want to push upstream? (y/n)"
read -r push_confirm
if [[ $push_confirm == [yY] || $push_confirm == [yY][eE][sS] ]]; then
echo "Starting push process..."
if ! docker build --push --platform linux/amd64,linux/arm64 --tag "$tag" .; then
echo "Error: Docker push failed"
return 1
fi
echo "Push completed successfully!"
else
echo "Skipping push to upstream."
fi
else
echo "Operation cancelled."
return 0
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment