I am running self-hosted GitLab CE with a GitLab-runner and a Docker executor. I want to build a binary for AWS Lambda, so I'm using the amazonlinux:latest image for my Docker executor.
Of course, not all packages that I need for building are available in the base amazonlinux image, so I install them via yum. Unfortunately, cmake is not available for Amazon Linux, so I build it from source.
At the moment, this takes place every time the pipeline runs, which is not optimal because cmake takes a relatively long time to build (compared to the binary I actually want to build).
My general question is: is there a clean and reproducible way to prepare an image for building, which is then used as base image for GitLab CI? Since I'm relatively new to Docker and friends, is the correct way to go to create an image locally on the runner host and use that in my gitlab-ci.yml? Or should I put it in a registry (probably even GitLab's own container registry?)