Build docker image based on asdf
What does this Merge Request do?
The problem: We want to rebuild the image, if the Dockerfile
,
.tool-versions
or packages.txt
change. Unfortunately that isn't possible
to do that in GitLab CI, because we cannot set a variable based on the
contents of files. That is why we use this algorithm:
Check if a docker image for our branch exists, e.g.
base_name/branch-name:latest
. If it exists, we pull it and compare the
dependencySHA label on it to the shasum of the Dockerfile
, packages.txt
and .tools-versions
. If the label matches the shasum, we do not build
the image.
Otherwise, we check if a caching image, e.g.
base_name/asdf-cache:$dependencySHA
exists. If it exists, we pull it
and push it under the base_name/branch-name:latest
. This operation is
rather space-efficient, as the existing layers will be re-used.
It also allows us to re-use images across branches if the dependencies
didn't change.
If none of the above allows us to use a cached image, we will build one.
Merge Request checklist
-
Tests added for new functionality. If not, please raise Issue to follow-up. -
This change is backward compatible. If not, please include steps to communicate to our users. -
Documentation added/updated, if needed. -
gdk doctor
test added, if needed.