build_docker.sh 1.4 KB
Newer Older
G
gongweibao 已提交
1 2 3 4
#!/bin/bash
cur_path="$(cd "$(dirname "$0")" && pwd -P)"
cd $cur_path/../

G
gongweibao 已提交
5 6 7 8 9 10 11
#check cache data
cache_data_path=.cache/paddle/dataset
if [ ${COPY_CACHE_DATA} ] && [ ! -d $cache_data_path ];  then
  echo 2>&1 "Check the cache_data_path:${cache_data_path}"
  exit 1
fi

G
gongweibao 已提交
12 13 14
#convert md to ipynb
.tools/convert-markdown-into-ipynb-and-test.sh

Y
Yancey1989 已提交
15 16
paddle_tag=0.10.0rc2
latest_tag=latest
G
gongweibao 已提交
17 18 19

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

mkdir -p build
Y
Yancey1989 已提交
26 27 28

cat > ./build/Dockerfile << EOF
FROM paddlepaddle/paddle:${paddle_tag}
G
gongweibao 已提交
29 30
MAINTAINER PaddlePaddle Authors <paddle-dev@baidu.com>

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

COPY . /book
Y
update  
Yancey1989 已提交
40
RUN python /book/.tools/cache_dataset.py
G
gongweibao 已提交
41 42
EXPOSE 8888
CMD ["sh", "-c", "jupyter notebook --ip=0.0.0.0 --no-browser --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True /book/"]
Y
Yancey1989 已提交
43
EOF
G
gongweibao 已提交
44 45

#build docker image
Y
Yancey1989 已提交
46 47
echo "paddle_tag:"$paddle_tag
echo $dockerfile | docker build --no-cache -t paddlepaddle/book:${paddle_tag}  -t paddlepaddle/book:${latest_tag}  -f ./build/Dockerfile .