RTFM: docker-pkg edition

2020-03-10 09:56:54 +0100 +0100

In today’s edition of RTFM…

I’ve been working on building Docker images to use with MediaWiki’s docker-compose development environment. We don’t use standard Dockerfiles and docker build commands, instead we use an in-house tool called docker-pkg, which uses Jinja for additional templating.

So, while working on these images, for months now I’ve been running commands like docker-pkg -c dockerfiles/config.yaml build --no-pull --select '*stretch-php72-fpm-apache2*' dockerfiles and then doing something else while the image builds, because unlike docker build the layers of the image are not cached.

Yesterday I wanted to tighten the feedback loop while working on phab:T223643 to create an EventLogging image, so I started looking at how I could use the Docker build cache. While not mentioned on the documentation page, sure enough, hiding in plain text:

docker-pkg build --help
usage: docker-pkg build [-h] [--nightly | --snapshot] [--use-cache]
                        [--no-pull] [--select GLOB]

optional arguments:
  -h, --help     show this help message and exit

options for docker build:
  --use-cache    Do use Docker cache when building the images
  --no-pull      Do not attempt to pull a newer version of the images
  --select GLOB  A glob pattern for the images to build, must match name:tag

And so, with --use-cache adjusting the ENTRYPOINT command for that EventLogging image took a few seconds instead of minutes.

While kind of embarrassing to admit I missed this option, some lessons for me are: