From e7d2ad900f211f884b9fc28ad36c8df003d4f633 Mon Sep 17 00:00:00 2001 From: gongweibao Date: Tue, 21 Mar 2017 16:52:30 +0800 Subject: [PATCH] copy cache data --- .tools/build_docker.sh | 30 +++++++++++++++---- .../convert-markdown-into-ipynb-and-test.sh | 4 +-- 2 files changed, 27 insertions(+), 7 deletions(-) diff --git a/.tools/build_docker.sh b/.tools/build_docker.sh index 55faa71..5343e51 100755 --- a/.tools/build_docker.sh +++ b/.tools/build_docker.sh @@ -2,24 +2,32 @@ cur_path="$(cd "$(dirname "$0")" && pwd -P)" cd $cur_path/../ +#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 + #convert md to ipynb .tools/convert-markdown-into-ipynb-and-test.sh paddle_version=0.10.0rc2 +latest_label=latest #generate docker file if [ ${USE_UBUNTU_REPO_MIRROR} ]; then - UPDATE_MIRROR_CMD="sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \\" + update_mirror_cmd="sed 's@http:\/\/archive.ubuntu.com\/ubuntu\/@mirror:\/\/mirrors.ubuntu.com\/mirrors.txt@' -i /etc/apt/sources.list && \\" else - UPDATE_MIRROR_CMD="\\" + update_mirror_cmd="\\" fi mkdir -p build -cat > build/Dockerfile < build/Dockerfile < -RUN ${UPDATE_MIRROR_CMD} +RUN ${update_mirror_cmd} apt-get install locales RUN localedef -f UTF-8 -i en_US en_US.UTF-8 @@ -30,6 +38,18 @@ RUN pip install -U matplotlib jupyter numpy requests scipy COPY . /book RUN rm -rf /book/build +EOF1 + +if [ ${COPY_CACHE_DATA} ]; then + +cat >> build/Dockerfile << EOF2 +RUN mkdir -p /root/${cache_data_path} +RUN mv /book/${cache_data_path}/* /root/${cache_data_path}/ && rm -rf /book/${cache_data_path} +EOF2 + +fi + +cat >> build/Dockerfile << EOF EXPOSE 8888 CMD ["sh", "-c", "jupyter notebook --ip=0.0.0.0 --no-browser --NotebookApp.token='' --NotebookApp.disable_check_xsrf=True /book/"] @@ -37,4 +57,4 @@ EOF #build docker image echo "paddle_version:"$paddle_version -docker build --no-cache -t paddlepaddle/book:${paddle_version} -t paddlepaddle/book:latest -f ./build/Dockerfile . +docker build --no-cache -t paddlepaddle/book:${paddle_version} -t paddlepaddle/book:${latest_label} -f ./build/Dockerfile . diff --git a/.tools/convert-markdown-into-ipynb-and-test.sh b/.tools/convert-markdown-into-ipynb-and-test.sh index 710b619..67d9956 100755 --- a/.tools/convert-markdown-into-ipynb-and-test.sh +++ b/.tools/convert-markdown-into-ipynb-and-test.sh @@ -5,14 +5,14 @@ if [ $? -ne 0 ]; then exit 1 fi -GOPATH=~/.go go get -u github.com/wangkuiyi/ipynb/markdown-to-ipynb +GOPATH=~/.cache/go go get -u github.com/wangkuiyi/ipynb/markdown-to-ipynb cur_path="$(cd "$(dirname "$0")" && pwd -P)" cd $cur_path/../ #convert md to ipynb for file in */{README,README\.en}.md ; do - /tmp/go/bin/markdown-to-ipynb < $file > ${file%.*}".ipynb" + ~/.cache/go/bin/markdown-to-ipynb < $file > ${file%.*}".ipynb" if [ $? -ne 0 ]; then echo >&2 "markdown-to-ipynb $file error" exit 1 -- GitLab