build_docker.sh 1.2 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

RUN pip install -U nltk \
    && python /book/.tools/cache_dataset.py
Y
Yancey1989 已提交
30

G
gongweibao 已提交
31
RUN ${update_mirror_cmd}
Y
Yancey1989 已提交
32 33 34 35 36 37
    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 已提交
38 39 40

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

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