From d92fe56e7beeeac9b6166c7ad7617c6fe34ccd5f Mon Sep 17 00:00:00 2001 From: Olaf Meeuwissen Date: Sat, 19 Aug 2017 12:43:16 +0900 Subject: [PATCH] Remove unneeded files from the image Keeping out the `/dev/` tree is done when tarring things up so that the `bootstrap.sh` script will have access to devices at run-time. This approach also protects against removing devices that have been mounted into the chroot, if any (e.g. devpts). --- build.sh | 2 +- scripts/remove-unneeded-files | 10 ++++++++++ scripts/tweak-apt-config | 2 ++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 scripts/remove-unneeded-files diff --git a/build.sh b/build.sh index 81cadde..75508f9 100755 --- a/build.sh +++ b/build.sh @@ -10,7 +10,7 @@ docker run --rm --cap-add SYS_ADMIN \ --volume $PWD:/devuan --workdir /devuan \ "$CI_REGISTRY_IMAGE"/migrated ./bootstrap.sh version="$DEVUAN_VERSION"-$(date +%F) -(tar -cC rootfs . | docker import - "$CI_REGISTRY_IMAGE":"$version") +(tar -cC rootfs --exclude './dev/**' . | docker import - "$CI_REGISTRY_IMAGE":"$version") docker push "$CI_REGISTRY_IMAGE":"$version" docker tag "$CI_REGISTRY_IMAGE":"$version" "$CI_REGISTRY_IMAGE":"$DEVUAN_VERSION" docker push "$CI_REGISTRY_IMAGE":"$DEVUAN_VERSION" diff --git a/scripts/remove-unneeded-files b/scripts/remove-unneeded-files new file mode 100644 index 0000000..1106a5f --- /dev/null +++ b/scripts/remove-unneeded-files @@ -0,0 +1,10 @@ +#!/bin/sh -eu +# remove-unneeded-files -- for a smaller Docker image +# Copyright (C) 2017 Olaf Meeuwissen +# +# License: GPL-3.0+ + +find /var/log -name '*.log' -delete +rm -f /var/cache/ldconfig/aux-cache || true + +rm $0 diff --git a/scripts/tweak-apt-config b/scripts/tweak-apt-config index cab2238..424a6ed 100755 --- a/scripts/tweak-apt-config +++ b/scripts/tweak-apt-config @@ -38,4 +38,6 @@ Acquire::Languages "none"; EOF chmod 0644 $cfg/docker-translations +rm -f $cfg/*autoremove-kernels || true + rm $0