Skip container builds unless local files changed

This commit adds an `ExecCondition` directive on the `container-build@`
service, used as a pre-requisite for all other Podman-based services,
skipping `podman build` invocations unless local `Containerfile` or any
files in the `container` sub-directories have changed.

Container builds are responsible for the majority of time taken during
boot, even with cache in place; this will help alleviate pressure and
hopefully speed up boot considerably.
This commit is contained in:
Alex Palaistras 2023-12-20 19:19:58 +00:00
parent 8e408413a1
commit d8a4b7874f
1 changed files with 2 additions and 0 deletions

View File

@ -7,6 +7,8 @@ ConditionPathExists=%E/coreos-home-server/%i/Containerfile
[Service]
Type=oneshot
SyslogIdentifier=%N
Environment=PODMAN_BUILD_OPTIONS=
ExecCondition=/bin/sh -c 'test -z "$(podman image list --quiet --filter until!="$(find %E/coreos-home-server/%i/{Containerfile,container} -type f -printf "%%T@\n" | sort -n | tail -1)" --filter reference=localhost/%i)"; exit $?'
ExecStart=/bin/podman build $PODMAN_BUILD_OPTIONS --file %E/coreos-home-server/%i/Containerfile --tag localhost/%i:latest %E/coreos-home-server/%i
[Install]