diff options
| author | ivarlovlie <git@ivarlovlie.no> | 2022-02-07 23:26:00 +0100 |
|---|---|---|
| committer | ivarlovlie <git@ivarlovlie.no> | 2022-02-07 23:26:00 +0100 |
| commit | 64ed9aac2632d2a473c375a041ce31937404bbbd (patch) | |
| tree | e94e3ec1c62f32327ed53a00d02689e8fd218097 /build_and_push.sh | |
| parent | 799b4503cfe2cbbf94d683781fda46b524ed70f6 (diff) | |
| download | bookmark-thing-64ed9aac2632d2a473c375a041ce31937404bbbd.tar.xz bookmark-thing-64ed9aac2632d2a473c375a041ce31937404bbbd.zip | |
build: Add docker image builder script
Diffstat (limited to 'build_and_push.sh')
| -rwxr-xr-x | build_and_push.sh | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/build_and_push.sh b/build_and_push.sh new file mode 100755 index 0000000..c55cf35 --- /dev/null +++ b/build_and_push.sh @@ -0,0 +1,35 @@ +#!/usr/bin/env bash +set -Eeuo pipefail + +do_push() { + IMAGE_NAME="bmt-server" + HUB_NAME="dr.ivarlovlie.no/bmt/server" + COMMIT_HASH=$(git rev-parse --short HEAD) + + pushd src/server + + docker build -t $IMAGE_NAME . + + popd + + docker tag $IMAGE_NAME $HUB_NAME:$COMMIT_HASH + docker tag $IMAGE_NAME $HUB_NAME:latest + + echo "" + echo "CTRL+C to cancel, anything to push to docker hub" + read -n 1 + docker push $HUB_NAME:$COMMIT_HASH + docker push $HUB_NAME:latest +} + +if [ -z "$(git status --untracked-files=no --porcelain)" ]; then + do_push +else + echo "unclean git tree! CTRL+C to cancel, anything to commit and push to default branch" + read -n 1 + read -p "Enter commit message: " COMMIT_MESSAGE + git add . + git commit -m "$COMMIT_MESSAGE" + git push + do_push +fi |
