forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·49 lines (42 loc) · 920 Bytes
/
build
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
#!/bin/bash
set -e
usage() {
cat << EOF
Usage: $0 [OPTIONS]
Build a new Python Docker image.
Options:
-g, --gpu Build an image with GPU support.
-c, --use-cache Use layer cache when building a new image.
EOF
}
CACHE_FLAG='--no-cache'
DOCKERFILE='Dockerfile'
IMAGE_TAG='kaggle/python-build'
while :; do
case "$1" in
-h|--help)
usage
exit
;;
-g|--gpu)
IMAGE_TAG='kaggle/python-gpu-build'
DOCKERFILE='gpu.Dockerfile'
;;
-c|--use-cache)
CACHE_FLAG=''
;;
-?*)
usage
printf 'ERROR: Unknown option: %s\n' "$1" >&2
exit
;;
*)
break
esac
shift
done
readonly CACHE_FLAG
readonly DOCKERFILE
readonly IMAGE_TAG
set -x
docker build --rm --pull $CACHE_FLAG -t "$IMAGE_TAG" -f "$DOCKERFILE" .