diff --git a/.tools/build_docker.sh b/.tools/build_docker.sh index 55faa715a4fbbda97d8ff6422fb2e3d7fe8668fc..5343e5169c55be7447c6eed741c572ec11cc9511 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 710b61957a82c033531d267aaccafcc616e6e46d..67d9956eb12be6743f0b9242b446df9aa690cf1e 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