docker-mailserver/.github
Brennan Kinney 21fbbfabe1
ci: Better build caching for CI (#2742)
* ci: Cache builds by splitting into two jobs

For the cache to work properly, we need to derive a cache key from the build context (files that affect the Dockerfile build) instead of the cache key changing by commit SHA.

We also need to avoid a test suite failure from preventing the caching of a build, thus splitting into separate jobs.

This first attempt used `upload-artifact` and `download-artifact` to transfer the built image, but it has quite a bit of overhead and prevented multi-platform build (without complicating the workflow further).

* ci: Transfer to dependent job via cache only

While `download-artifact` + `docker load` is a little faster than rebuilding the image from cached layers, `upload-artifact` takes about 2 minutes to upload the AMD64 (330MB) tar image export (likely due to compression during upload?).

The `actions/cache` approach however does not incur that hit and is very quick (<10 secs) to complete it's post upload work. The dependent job still gets a cache-hit, and the build job is able to properly support multi-platform builds.

Added additional notes about timing and size of including ARM builds.

* ci: Move Dockerfile ARG to end of build

When the ARG changes due to commit SHA, it invalidates all cache due to the LABEL layers at the start. Then any RUN layers implicitly invalidate, even when the ARG is not used.

Introduced basic multi-stage build, and relocated the container config / metadata to the end of the build. This avoids invalidating expensive caching layers (size and build time) needlessly.
2022-08-28 11:42:42 +12:00
..
ISSUE_TEMPLATE scripts: remove DMS_DEBUG (#2523) 2022-04-03 13:29:10 +02:00
workflows ci: Better build caching for CI (#2742) 2022-08-28 11:42:42 +12:00
dependabot.yml Added docker to dependabot.yml config (#2316) 2021-12-11 09:58:17 +01:00
FUNDING.yml create .github/FUNDING.yml (#2512) 2022-04-02 15:56:29 +02:00
pull_request_template.md chore(docs): outsourcing environment vars to the documentation (#1948) 2021-05-11 22:15:34 +12:00