build_docker.sh 1.7 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
Y
Yu Yang 已提交
51 52 53 54 55 56 57 58
EOF

if [ -n ${http_proxy} ]; then
cat >> Dockerfile <<EOF
ENV http_proxy ${http_proxy}
ENV https_proxy ${http_proxy}
EOF
fi
G
gongweibao 已提交
59

Y
Yu Yang 已提交
60
cat >> Dockerfile <<EOF
G
gongweibao 已提交
61 62
RUN pip install -U nltk \
    && python /book/.tools/cache_dataset.py
Y
Yancey1989 已提交
63

G
gongweibao 已提交
64
RUN ${update_mirror_cmd}
Y
Yancey1989 已提交
65
    apt-get update && \
L
liaogang 已提交
66
    apt-get install -y locales patch notedown && \
Y
Yancey1989 已提交
67 68 69
    apt-get -y install gcc && \
    apt-get -y clean && \
    localedef -f UTF-8 -i en_US en_US.UTF-8 && \
L
liaogang 已提交
70
    pip install --upgrade pip && \
G
gangliao 已提交
71
    pip install -U pillow matplotlib jupyter numpy requests scipy
G
gongweibao 已提交
72

L
liaogang 已提交
73 74 75
#convert md to ipynb
RUN /book/.tools/notedown.sh

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

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