build_docker.sh 1.5 KB
Newer Older
G
gongweibao 已提交
1
#!/bin/bash
L
liaogang 已提交
2 3
set -e

G
gongweibao 已提交
4 5 6
cur_path="$(cd "$(dirname "$0")" && pwd -P)"
cd $cur_path/../

7 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
#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 已提交
34 35 36

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

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

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

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

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

G
gongweibao 已提交
55
RUN ${update_mirror_cmd}
Y
Yancey1989 已提交
56
    apt-get update && \
L
liaogang 已提交
57
    apt-get install -y locales patch notedown && \
Y
Yancey1989 已提交
58 59 60 61
    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 已提交
62

L
liaogang 已提交
63 64 65
#convert md to ipynb
RUN /book/.tools/notedown.sh

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

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