-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.sh
executable file
·91 lines (81 loc) · 2.56 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/bash
######################################################################
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. #
# SPDX-License-Identifier: MIT-0 #
######################################################################
source .env
source .fun2
function usage() {
echo ""
echo "Usage:"
echo " $0 [option] - builds one or more containers in this project."
echo ""
echo " The build behavior is controlled by settings "
echo " in the configuration file .env"
echo ""
echo " BUILD_TO - controls whether the build is run by docker or docker-compose"
echo " use './config.sh BUILD_TO docker' or './config.sh BUILD_TO compose' to set"
echo " BUILD_TO=docker is recommended since it can build all container images"
echo " BUILD_TO=compose will only build the platform and ui container image "
echo ""
echo " options when BUILD_TO=docker:"
echo " '' - build the last built Dockerfile"
echo " ls - list available Dockerfiles to build"
echo " all - build all Dockerfiles sequentially"
echo ""
}
if [ ! "$TO" == "$BUILD_TO" ]; then
echo $BUILD_TO > wd/.to
source .env
fi
if [ "${DEBUG}" == "true" ]; then
set -x
fi
if [ "$1" == "--help" ]; then
usage
else
echo ""
echo "Building container image(s) ..."
case "${TO}" in
"compose")
echo " ... using ${DOCKER_COMPOSE}"
generate_compose_files
CMD="${DOCKER_COMPOSE} -f ${COMPOSE_FILE} build"
;;
"docker")
echo " ... using docker"
if [ "$1" == "ls" ]; then
ls -alh Dockerfile-*
elif [ "$1" == "all" ]; then
DOCKERFILES=$(ls Dockerfile-*)
for DF in $DOCKERFILES; do
./build.sh $DF
done
elif [ ! "$1" == "" ]; then
echo ""
echo "=================================================="
echo "Building Dockerfile: $1"
DF_EXT=-$(echo ${1} | cut -d '-' -f 2)
echo ${DF_EXT} > wd/.dockerfile_ext
./build.sh
else
CMD="docker image build ${BUILD_OPTS} -t ${REGISTRY}${IMAGE}${TAG} ."
fi
;;
*)
echo ""
echo "Target orchestrator (TO) must be 'compose' or 'docker' to build"
echo "Please set target orchestrator to 'compose' or 'docker' by executing ./config.sh TO "
usage
;;
esac
fi
if [ "${VERBOSE}" == "true" ]; then
echo "${CMD}"
fi
if [ "${DRY_RUN}" == "false" ]; then
eval "${CMD}"
fi
if [ "${DEBUG}" == "true" ]; then
set +x
fi