forked from mjang/docker-1
-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.sh
executable file
·63 lines (49 loc) · 1.32 KB
/
build.sh
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
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env bash
# Build Docker images
# Usage: ./build image [-d] [-p] image-dir
# Options
# -d download: runs mvn package to get latest software bits
# -p push the image to the registry
# Note: On a Mac you need to replace the ancient bash with a more up to date one using homebrew
# ENV vars for the registry / repo and tags
REPO=${REPO:-forgerock}
TAG=${TAG:-latest}
# To test this script uncomment this
#DRYRUN="echo"
DRYRUN=""
# If you add new docker images add them here
IMAGES="apache-agent openam opendj openidm openidm-postgres openig resty ssoadm ssoconfig openam-onbuild openidm-onbuild"
function download {
echo "downloading software"
mvn package
}
function buildDocker {
${DRYRUN} docker build -t ${REPO}/$1:${TAG} $1
if [[ -v PUSH ]]; then
${DRYRUN} docker push ${REPO}/$1
fi
}
while getopts "dp" opt; do
case ${opt} in
d) # process option a
download
;;
p ) # process option l
PUSH="1"
;;
\? )
echo "Usage: build [-d] [-p] image"
echo "-d downloads ForgeRock binaries in maven pom.xml, -p push images to registry after building"
;;
esac
done
shift $((OPTIND -1))
if [ "$#" -eq "0" ]; then
echo "Building All images"
for image in $IMAGES; do
buildDocker $image
done
else
echo "Building $@"
buildDocker $@
fi