coreos-home-server/host/base/systemd/container-build@.service
Alex Palaistras d8a4b7874f 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.
2023-12-20 19:50:39 +00:00

16 lines
809 B
Desktop File

[Unit]
Description=Container Build for %I
Wants=network-online.target container-environment@%i.service container-network@internal.service container-build@%i.path
After=network-online.target container-environment@%i.service container-network@internal.service
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]
WantedBy=multi-user.target