forked from cookiecutter-flask/cookiecutter-flask
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cookiecutter-docker.sh
executable file
·55 lines (44 loc) · 980 Bytes
/
cookiecutter-docker.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
#!/usr/bin/env bash
set -e
PROGNAME=$0
BUILD_IMAGE=false
COOKIECUTTER_TEMPLATE='.'
usage() {
cat << EOF >&2
Usage: $PROGNAME [OPTIONS]
Options:
-b, --build Build Docker image before running cookiecutter
-h, --help Show this message and exit
EOF
exit 1
}
process_args() {
while test $# -gt 0
do
case "$1" in
-h) usage
;;
--help) usage
;;
-b) BUILD_IMAGE=true
;;
--build) BUILD_IMAGE=true
;;
--*) usage;
exit 1;
;;
*) usage;
exit 1;
;;
esac
shift
done
}
run_cookiecutter() {
if [[ "$(docker images -q cookiecutter-docker 2> /dev/null)" == "" ]] || $BUILD_IMAGE ; then
docker build . --tag=cookiecutter-docker
fi
docker run -i -t -v ${PWD}:/build -w /build cookiecutter-docker ${COOKIECUTTER_TEMPLATE}
}
process_args "$@"
run_cookiecutter