-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuilder.sh
More file actions
executable file
·66 lines (57 loc) · 1.1 KB
/
Copy pathbuilder.sh
File metadata and controls
executable file
·66 lines (57 loc) · 1.1 KB
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
#!/bin/bash
WORKDIR=$(dirname $0)
ENVFILE="${WORKDIR}/.env"
# Default args
NBPROC=$(nproc || echo 1)
DOCKER_BASEIMAGE="trinitycore"
DOCKER_PUSH="false"
if [ -f ${ENVFILE} ]
then
echo "Sourcing variables from ${ENVFILE}"
export $(cat .env | xargs)
fi
function fail()
{
>&2 echo $@
exit 2
}
POSITIONAL_ARGS=()
while [[ $# -gt 0 ]]; do
case $1 in
-b|--docker-base-imagename)
DOCKER_BASEIMAGE="$2"
shift
shift
;;
-j)
NBPROC="$2"
shift
shift
;;
-p|--push)
DOCKER_PUSH="true"
shift
;;
-*|--*)
echo "Unknown option $1"
exit 1
;;
*)
POSITIONAL_ARGS+=("$1") # save positional arg
shift # past argument
;;
esac
done
set -- "${POSITIONAL_ARGS[@]}" # restore positional parameters
for vers in ${POSITIONAL_ARGS[@]}
do
test -d $vers || fail "directory ${vers} not found"
cd $vers
test -f Dockerfile || fail "Dockerfile not found in $(pwd)"
docker build -t ${DOCKER_BASEIMAGE}:${vers} . || exit 1
if [ ${DOCKER_PUSH} == "true" ]
then
docker push ${DOCKER_BASEIMAGE}:${vers}
fi
cd ..
done