What is .build-deps for apk add --virtual command?

Viewed 71767

What is .build-deps in the following command? I can't find an explanation in the Alpine docs. Is this a file that is predefined? Is see this referenced in many Dockerfiles.

RUN apk add --no-cache --virtual .build-deps \
gcc \
freetype-dev \
musl-dev

RUN pip install --no-cache-dir <packages_that_require_gcc...> \

RUN apk del .build-deps
2 Answers

.build-deps is an arbitrary name to call a "virtual package" in Alpine, where you will add packages.

It creates an extra 'world' of packages, that you will need for a limited period of time (e.g. compilers for building other things).

Its main purpose is to keep your image as lean and light as possible, because you can easily get rid of it once those packages were used.

Please remember that it should be included in the same RUN if you want to achieve the main purpose of lightweight.

Related