|
| 1 | +# Java baseimage, for Bazel. |
1 | 2 | FROM java:8
|
2 | 3 |
|
3 | 4 | ENV SYNTAXNETDIR=/opt/tensorflow PATH=$PATH:/root/bin
|
4 | 5 |
|
| 6 | +# Install system packages. This doesn't include everything the TensorFlow |
| 7 | +# dockerfile specifies, so if anything goes awry, maybe install more packages |
| 8 | +# from there. Also, running apt-get clean before further commands will make the |
| 9 | +# Docker images smaller. |
5 | 10 | RUN mkdir -p $SYNTAXNETDIR \
|
6 | 11 | && cd $SYNTAXNETDIR \
|
7 | 12 | && apt-get update \
|
8 |
| - && apt-get install git zlib1g-dev file swig python2.7 python-dev python-pip python-mock -y \ |
9 |
| - && pip install --upgrade pip \ |
10 |
| - && pip install -U protobuf==3.0.0b2 \ |
11 |
| - && pip install asciitree \ |
12 |
| - && pip install numpy \ |
13 |
| - && wget https://github.com/bazelbuild/bazel/releases/download/0.4.3/bazel-0.4.3-installer-linux-x86_64.sh \ |
| 13 | + && apt-get install -y \ |
| 14 | + file \ |
| 15 | + git \ |
| 16 | + graphviz \ |
| 17 | + libcurl3-dev \ |
| 18 | + libfreetype6-dev \ |
| 19 | + libgraphviz-dev \ |
| 20 | + liblapack-dev \ |
| 21 | + libopenblas-dev \ |
| 22 | + libpng12-dev \ |
| 23 | + libxft-dev \ |
| 24 | + python-dev \ |
| 25 | + python-mock \ |
| 26 | + python-pip \ |
| 27 | + python2.7 \ |
| 28 | + swig \ |
| 29 | + vim \ |
| 30 | + zlib1g-dev \ |
| 31 | + && apt-get clean \ |
| 32 | + && (rm -f /var/cache/apt/archives/*.deb \ |
| 33 | + /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true) |
| 34 | + |
| 35 | +# Install common Python dependencies. Similar to above, remove caches |
| 36 | +# afterwards to help keep Docker images smaller. |
| 37 | +RUN pip install --ignore-installed pip \ |
| 38 | + && python -m pip install numpy \ |
| 39 | + && rm -rf /root/.cache/pip /tmp/pip* |
| 40 | +RUN python -m pip install \ |
| 41 | + asciitree \ |
| 42 | + ipykernel \ |
| 43 | + jupyter \ |
| 44 | + matplotlib \ |
| 45 | + pandas \ |
| 46 | + protobuf \ |
| 47 | + scipy \ |
| 48 | + sklearn \ |
| 49 | + && python -m ipykernel.kernelspec \ |
| 50 | + && python -m pip install pygraphviz \ |
| 51 | + --install-option="--include-path=/usr/include/graphviz" \ |
| 52 | + --install-option="--library-path=/usr/lib/graphviz/" \ |
| 53 | + && rm -rf /root/.cache/pip /tmp/pip* |
| 54 | + |
| 55 | +# Installs the latest version of Bazel. |
| 56 | +RUN wget --quiet https://github.com/bazelbuild/bazel/releases/download/0.4.3/bazel-0.4.3-installer-linux-x86_64.sh \ |
14 | 57 | && chmod +x bazel-0.4.3-installer-linux-x86_64.sh \
|
15 |
| - && ./bazel-0.4.3-installer-linux-x86_64.sh --user \ |
16 |
| - && git clone --recursive https://github.com/tensorflow/models.git \ |
17 |
| - && cd $SYNTAXNETDIR/models/syntaxnet/tensorflow \ |
18 |
| - && echo -e "\n\n\n\n\n\n\n\n\n" | ./configure \ |
19 |
| - && apt-get autoremove -y \ |
20 |
| - && apt-get clean |
| 58 | + && ./bazel-0.4.3-installer-linux-x86_64.sh \ |
| 59 | + && rm ./bazel-0.4.3-installer-linux-x86_64.sh |
| 60 | + |
| 61 | +COPY WORKSPACE $SYNTAXNETDIR/syntaxnet/WORKSPACE |
| 62 | +COPY tools/bazel.rc $SYNTAXNETDIR/syntaxnet/tools/bazel.rc |
| 63 | +COPY tensorflow $SYNTAXNETDIR/syntaxnet/tensorflow |
| 64 | + |
| 65 | +# Compile common TensorFlow targets, which don't depend on DRAGNN / SyntaxNet |
| 66 | +# source. This makes it more convenient to re-compile DRAGNN / SyntaxNet for |
| 67 | +# development (though not as convenient as the docker-devel scripts). |
| 68 | +RUN cd $SYNTAXNETDIR/syntaxnet/tensorflow \ |
| 69 | + && tensorflow/tools/ci_build/builds/configured CPU \ |
| 70 | + && cd $SYNTAXNETDIR/syntaxnet \ |
| 71 | + && bazel build -c opt @org_tensorflow//tensorflow:tensorflow_py |
21 | 72 |
|
22 |
| -RUN cd $SYNTAXNETDIR/models/syntaxnet \ |
23 |
| - && bazel test --genrule_strategy=standalone syntaxnet/... util/utf8/... |
| 73 | +# Build the codez. |
| 74 | +WORKDIR $SYNTAXNETDIR/syntaxnet |
| 75 | +COPY dragnn $SYNTAXNETDIR/syntaxnet/dragnn |
| 76 | +COPY syntaxnet $SYNTAXNETDIR/syntaxnet/syntaxnet |
| 77 | +COPY third_party $SYNTAXNETDIR/syntaxnet/third_party |
| 78 | +COPY util/utf8 $SYNTAXNETDIR/syntaxnet/util/utf8 |
| 79 | +RUN bazel build -c opt //dragnn/python:all //dragnn/tools:all |
24 | 80 |
|
25 |
| -WORKDIR $SYNTAXNETDIR/models/syntaxnet |
| 81 | +# This makes the IP exposed actually "*"; we'll do host restrictions by passing |
| 82 | +# a hostname to the `docker run` command. |
| 83 | +COPY tensorflow/tensorflow/tools/docker/jupyter_notebook_config.py /root/.jupyter/ |
| 84 | +EXPOSE 8888 |
26 | 85 |
|
27 |
| -CMD [ "sh", "-c", "echo 'Bob brought the pizza to Alice.' | syntaxnet/demo.sh" ] |
| 86 | +# This does not need to be compiled, only copied. |
| 87 | +COPY examples $SYNTAXNETDIR/syntaxnet/examples |
| 88 | +# Todo: Move this earlier in the file (don't want to invalidate caches for now). |
| 89 | +RUN jupyter nbextension enable --py --sys-prefix widgetsnbextension |
28 | 90 |
|
29 |
| -# COMMANDS to build and run |
30 |
| -# =============================== |
31 |
| -# mkdir build && cp Dockerfile build/ && cd build |
32 |
| -# docker build -t syntaxnet . |
33 |
| -# docker run syntaxnet |
| 91 | +CMD /bin/bash -c "bazel-bin/dragnn/tools/oss_notebook_launcher notebook --debug --notebook-dir=/opt/tensorflow/syntaxnet/examples" |
0 commit comments