Docker

container

Alpine images: build deps in one layer

Install the build toolchain under a named virtual package, build, then remove that group, all in one RUN so the build deps never reach the final image layer.

RUN apk add --no-cache --virtual .builddeps build-base ... build deps ... \
    && ... build steps that need those deps ... \
    && apk del .builddeps

--virtual .builddeps tags everything installed in that call under one name, so apk del .builddeps drops the whole group afterwards. --no-cache fetches a fresh package index on the fly and keeps nothing in /var/cache/apk, which replaces the old --update plus rm -rf /var/cache/apk/* dance; passing --update as well is redundant. Keep it a single RUN: removing the deps in a later layer would not shrink the image, since each layer only adds.

Misc

Container ecosystem map: https://www.mindmeister.com/fr/389671722/open-container-ecosystem-formerly-docker-ecosystem

Related