forked from Kaggle/docker-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild
More file actions
executable file
·83 lines (77 loc) · 3 KB
/
build
File metadata and controls
executable file
·83 lines (77 loc) · 3 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
set -e
# Sync restricted dependencies to the local filesystem so that the docker build can pick them up.
# We cannot make these dependencies in their installable form public as they have licensing
# restrictions. They are however listed here for reproducability:
#
# 1. From http://docs.nvidia.com/deeplearning/sdk/cudnn-install/. Requires a NVidia developer
# account:
# libcudnn7_7.0.5.15-1+cuda9.1_amd64.deb
# libcudnn7-dev_7.0.5.15-1+cuda9.1_amd64.deb
# libcudnn7-doc_7.0.5.15-1+cuda9.1_amd64.deb
#
# You can either sync these deps locally yourself (prior to calling build) by setting
# KAGGLE_SKIP_SYNC_DEPS. For example:
# KAGGLE_SKIP_SYNC_DEPS=1 ./build
#
# Alternatively, to sync these from a gsutil supported location, specify the source path of the
# deps location to sync using KAGGLE_DEPS_SRC_PATH. For example:
# KAGGLE_DEPS_SRC_PATH=s3://my-aws-bucket/kaggle-python-docker-deps/ ./build
KAGGLE_DEPS_SRC_PATH="${KAGGLE_DEPS_SRC_PATH:-gs://kaggle-image-deps/}" # Private to Kaggle.
if [[ "$KAGGLE_SKIP_SYNC_DEPS" != "1" ]]; then
mkdir -p deps
gsutil rsync "$KAGGLE_DEPS_SRC_PATH" deps/
fi
# Default behavior is to do everything from scratch.
# The --use-cache option is useful if you're iterating on a broken build.
if [[ "$1" == "--use-cache" ]]; then
docker build --rm -t kaggle/python-build .
else
docker pull continuumio/anaconda3:latest
docker build --rm --no-cache -t kaggle/python-build .
fi
rm -rf /tmp/python-build
docker rm jupyter_test || true
mkdir -p /tmp/python-build/tmp
mkdir -p /tmp/python-build/devshm
mkdir -p /tmp/python-build/working
# Check that Jupyter server can run; if it dies on startup, the `docker kill` command will throw an error.
docker run \
-d \
--name=jupyter_test \
--read-only \
--net=none \
-e HOME=/tmp \
-v $PWD:/input:ro \
-v /tmp/python-build/working:/working \
-w=/working \
-v /tmp/python-build/tmp:/tmp \
-v /tmp/python-build/devshm:/dev/shm \
kaggle/python-build \
jupyter notebook --allow-root --ip="*"
sleep 3
docker kill jupyter_test && docker rm jupyter_test
docker run \
--rm \
-t \
--read-only \
--net=none \
-e HOME=/tmp \
-e KAGGLE_DATA_PROXY_TOKEN=test-key \
-e KAGGLE_DATA_PROXY_URL=http://127.0.0.1:8000 \
-e KAGGLE_DATA_PROXY_PROJECT=test \
-v $PWD:/input:ro \
-v /tmp/python-build/working:/working \
-w=/working \
-v /tmp/python-build/tmp:/tmp \
-v /tmp/python-build/devshm:/dev/shm \
kaggle/python-build \
/bin/bash -c 'python /input/test_build.py'
# The test_build.py script creates a plot called plot1.png; check that it exists.
[ -s /tmp/python-build/working/plot1.png ] || exit 1
# TODO(seb): DO NOT MERGE. This is temporary until we figure out how to approach the NVIDIA
# licensing requirements in our public images.
docker tag kaggle/python-build gcr.io/kaggle-private-byod/python
gcloud docker -- push gcr.io/kaggle-private-byod/python
#docker tag kaggle/python-build:latest kaggle/python:latest
#docker push kaggle/python:latest