From 638a81fe7d361477f399823f35edde6237ea7e64 Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Mon, 2 Mar 2020 15:50:48 +0530 Subject: [PATCH 1/6] added some cleanup tweaks By default, Ubuntu or Debian based "apt" or "apt-get" system installs recommended but not suggested packages . By passing "--no-install-recommends" option, the user lets apt-get know not to consider recommended packages as a dependency to install. This results in smaller downloads and installation of packages . Refer to blog at [Ubuntu Blog](https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends) . Removed "sudo" as docker best practice at [Docker Blog](https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#user) Another Cleanup tweaks using 1. apt-get clean 2. rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* removing downloaded packages and packages list will free up some space , results in smaller image size. --- mcrouter/scripts/docker/Dockerfile | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/mcrouter/scripts/docker/Dockerfile b/mcrouter/scripts/docker/Dockerfile index 036157a3d..406269257 100644 --- a/mcrouter/scripts/docker/Dockerfile +++ b/mcrouter/scripts/docker/Dockerfile @@ -6,7 +6,16 @@ ENV MCROUTER_DIR /usr/local/mcrouter ENV MCROUTER_REPO https://github.com/facebook/mcrouter.git ENV DEBIAN_FRONTEND noninteractive -RUN apt-get update && apt-get install -y git && \ +RUN apt-get update && apt-get --no-install-recommends install -y git && \ + apt-get clean && \ + apt-get purge autoremove && \ + rm -rf \ + /var/lib/apt/lists/* \ + /tmp/* \ + /var/tmp/* \ + /usr/share/man \ + /usr/share/doc \ + /usr/share/doc-base && \ mkdir -p $MCROUTER_DIR/repo && \ cd $MCROUTER_DIR/repo && git clone $MCROUTER_REPO && \ cd $MCROUTER_DIR/repo/mcrouter/mcrouter/scripts && \ From bfa59b434a225a12dcf6cd66ffe911fefe2e92ce Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Mon, 2 Mar 2020 15:57:01 +0530 Subject: [PATCH 2/6] Update clean_ubuntu_14.04.sh By default, Ubuntu or Debian based "apt" or "apt-get" system installs recommended but not suggested packages . By passing "--no-install-recommends" option, the user lets apt-get know not to consider recommended packages as a dependency to install. This results in smaller downloads and installation of packages . Refer to blog at [Ubuntu Blog](https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends) . removing packages with "--purge" will clean the residual configurations of the packages. results in smaller image size. --- mcrouter/scripts/clean_ubuntu_14.04.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mcrouter/scripts/clean_ubuntu_14.04.sh b/mcrouter/scripts/clean_ubuntu_14.04.sh index ef8ed354c..987079d1f 100755 --- a/mcrouter/scripts/clean_ubuntu_14.04.sh +++ b/mcrouter/scripts/clean_ubuntu_14.04.sh @@ -6,17 +6,17 @@ set -ex -sudo apt-get install -y libdouble-conversion1 libgflags2 \ +sudo apt-get --no-install-recommends install -y libdouble-conversion1 libgflags2 \ libboost-program-options1.54.0 libboost-filesystem1.54.0 \ libboost-system1.54.0 libboost-regex1.54.0 libboost-thread1.54.0 \ libboost-context1.54.0 libgoogle-glog0 libevent-2.0-5 libjemalloc1 -sudo apt-get purge -y gcc g++ ragel autoconf \ +sudo apt-get -purge purge -y gcc g++ ragel autoconf \ git libtool python-dev libssl-dev libevent-dev \ binutils-dev make libdouble-conversion-dev libgflags-dev \ libgoogle-glog-dev libjemalloc-dev -sudo apt-get purge -y 'libboost.*-dev' +sudo apt-get --purge purge -y 'libboost.*-dev' sudo apt-get autoremove --purge -y sudo apt-get autoclean -y sudo apt-get clean -y From 14c14448778af64df309c1077ad2bdde0384a77f Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Mon, 2 Mar 2020 16:04:34 +0530 Subject: [PATCH 3/6] some apt-get tweaks By default, Ubuntu or Debian based "apt" or "apt-get" system installs recommended but not suggested packages . By passing "--no-install-recommends" option, the user lets apt-get know not to consider recommended packages as a dependency to install. This results in smaller downloads and installation of packages . Refer to blog at [Ubuntu Blog](https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends) . removing packages with "--purge" will clean the residual configurations of the packages. --- mcrouter/scripts/install_ubuntu_18.04.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mcrouter/scripts/install_ubuntu_18.04.sh b/mcrouter/scripts/install_ubuntu_18.04.sh index 0c67dd0d7..aafd834f9 100755 --- a/mcrouter/scripts/install_ubuntu_18.04.sh +++ b/mcrouter/scripts/install_ubuntu_18.04.sh @@ -14,7 +14,7 @@ TARGET="${2:-all}" sudo apt-get update # Note libzstd-dev is not available on stock Ubuntu 14.04 or 15.04. -sudo apt-get install -y \ +sudo apt-get --no-install-recommends install -y \ autoconf \ binutils-dev \ bison \ @@ -46,3 +46,9 @@ sudo apt-get install -y \ cd "$(dirname "$0")" || ( echo "cd fail"; exit 1 ) ./get_and_build_by_make.sh "Makefile_ubuntu-18.04" "$TARGET" "$BASE_DIR" + + +# Some Cleanup Up On the go +sudo apt-get clean + +sudo apt-get -y --purge autoremove From fea3837eac647c4b593304c32a59d7912b000e39 Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Mon, 2 Mar 2020 16:06:15 +0530 Subject: [PATCH 4/6] some apt-get tweaks By default, Ubuntu or Debian based "apt" or "apt-get" system installs recommended but not suggested packages . By passing "--no-install-recommends" option, the user lets apt-get know not to consider recommended packages as a dependency to install. This results in smaller downloads and installation of packages . Refer to blog at [Ubuntu Blog](https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends) . removing packages with "--purge" will clean the residual configurations of the packages. --- mcrouter/scripts/install_ubuntu_16.04.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mcrouter/scripts/install_ubuntu_16.04.sh b/mcrouter/scripts/install_ubuntu_16.04.sh index 8cf35e998..804f593eb 100755 --- a/mcrouter/scripts/install_ubuntu_16.04.sh +++ b/mcrouter/scripts/install_ubuntu_16.04.sh @@ -11,7 +11,7 @@ set -ex sudo apt-get update # Note libzstd-dev is not available on stock Ubuntu 14.04 or 15.04. -sudo apt-get install -y \ +sudo apt-get --no-install-recommends install -y \ autoconf \ binutils-dev \ bison \ @@ -43,3 +43,8 @@ sudo apt-get install -y \ cd "$(dirname "$0")" || ( echo "cd fail"; exit 1 ) ./get_and_build_everything.sh ubuntu-16.04 "$@" + +# Some Cleanup Up On the go +sudo apt-get clean + +sudo apt-get -y --purge autoremove From 8285929e7ba7592cf6d8e16430ea79b46d7b9d24 Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Mon, 2 Mar 2020 16:07:35 +0530 Subject: [PATCH 5/6] some apt-get tweaks By default, Ubuntu or Debian based "apt" or "apt-get" system installs recommended but not suggested packages . By passing "--no-install-recommends" option, the user lets apt-get know not to consider recommended packages as a dependency to install. This results in smaller downloads and installation of packages . Refer to blog at [Ubuntu Blog](https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends) . removing packages with "--purge" will clean the residual configurations of the packages. --- mcrouter/scripts/install_ubuntu_15.04.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mcrouter/scripts/install_ubuntu_15.04.sh b/mcrouter/scripts/install_ubuntu_15.04.sh index ca8389068..3258b58ae 100755 --- a/mcrouter/scripts/install_ubuntu_15.04.sh +++ b/mcrouter/scripts/install_ubuntu_15.04.sh @@ -10,7 +10,7 @@ set -ex sudo apt-get update -sudo apt-get install -y \ +sudo apt-get --no-install-recommends install -y \ autoconf \ binutils-dev \ bison \ @@ -41,3 +41,8 @@ sudo apt-get install -y \ cd "$(dirname "$0")" || ( echo "cd fail"; exit 1 ) ./get_and_build_everything.sh ubuntu-15.04 "$@" + +# Some Cleanup Up On the go +sudo apt-get clean + +sudo apt-get -y --purge autoremove From e6e945dabf5a0b91c481cb4789b03879c060e74b Mon Sep 17 00:00:00 2001 From: Pratik Raj Date: Mon, 2 Mar 2020 16:08:47 +0530 Subject: [PATCH 6/6] some apt-get tweaks By default, Ubuntu or Debian based "apt" or "apt-get" system installs recommended but not suggested packages . By passing "--no-install-recommends" option, the user lets apt-get know not to consider recommended packages as a dependency to install. This results in smaller downloads and installation of packages . Refer to blog at [Ubuntu Blog](https://ubuntu.com/blog/we-reduced-our-docker-images-by-60-with-no-install-recommends) . removing packages with "--purge" will clean the residual configurations of the packages. --- mcrouter/scripts/install_ubuntu_14.04.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/mcrouter/scripts/install_ubuntu_14.04.sh b/mcrouter/scripts/install_ubuntu_14.04.sh index 642ccebfe..b0c3d40c8 100755 --- a/mcrouter/scripts/install_ubuntu_14.04.sh +++ b/mcrouter/scripts/install_ubuntu_14.04.sh @@ -15,7 +15,7 @@ sudo add-apt-repository -y ppa:sickpig/boost sudo apt-get update -sudo apt-get install -y \ +sudo apt-get --no-install-recommends install -y \ autoconf \ binutils-dev \ bison \ @@ -58,3 +58,8 @@ export CC="gcc-5" export CXX="g++-5" ./get_and_build_everything.sh ubuntu-14.04 "$@" + +# Some Cleanup Up On the go +sudo apt-get clean + +sudo apt-get -y --purge autoremove