From 98940e9f6384b51812d5b8d68e8a2c0d384a5569 Mon Sep 17 00:00:00 2001 From: Xiangquan Xiao Date: Thu, 4 Jun 2020 14:54:52 -0700 Subject: [PATCH] Docker: Clean up apt cache to reduce image size by 1GB. --- docker/build/installers/install_adolc.sh | 5 +++-- docker/build/installers/install_bazel.sh | 4 ++++ docker/build/installers/install_bosfs.sh | 2 +- docker/build/installers/install_common_modules.sh | 3 +++ docker/build/installers/install_cyber_deps.sh | 3 +-- docker/build/installers/install_drivers_deps.sh | 4 ++++ docker/build/installers/install_glew.sh | 4 +++- docker/build/installers/install_gpu_support.sh | 4 ++++ docker/build/installers/install_ipopt.sh | 3 --- docker/build/installers/install_libtorch.sh | 2 +- docker/build/installers/install_llvm_clang.sh | 1 - .../installers/install_minimal_environment.sh | 14 +++++++------- docker/build/installers/install_pcl.sh | 4 ++++ docker/build/installers/install_python_modules.sh | 9 ++++++--- docker/build/installers/install_qa_tools.sh | 1 + docker/build/installers/install_tensorrt.sh | 5 +---- docker/build/installers/install_visualizer_deps.sh | 5 +++-- docker/build/new_dev.x86_64.dockerfile | 5 ++++- docker/scripts/cyber_start.sh | 2 +- docker/scripts/dev_start.sh | 2 +- 20 files changed, 52 insertions(+), 30 deletions(-) diff --git a/docker/build/installers/install_adolc.sh b/docker/build/installers/install_adolc.sh index e469f312e6e..0cb4d7cedcd 100755 --- a/docker/build/installers/install_adolc.sh +++ b/docker/build/installers/install_adolc.sh @@ -30,5 +30,6 @@ apt-get -y update && \ libcolpack-dev \ libadolc-dev -# clean up -apt-get clean && rm -rf /var/lib/apt/lists/* +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_bazel.sh b/docker/build/installers/install_bazel.sh index 3404b27119d..80f6c908082 100755 --- a/docker/build/installers/install_bazel.sh +++ b/docker/build/installers/install_bazel.sh @@ -85,3 +85,7 @@ elif [ "$ARCH" == "aarch64" ]; then else echo "not support $ARCH" fi + +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_bosfs.sh b/docker/build/installers/install_bosfs.sh index 6a387e59e0f..97110478338 100755 --- a/docker/build/installers/install_bosfs.sh +++ b/docker/build/installers/install_bosfs.sh @@ -47,7 +47,7 @@ popd ok "Successfully installed bosfs-${VERSION}." -# Clean +# Clean up cache to reduce layer size. rm -fr ${PACKAGE} "bosfs-${VERSION}" apt-get clean && \ rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_common_modules.sh b/docker/build/installers/install_common_modules.sh index 1caa6b754aa..c3eaaeb5ed3 100755 --- a/docker/build/installers/install_common_modules.sh +++ b/docker/build/installers/install_common_modules.sh @@ -103,3 +103,6 @@ apt-get -y update && \ # modules/storytelling # modules/routing +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_cyber_deps.sh b/docker/build/installers/install_cyber_deps.sh index ef9ee812f34..6527f5f34b4 100755 --- a/docker/build/installers/install_cyber_deps.sh +++ b/docker/build/installers/install_cyber_deps.sh @@ -47,7 +47,6 @@ bash /tmp/installers/install_fast-rtps.sh info "Install Poco ..." bash /tmp/installers/install_poco.sh -# clean up +# Clean up cache to reduce layer size. apt-get clean && \ rm -rf /var/lib/apt/lists/* - diff --git a/docker/build/installers/install_drivers_deps.sh b/docker/build/installers/install_drivers_deps.sh index 8ba5aa47fb8..12c890ca94e 100755 --- a/docker/build/installers/install_drivers_deps.sh +++ b/docker/build/installers/install_drivers_deps.sh @@ -29,3 +29,7 @@ bash /tmp/installers/install_proj4.sh apt-get -y update && \ apt-get -y install \ libopencv-dev + +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_glew.sh b/docker/build/installers/install_glew.sh index ec302b99262..084132e91b1 100755 --- a/docker/build/installers/install_glew.sh +++ b/docker/build/installers/install_glew.sh @@ -31,4 +31,6 @@ apt-get -y update && \ # libglfw3-dev depends on libglfw3, # and libglew-dev have a dependency over libglew2.0 - +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_gpu_support.sh b/docker/build/installers/install_gpu_support.sh index 6738aac32c0..ebf0071d9b8 100755 --- a/docker/build/installers/install_gpu_support.sh +++ b/docker/build/installers/install_gpu_support.sh @@ -33,3 +33,7 @@ bash /tmp/installers/install_gpu_caffe.sh ${INSTALL_MODE} info "Install libtorch ..." bash /tmp/installers/install_libtorch.sh + +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_ipopt.sh b/docker/build/installers/install_ipopt.sh index fa2b2dd4c50..72488d29775 100755 --- a/docker/build/installers/install_ipopt.sh +++ b/docker/build/installers/install_ipopt.sh @@ -30,6 +30,3 @@ sed -i '/#define __IPSMARTPTR_HPP__/a\#define HAVE_CSTDDEF' \ /usr/include/coin/IpSmartPtr.hpp # Source Code Package Link: https://github.com/coin-or/Ipopt/releases - -# Clean up. -# apt-get clean && rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_libtorch.sh b/docker/build/installers/install_libtorch.sh index f3e83645dc6..1557fc04fac 100644 --- a/docker/build/installers/install_libtorch.sh +++ b/docker/build/installers/install_libtorch.sh @@ -52,6 +52,6 @@ pushd libtorch mv lib /usr/local/libtorch_cpu/lib mv share /usr/local/libtorch_cpu/share popd + # Cleanup rm -rf libtorch ${PKG_NAME} - diff --git a/docker/build/installers/install_llvm_clang.sh b/docker/build/installers/install_llvm_clang.sh index aae593e4269..400a90a5869 100755 --- a/docker/build/installers/install_llvm_clang.sh +++ b/docker/build/installers/install_llvm_clang.sh @@ -56,4 +56,3 @@ fi """ echo "${__mytext}" > /etc/profile.d/llvm-clang-path.sh - diff --git a/docker/build/installers/install_minimal_environment.sh b/docker/build/installers/install_minimal_environment.sh index 07a134a270e..17d86807b74 100644 --- a/docker/build/installers/install_minimal_environment.sh +++ b/docker/build/installers/install_minimal_environment.sh @@ -88,18 +88,18 @@ if [[ "${MY_GEO}" == "cn" ]]; then if [[ "${ARCH}" == "x86_64" ]]; then # Mirror from Tsinghua Univ. PYPI_MIRROR="https://pypi.tuna.tsinghua.edu.cn/simple" - python3 -m pip install --no-cache-dir -i "$PYPI_MIRROR" pip -U + pip3_install -i "$PYPI_MIRROR" pip -U python3 -m pip config set global.index-url "$PYPI_MIRROR" else info "Use default PYPI mirror: https://pypi.org/simple for ${ARCH} for ${MY_GEO}" - python3 -m pip install --no-cache-dir pip -U + pip3_install pip -U fi else - python3 -m pip install --no-cache-dir pip -U + pip3_install pip -U fi -python3 -m pip install --no-cache-dir setuptools - -# Clean up. -apt-get clean && rm -rf /var/lib/apt/lists/* +pip3_install setuptools +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_pcl.sh b/docker/build/installers/install_pcl.sh index ac138b3461f..10f448c0e69 100755 --- a/docker/build/installers/install_pcl.sh +++ b/docker/build/installers/install_pcl.sh @@ -73,3 +73,7 @@ else #clean up rm -fr pcl.zip pcl fi + +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_python_modules.sh b/docker/build/installers/install_python_modules.sh index c7e914ef6bb..9b646bd077c 100755 --- a/docker/build/installers/install_python_modules.sh +++ b/docker/build/installers/install_python_modules.sh @@ -21,6 +21,8 @@ set -e cd "$(dirname "${BASH_SOURCE[0]}")" +. /tmp/installers/installer_base.sh + apt update -y && apt install -y \ libgeos-dev \ python3-matplotlib \ @@ -29,7 +31,8 @@ apt update -y && apt install -y \ python3-scipy \ software-properties-common -pip3 install --no-cache-dir -r py3_requirements.txt +pip3_install -r py3_requirements.txt -# Clean up. -apt-get clean && rm -rf /var/lib/apt/lists/* +# Clean up cache to reduce layer size. +apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_qa_tools.sh b/docker/build/installers/install_qa_tools.sh index fcd46d62067..b1f135fb64e 100755 --- a/docker/build/installers/install_qa_tools.sh +++ b/docker/build/installers/install_qa_tools.sh @@ -36,5 +36,6 @@ apt-get -y update && \ pip3_install pycodestyle pip3_install pylint +# Clean up cache to reduce layer size. apt-get clean && \ rm -rf /var/lib/apt/lists/* diff --git a/docker/build/installers/install_tensorrt.sh b/docker/build/installers/install_tensorrt.sh index be1e8e19195..a6e50fac392 100755 --- a/docker/build/installers/install_tensorrt.sh +++ b/docker/build/installers/install_tensorrt.sh @@ -49,7 +49,4 @@ CUDNN_HEADER_DIR="/usr/include/$(uname -m)-linux-gnu" ln -s "${CUDNN_HEADER_DIR}/cudnn_v7.h" "${CUDNN_HEADER_DIR}/cudnn.h" # disable nvidia apt source to speed to build process -sed -i 's/^/# /g' /etc/apt/sources.list.d/nvidia-ml.list - -info "nVidia machine learning repo disabled after successful TensorRT-7 installation" -info "$(cat /etc/apt/sources.list.d/nvidia-ml.list)" +rm -f /etc/apt/sources.list.d/nvidia-ml.list diff --git a/docker/build/installers/install_visualizer_deps.sh b/docker/build/installers/install_visualizer_deps.sh index aad345540c8..d2dd706c995 100755 --- a/docker/build/installers/install_visualizer_deps.sh +++ b/docker/build/installers/install_visualizer_deps.sh @@ -42,7 +42,8 @@ apt-get -y update && \ # For test run # /usr/local/cuda/samples/5_Simulations/nbody +bash /tmp/installers/install_qt.sh + +# Clean up cache to reduce layer size. apt-get clean && \ rm -rf /var/lib/apt/lists/* - -bash /tmp/installers/install_qt.sh diff --git a/docker/build/new_dev.x86_64.dockerfile b/docker/build/new_dev.x86_64.dockerfile index 08a5328642e..4d37b60dae4 100644 --- a/docker/build/new_dev.x86_64.dockerfile +++ b/docker/build/new_dev.x86_64.dockerfile @@ -1,4 +1,4 @@ -FROM apolloauto/apollo:cyber-x86_64-18.04-20200602_2144 +FROM apolloauto/apollo:cyber-x86_64-18.04-20200604_1305 ARG GEOLOC ARG BUILD_STAGE @@ -22,4 +22,7 @@ RUN bash /tmp/installers/install_3rdparty_pept_deps.sh ${INSTALL_MODE} RUN bash /tmp/installers/install_glew.sh RUN bash /tmp/installers/install_pcl.sh +# TODO(xiaoxq): Not needed for docker_dev, but should enable before release. +# RUN bash /tmp/installers/install_bosfs.sh + RUN bash /tmp/installers/post_install.sh ${BUILD_STAGE} diff --git a/docker/scripts/cyber_start.sh b/docker/scripts/cyber_start.sh index 7bd5c025d31..37b8154f825 100755 --- a/docker/scripts/cyber_start.sh +++ b/docker/scripts/cyber_start.sh @@ -20,7 +20,7 @@ source "${APOLLO_ROOT_DIR}/scripts/apollo.bashrc" # CACHE_ROOT_DIR="${APOLLO_ROOT_DIR}/.cache" -VERSION_X86_64="cyber-x86_64-18.04-20200602_2144" +VERSION_X86_64="cyber-x86_64-18.04-20200604_1305" VERSION_AARCH64="cyber-aarch64-18.04-20200525_0656" VERSION_LOCAL_CYBER="local_cyber_dev" CYBER_CONTAINER="apollo_cyber_${USER}" diff --git a/docker/scripts/dev_start.sh b/docker/scripts/dev_start.sh index 368c20edb82..fdc24489fc5 100755 --- a/docker/scripts/dev_start.sh +++ b/docker/scripts/dev_start.sh @@ -28,7 +28,7 @@ LOCAL_IMAGE="no" FAST_BUILD_MODE="no" FAST_TEST_MODE="no" VERSION="" -VERSION_X86_64="dev-x86_64-18.04-20200603_0039" +VERSION_X86_64="dev-x86_64-18.04-20200604_1359" VERSION_AARCH64="dev-aarch64-20170927_1111" VERSION_OPT="" NO_PULL_IMAGE=""