From c9d7c2865d9bf24c9a376212e3cc156fe24a3154 Mon Sep 17 00:00:00 2001 From: zstadler Date: Thu, 1 Dec 2022 17:41:27 +0200 Subject: [PATCH] build.sh: accept an optional graphhopper tag ``` Build a docker image Usage: ./build.sh [ | --help] Argument: Build an image for the given graphhopper repository tag [default: master] Option: --help Print this message ``` --- build.sh | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/build.sh b/build.sh index d6a1af5..a4fd9c6 100644 --- a/build.sh +++ b/build.sh @@ -1,6 +1,39 @@ #!/bin/bash -echo "Cloning graphhopper" -git clone https://github.com/graphhopper/graphhopper.git -echo "Building docker image" -docker build . -t israelhikingmap/graphhopper:latest +usage() ( +cat < | --help] + +Argument: + Build an image for the given graphhopper repository tag [default: master] + +Option: + --help Print this message +USAGE +) + +if [ $# -gt 1 ] || [ "$1" == "--help" ]; then + usage + exit +fi + +if [ ! -d graphhopper ]; then + echo "Cloning graphhopper" + git clone https://github.com/graphhopper/graphhopper.git +fi + +imagename="israelhikingmap/graphhopper:${1:-latest}" +if [ "$1" ]; then + echo "Checking out graphhopper:$1" + (cd graphhopper; git checkout --detach "$1") +fi + +echo "Building docker image ${imagename}" +docker build . -t ${imagename} + +if [ $# -eq 1 ]; then + echo "Use \"docker push ${imagename}\" to publish the image on Docker Hub" +fi