Add optional --autopush parameter to skip the interactive push prompt and automatically push built images to registry. Useful for CI/CD pipelines and automated builds. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
35 lines
840 B
Bash
Executable File
35 lines
840 B
Bash
Executable File
#!/bin/bash
|
|
|
|
if [ "$1" == "" ] ; then
|
|
printf "\nYou did not specify the Docker image version to build"
|
|
printf "\n\nSyntax:\n\n build-image.sh 1.0.0 [--autopush]\n\n"
|
|
exit 1
|
|
fi
|
|
|
|
# Check for --autopush flag
|
|
if [ "$2" == "--autopush" ]; then
|
|
PUSH_IMAGE="y"
|
|
printf "\nAuto-push enabled. Image will be pushed to registry.\n"
|
|
else
|
|
read -p "BUILD: Push new image to registry [y/n]? " -n 1 -r
|
|
echo # (optional) move to a new line
|
|
PUSH_IMAGE="$REPLY"
|
|
fi
|
|
|
|
printf "\nBUILD START ...\n\n"
|
|
|
|
REGISTRY_URL="registry.budakova.org"
|
|
IMAGE_NAME=$(node -p "require('./package.json').name")
|
|
IMAGE_VERSION=$1
|
|
|
|
IMAGE_TAG=$REGISTRY_URL/$IMAGE_NAME:$IMAGE_VERSION
|
|
docker build . -t $IMAGE_TAG
|
|
|
|
if [[ "$PUSH_IMAGE" =~ ^[Yy]$ ]]
|
|
then
|
|
printf "\nPushing image ...\n\n"
|
|
docker push $IMAGE_TAG
|
|
fi
|
|
|
|
printf "\nBUILD DONE!\n\n"
|