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

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
#paddle production image name
if [ ! -n "$1" ]; then
  paddle_image=paddlepaddle/paddle
else
  paddle_image=$1
fi

#paddle production image tag
if [ ! -n "$2" ]; then
  paddle_tag=0.10.0rc2
else
  paddle_tag=$2
fi

#paddle book image name
if [ ! -n "$3" ]; then
  book_image=paddlepaddle/book
else
  book_image=$3
fi

#paddle book image tag
if [ ! -n "$4" ]; then
  book_tag=latest
else
  book_tag=$4
fi
G
gongweibao 已提交
35 36 37

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

G
gongweibao 已提交
43 44 45
#build docker image
echo "paddle_tag:"$paddle_tag
echo "book_tag:"$book_tag
Y
Yancey1989 已提交
46

G
gongweibao 已提交
47
cat > Dockerfile <<EOF
48
FROM ${paddle_image}:${paddle_tag}
G
gongweibao 已提交
49 50
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>

Y
Yancey1989 已提交
51
COPY . /book
G
gongweibao 已提交
52 53 54

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

G
gongweibao 已提交
56
RUN ${update_mirror_cmd}
Y
Yancey1989 已提交
57 58 59 60 61 62
    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 已提交
63 64

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

68
docker build --no-cache  -t ${book_image}:${paddle_tag}  -t ${book_image}:${book_tag} .