-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathbuild
executable file
·51 lines (45 loc) · 2.49 KB
/
build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
# Override the build hook of the automated builds on Docker Hub.
# The build hook is running in the root of the git sandbox. That is the directory contaning the file RELEASE.
# See https://docs.docker.com/docker-hub/builds/advanced/ for the list of preset environment variables.
# Additionally, the undocumented environment variable $BUILD_PATH is used. $BUILD_PATH can be set
# in the input field Build Context of the Docker Hub automated build GUI.
# The path to the Dockerfile is given relative to ./$BUILD_PATH in order to be compatible
# with the default build hook in Docker Hub. The default value of the Build Context is '/'. The build command works with this approach,
# because the resulting path will then be something like .//otobo.web.dockerfile.
# These commands can be uncommented for debugging:
#pwd
#ls
#docker -v
#printenv
# The relevant Dockerfile and the target depend on the given Dockerfile.
# Note that the give Dockerfile does not have to exist, only the
# actually used Dockerfile must exist.
ACTUAL_DOCKERFILE_PATH=$(case $DOCKERFILE_PATH in
"otobo.kerberos.web.dockerfile") echo "otobo.web.dockerfile" ;;
"../../otobo.nginx-kerberos.dockerfile") echo "../../otobo.nginx.dockerfile" ;;
*) echo $DOCKERFILE_PATH ;;
esac)
TARGET_OPTION=$(case $DOCKERFILE_PATH in
"otobo.web.dockerfile") echo "--target=otobo-web" ;;
"otobo.kerberos.web.dockerfile") echo "--target=otobo-web-kerberos" ;;
"../../otobo.nginx.dockerfile") echo "--target=otobo-nginx-webproxy" ;;
"../../otobo.nginx-kerberos.dockerfile") echo "--target=otobo-nginx-kerberos-webproxy" ;;
"otobo.elasticsearch.dockerfile") echo "--target=otobo-elasticsearch" ;;
"otobo.nginx.dockerfile") echo "--target=otobo-nginx-webproxy" ;;
"otobo.nginx-kerberos.dockerfile") echo "--target=otobo-nginx-kerberos-webproxy" ;;
"otobo.selenium-chrome.dockerfile") echo "--target=otobo-selenium-chrome" ;;
*) echo "" ;;
esac)
# build the Docker image
# add the option '--progress plain' for seeing the printed output
docker build\
--build-arg "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"\
--build-arg "DOCKER_TAG=$DOCKER_TAG"\
--build-arg "GIT_COMMIT=$SOURCE_COMMIT"\
--build-arg "GIT_BRANCH=$SOURCE_BRANCH"\
--build-arg "GIT_REPO=$(git config --get remote.origin.url)"\
-f ./$BUILD_PATH/$ACTUAL_DOCKERFILE_PATH\
-t $IMAGE_NAME\
$TARGET_OPTION\
./$BUILD_PATH