forked from Kaggle/docker-rstats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild
executable file
·49 lines (43 loc) · 964 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 Docker R image.
Options:
-c, --use-cache Use layer cache when building a new image.
-g, --gpu Build an image with GPU support.
EOF
}
CACHE_FLAG='--no-cache'
DOCKERFILE='Dockerfile'
IMAGE_TAG='kaggle/rstats-build'
NCPUS=$(nproc || echo 1)
while :; do
case "$1" in
-h|--help)
usage
exit
;;
-c|--use-cache)
CACHE_FLAG=''
;;
-g|--gpu)
IMAGE_TAG='kaggle/rstats-gpu-build'
DOCKERFILE='gpu.Dockerfile'
;;
-?*)
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" --build-arg ncpus=$NCPUS .