Skip to content

Commit

Permalink
Docker: Clean up apt cache to reduce image size by 1GB.
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoxq authored and storypku committed Jun 5, 2020
1 parent 7fc1310 commit 98940e9
Show file tree
Hide file tree
Showing 20 changed files with 52 additions and 30 deletions.
5 changes: 3 additions & 2 deletions docker/build/installers/install_adolc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
4 changes: 4 additions & 0 deletions docker/build/installers/install_bazel.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
2 changes: 1 addition & 1 deletion docker/build/installers/install_bosfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
3 changes: 3 additions & 0 deletions docker/build/installers/install_common_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
3 changes: 1 addition & 2 deletions docker/build/installers/install_cyber_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*

4 changes: 4 additions & 0 deletions docker/build/installers/install_drivers_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
4 changes: 3 additions & 1 deletion docker/build/installers/install_glew.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
4 changes: 4 additions & 0 deletions docker/build/installers/install_gpu_support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
3 changes: 0 additions & 3 deletions docker/build/installers/install_ipopt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
2 changes: 1 addition & 1 deletion docker/build/installers/install_libtorch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}

1 change: 0 additions & 1 deletion docker/build/installers/install_llvm_clang.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,3 @@ fi
"""

echo "${__mytext}" > /etc/profile.d/llvm-clang-path.sh

14 changes: 7 additions & 7 deletions docker/build/installers/install_minimal_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
4 changes: 4 additions & 0 deletions docker/build/installers/install_pcl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
9 changes: 6 additions & 3 deletions docker/build/installers/install_python_modules.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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/*
1 change: 1 addition & 0 deletions docker/build/installers/install_qa_tools.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
5 changes: 1 addition & 4 deletions docker/build/installers/install_tensorrt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 3 additions & 2 deletions docker/build/installers/install_visualizer_deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 4 additions & 1 deletion docker/build/new_dev.x86_64.dockerfile
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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}
2 changes: 1 addition & 1 deletion docker/scripts/cyber_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
2 changes: 1 addition & 1 deletion docker/scripts/dev_start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down

0 comments on commit 98940e9

Please sign in to comment.