Build scripts refactoring
`.github/build-and-upload.sh` to use `build.sh` Related to #32
هذا الالتزام موجود في:
22
.github/build-and-upload.sh
مباع
Normal file → Executable file
22
.github/build-and-upload.sh
مباع
Normal file → Executable file
@@ -1,20 +1,12 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "Cloning graphhopper"
|
||||
git clone https://github.com/graphhopper/graphhopper.git
|
||||
echo "Building docker image"
|
||||
docker build . -t israelhikingmap/graphhopper:latest
|
||||
docker login --username $DOCKERHUB_USER --password $DOCKERHUB_TOKEN
|
||||
echo "Publishing docker image"
|
||||
docker push israelhikingmap/graphhopper:latest
|
||||
echo "Buidling and pushing israelhikingmap/graphhopper:latest"
|
||||
./build.sh --push
|
||||
|
||||
TAG=`cd graphhopper; git for-each-ref --sort=committerdate refs/tags | tail -n 1 | cut -d "/" -f3`
|
||||
if docker manifest inspect israelhikingmap/graphhopper:$TAG >/dev/null; then
|
||||
echo "No need to publish existing version: $TAG";
|
||||
TAG=`cd graphhopper; git for-each-ref --sort=committerdate refs/tags | sed -n '$s/.*\///p'`
|
||||
if docker manifest inspect "israelhikingmap/graphhopper:${TAG}" >/dev/null; then
|
||||
echo "No need to push existing version: ${TAG}";
|
||||
else
|
||||
(cd graphhopper ; git checkout tags/$TAG)
|
||||
echo "Building docker image for tag: $TAG"
|
||||
docker build . -t israelhikingmap/graphhopper:$TAG
|
||||
echo "Publishing docker image for tag: $TAG"
|
||||
docker push israelhikingmap/graphhopper:$TAG
|
||||
echo "Buidling and pushing israelhikingmap/graphhopper:${TAG}"
|
||||
./build.sh --push "${TAG}"
|
||||
fi
|
||||
|
||||
22
build.sh
22
build.sh
@@ -5,16 +5,26 @@ cat <<USAGE
|
||||
Build a docker image
|
||||
|
||||
Usage:
|
||||
./build.sh [<tag> | --help]
|
||||
./build.sh [[--push] <tag>]
|
||||
./build.sh --help
|
||||
|
||||
Argument:
|
||||
<tag> Build an image for the given graphhopper repository tag [default: master]
|
||||
|
||||
Option:
|
||||
--push Push the image to Docker Hub
|
||||
--help Print this message
|
||||
USAGE
|
||||
)
|
||||
|
||||
if [ "$1" == "--push" ]; then
|
||||
push="true"
|
||||
docker login --username "${DOCKERHUB_USER}" --password "${DOCKERHUB_TOKEN}" || exit $?
|
||||
shift
|
||||
else
|
||||
push="false"
|
||||
fi
|
||||
|
||||
if [ $# -gt 1 ] || [ "$1" == "--help" ]; then
|
||||
usage
|
||||
exit
|
||||
@@ -23,6 +33,9 @@ fi
|
||||
if [ ! -d graphhopper ]; then
|
||||
echo "Cloning graphhopper"
|
||||
git clone https://github.com/graphhopper/graphhopper.git
|
||||
else
|
||||
echo "Pulling graphhopper"
|
||||
(cd graphhopper; git checkout master; git pull)
|
||||
fi
|
||||
|
||||
imagename="israelhikingmap/graphhopper:${1:-latest}"
|
||||
@@ -32,8 +45,11 @@ if [ "$1" ]; then
|
||||
fi
|
||||
|
||||
echo "Building docker image ${imagename}"
|
||||
docker build . -t ${imagename}
|
||||
docker build . -t "${imagename}"
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
if [ "${push}" == "false" ]; then
|
||||
echo "Use \"docker push ${imagename}\" to publish the image on Docker Hub"
|
||||
else
|
||||
# TODO
|
||||
docker push "${imagename}"
|
||||
fi
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم