Skip to content

Instantly share code, notes, and snippets.

@remorses
Last active February 12, 2019 14:34
Show Gist options
  • Save remorses/0275e81a4fa33bc851116460a8cb1ef0 to your computer and use it in GitHub Desktop.
Save remorses/0275e81a4fa33bc851116460a8cb1ef0 to your computer and use it in GitHub Desktop.
Docker deploy with version tag
set -ex
##################################################
REGISTRY="myregistry.com:5000" # for docker hub just put your username
IMAGE=`basename $PWD` # image name
##################################################
test -f ./VERSION || echo "file VERSION containing current version is needed" && exit 1
test -f ./build.sh || echo "file build.sh containing build script is needed" && exit 1
git pull
# bump version
docker run --rm -v "$PWD":/app treeder/bump patch
version=`cat VERSION`
echo "version: $version"
# run build
./build.sh
# tag it
git add -A
git commit -m "version $version"
git tag -a "$version" -m "version $version"
git push
git push --tags
docker tag $REGISTRY/$IMAGE:latest $REGISTRY/$IMAGE:$version
# push it
docker push $REGISTRY/$IMAGE:latest
docker push $REGISTRY/$IMAGE:$version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment