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

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

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

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

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