From: W. Trevor King Date: Thu, 31 Jul 2014 03:15:23 +0000 (-0700) Subject: trim.sh: Remove build-only dependencies with --depclean X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=50da07cd71e77f15d60e558786537c281fdb99e0;p=dockerfile.git trim.sh: Remove build-only dependencies with --depclean Use '--with-bdeps=n' to tell Portage to ignore build-time dependencies (e.g. an ebuild's DEPEND). Only the runtime dependencies (an ebuild's RDEPEND and PDEPEND) are taken into acount when selecting packages required by @world. That lets us keep what we need to run the target application, but remove all the build tooling (including GCC), leaving a functional, lightweight image. --- diff --git a/trim.sh b/trim.sh index 1091a69..3a68a54 100755 --- a/trim.sh +++ b/trim.sh @@ -49,14 +49,12 @@ trim() #sys-apps/openrc (/sbin/rc) #sys-apps/net-tools (/bin/hostname) #sys-devel/gettext (/usr/bin/envsubst) - # unmerge GCC to break the GCC <-> libc dependency loop docker run -t --name "${CONTAINER}" \ -v "${PWD}/empty-system.py:/tmp/empty-system.py" \ "${IMAGE}" /bin/bash -c " /tmp/empty-system.py && emerge --noreplace app-shells/bash sys-apps/net-tools sys-apps/openrc sys-devel/gettext && - emerge --unmerge sys-devel/gcc && - emerge -v --depclean && + emerge -v --with-bdeps=n --depclean && rm -rf /usr/portage" || die "failed to create ${CONTAINER}" docker export "${CONTAINER}" | docker import - "${IMG}" ||