Category: Docker, gitlab

So, we have: See that apk add … It installs tools essential for your building process, but it takes time every time the job is executed.

One way to optimize this is to build custom image: we have that image: alpine:latest, and then apk add … why not combine all of that into a Dockerfile: Now, we have full GitLab up and running, and we can use it to build that Dockerfile into nice image, automatically: At this point first build of the custom image probably has passed, and you can find resulting artifact in Docker registry tagged as latest: in Packages & Registries (left-side menu) you should be able to find one registry for your builder project, and there should be two tags that point to the same image, one equals to git commit hash, the other one is latest.

Now we can modify.gitlab-ci.yml: So, all required tools are baked into automatically built image hosted on the same GitLab server, and that should decrease build time by fair amount.

Related Articles