aboutsummaryrefslogtreecommitdiffstats
path: root/build_docker_image.sh
diff options
context:
space:
mode:
Diffstat (limited to 'build_docker_image.sh')
-rwxr-xr-xbuild_docker_image.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/build_docker_image.sh b/build_docker_image.sh
new file mode 100755
index 0000000..504dd4d
--- /dev/null
+++ b/build_docker_image.sh
@@ -0,0 +1,31 @@
+#!/usr/bin/env bash
+set -Eeuo pipefail
+
+do_push() {
+ IMAGE_NAME="srht-git-feed"
+ HUB_NAME="ivarlovlie/srht-git-feed"
+ COMMIT_HASH=$(git rev-parse --short HEAD)
+
+ echo $COMMIT_HASH >version.txt
+ docker build -t $IMAGE_NAME .
+ 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