build_docker.sh 1.3 KB
Newer Older
G
gongweibao 已提交
1 2 3 4 5 6 7
#!/bin/bash
cur_path="$(cd "$(dirname "$0")" && pwd -P)"
cd $cur_path/../

#convert md to ipynb
.tools/convert-markdown-into-ipynb-and-test.sh

Y
Yancey1989 已提交
8
paddle_tag=0.10.0rc2
G
gongweibao 已提交
9
book_tag=latest
G
gongweibao 已提交
10 11 12

#generate docker file
if [ ${USE_UBUNTU_REPO_MIRROR} ]; then
G
gongweibao 已提交
13
  update_mirror_cmd="sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \\"
G
gongweibao 已提交
14
else
G
gongweibao 已提交
15
  update_mirror_cmd="\\"
G
gongweibao 已提交
16 17
fi

G
gongweibao 已提交
18 19 20
#build docker image
echo "paddle_tag:"$paddle_tag
echo "book_tag:"$book_tag
Y
Yancey1989 已提交
21

G
gongweibao 已提交
22
cat > Dockerfile <<EOF
Y
Yancey1989 已提交
23
FROM paddlepaddle/paddle:${paddle_tag}
G
gongweibao 已提交
24 25
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>

Y
Yancey1989 已提交
26
COPY . /book
G
gongweibao 已提交
27

28 29 30 31
#RUN pip install -U nltk \
#    && python /book/.tools/cache_dataset.py

RUN python -c "import paddle.v2.dataset as dataset; dataset.fetch_all()"
Y
Yancey1989 已提交
32

G
gongweibao 已提交
33
RUN ${update_mirror_cmd}
Y
Yancey1989 已提交
34 35 36 37 38 39
    apt-get update && \
    apt-get install -y locales && \
    apt-get -y install gcc && \
    apt-get -y clean && \
    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
    pip install -U matplotlib jupyter numpy requests scipy
G
gongweibao 已提交
40 41

EXPOSE 8888
Y
Yancey1989 已提交
42
CMD ["sh", "-c", "jupyter notebook --ip=0.0.0.0 --no-browser --allow-root --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True /book/"]
Y
Yancey1989 已提交
43
EOF
G
gongweibao 已提交
44

G
gongweibao 已提交
45
docker build --no-cache  -t paddlepaddle/book:${paddle_tag}  -t paddlepaddle/book:${book_tag} .