-
Notifications
You must be signed in to change notification settings - Fork 0
/
build_team.sh
executable file
·75 lines (64 loc) · 1.38 KB
/
build_team.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
#!/usr/bin/env bash
#!/bin/bash
# ------------- PUBLIC ONES
source ./utils.sh
NAME=
TAG='latest'
DockerfileName='Dockerfile'
#------------------------------------------------------------
printHelp() {
echo "
Usage : ./build_team.sh [OPTIONS]
Options:
-n , --name name
-t , --tag
-f , --f docker file name
"
}
checkParams() {
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-n | --name)
NAME="$2"
shift # past argument
shift # past value
;;
-t | --tag)
TAG="$2"
shift # past argument
shift # past value
;;
-f | --f)
DockerfileName="$2"
shift # past argument
shift # past value
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
success=1
[ ! -z "$NAME" ] || success=0
if ((!success)); then
printHelp
exit 1
fi
}
buildTeam() {
echo "--- BUILDING ${NAME}"
cp teams.Dockerfile bins/${NAME}/Dockerfile
cp challenge.Dockerfile bins/${NAME}/challenge.Dockerfile
chmod -R 777 bins/${NAME}/*
RUN "docker build -t ${NAME}:${TAG} -f bins/${NAME}/${DockerfileName} bins/${NAME}" -po
echo "--- END BUILDING ${NAME}"
}
main() {
checkParams "$@"
# ----- RUN
buildTeam
}
main "$@"
exit 0