-
Notifications
You must be signed in to change notification settings - Fork 13
/
Dockerfile
97 lines (92 loc) · 3.69 KB
/
Dockerfile
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
FROM alpine:3.6
ENV JAVA_HOME /usr/lib/jvm/java-1.8-openjdk
ENV LOCAL_RESOURCES 2048,.5,1.0
ENV BAZEL_VERSION 0.7.0
ENV TENSORFLOW_VERSION 1.4.0
RUN apk add --no-cache python3 python3-tkinter py3-numpy py3-numpy-f2py freetype libpng libjpeg-turbo imagemagick graphviz git
RUN apk add --no-cache --virtual=.build-deps \
bash \
cmake \
curl \
freetype-dev \
g++ \
libjpeg-turbo-dev \
libpng-dev \
linux-headers \
make \
musl-dev \
openblas-dev \
openjdk8 \
patch \
perl \
python3-dev \
py-numpy-dev \
rsync \
sed \
swig \
zip \
&& : prepare for building TensorFlow \
&& : install wheel python module \
&& cd /tmp \
&& pip3 install --no-cache-dir wheel \
&& : \
&& : add python symlink to avoid python detection error \
&& $(cd /usr/bin && ln -s python3 python) \
&& : install Bazel to build TensorFlow \
&& curl -SLO https://github.com/bazelbuild/bazel/releases/download/${BAZEL_VERSION}/bazel-${BAZEL_VERSION}-dist.zip \
&& mkdir bazel-${BAZEL_VERSION} \
&& unzip -qd bazel-${BAZEL_VERSION} bazel-${BAZEL_VERSION}-dist.zip \
&& cd bazel-${BAZEL_VERSION} \
&& : add -fpermissive compiler option to avoid compilation failure \
&& sed -i -e '/"-std=c++0x"/{h;s//"-fpermissive"/;x;G}' tools/cpp/cc_configure.bzl \
&& : add '#include <sys/stat.h>' to avoid mode_t type error \
&& sed -i -e '/#endif \/\/ COMPILER_MSVC/{h;s//#else/;G;s//#include <sys\/stat.h>/;G;}' third_party/ijar/common.h \
&& bash compile.sh \
&& cp -p output/bazel /usr/bin/ \
&& : \
&& : build TensorFlow pip package \
&& cd /tmp \
&& curl -SL https://github.com/tensorflow/tensorflow/archive/v${TENSORFLOW_VERSION}.tar.gz \
| tar xzf - \
&& cd tensorflow-${TENSORFLOW_VERSION} \
&& : musl-libc does not have "secure_getenv" function \
&& sed -i -e '/JEMALLOC_HAVE_SECURE_GETENV/d' third_party/jemalloc.BUILD \
&& PYTHON_BIN_PATH=/usr/bin/python \
PYTHON_LIB_PATH=/usr/lib/python3.6/site-packages \
CC_OPT_FLAGS="-march=native" \
TF_NEED_JEMALLOC=1 \
TF_NEED_GCP=0 \
TF_NEED_HDFS=0 \
TF_NEED_S3=0 \
TF_ENABLE_XLA=0 \
TF_NEED_GDR=0 \
TF_NEED_VERBS=0 \
TF_NEED_OPENCL=0 \
TF_NEED_CUDA=0 \
TF_NEED_MPI=0 \
bash configure \
&& bazel build -c opt --local_resources ${LOCAL_RESOURCES} //tensorflow/tools/pip_package:build_pip_package \
&& ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg \
&& : \
&& : install python modules including TensorFlow \
&& cd \
&& pip3 install --no-cache-dir /tmp/tensorflow_pkg/tensorflow-${TENSORFLOW_VERSION}-cp36-cp36m-linux_x86_64.whl \
&& pip3 install --no-cache-dir pandas scipy jupyter \
&& pip3 install --no-cache-dir scikit-learn matplotlib Pillow \
&& pip3 install --no-cache-dir google-api-python-client \
&& : \
&& : clean up unneeded packages and files \
&& apk del .build-deps \
&& rm -f /usr/bin/bazel \
&& rm -rf /tmp/* /root/.cache
RUN jupyter notebook --generate-config --allow-root \
&& sed -i -e "/c\.NotebookApp\.ip/a c.NotebookApp.ip = '*'" \
-e "/c\.NotebookApp\.open_browser/a c.NotebookApp.open_browser = False" \
/root/.jupyter/jupyter_notebook_config.py
RUN ipython profile create \
&& sed -i -e "/c\.InteractiveShellApp\.matplotlib/a c.InteractiveShellApp.matplotlib = 'inline'" \
/root/.ipython/profile_default/ipython_kernel_config.py
ADD init.sh /usr/local/bin/init.sh
RUN chmod u+x /usr/local/bin/init.sh
EXPOSE 8888
CMD ["/usr/local/bin/init.sh"]