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).
This commit is contained in:
Olaf Meeuwissen 2017-08-19 12:43:16 +09:00
parent e4bd65c005
commit d92fe56e7b
3 changed files with 13 additions and 1 deletions

View File

@ -10,7 +10,7 @@ docker run --rm --cap-add SYS_ADMIN \
--volume $PWD:/devuan --workdir /devuan \ --volume $PWD:/devuan --workdir /devuan \
"$CI_REGISTRY_IMAGE"/migrated ./bootstrap.sh "$CI_REGISTRY_IMAGE"/migrated ./bootstrap.sh
version="$DEVUAN_VERSION"-$(date +%F) 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 push "$CI_REGISTRY_IMAGE":"$version"
docker tag "$CI_REGISTRY_IMAGE":"$version" "$CI_REGISTRY_IMAGE":"$DEVUAN_VERSION" docker tag "$CI_REGISTRY_IMAGE":"$version" "$CI_REGISTRY_IMAGE":"$DEVUAN_VERSION"
docker push "$CI_REGISTRY_IMAGE":"$DEVUAN_VERSION" docker push "$CI_REGISTRY_IMAGE":"$DEVUAN_VERSION"

View File

@ -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

View File

@ -38,4 +38,6 @@ Acquire::Languages "none";
EOF EOF
chmod 0644 $cfg/docker-translations chmod 0644 $cfg/docker-translations
rm -f $cfg/*autoremove-kernels || true
rm $0 rm $0