Skip to content. | Skip to navigation

Navigation

You are here: Home / Support / Guides / Tools / Kubernetes / CI Build Image

Personal tools

CI Build Image

In a moment we're going to hook ourselves into our self-hosted GitLab's CI.

The thing we want to CI is an old-school C program, Idio, where we want to run make and use a C compiler. Of course, whilst getting an operating system image, say, Ubuntu, is easy enough, there's no other obvious candidates for one with a C build environment.

If our CI naively says apt-get install -y build-essentials, say, then that is going to happen four times (we'll get to that) for each commit. Poor show.

So we need a CI build image and we have a handy private docker registry to put it in.

Components

build-essentials has most of the build utilities we need though it also has a large number of "recommends." So we can cut them out.

The test suite uses both expect and lsof.

The CI also runs some code coverage which requires gcovr and dependencies. It only does this so that GitLab can report on the code coverage percentage.

Dockerfile

FROM ubuntu:20.04
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yq --no-install-recommends git build-essential expect lsof gcovr && rm -rf /var/lib/apt/lists/*
RUN useradd -d /home/idio -m idio
USER idio
WORKDIR /home/idio

We need to set DEBIAN_FRONTEND because -y is not enough.

Someone somewhere recommended removing the accumulated apt data.

In doing this I also discovered why some of the tests had been failing when run in another Docker guise. They were being run as root so several permissions tests were failing.

Hence the creation of a user and a change to that user's home directory to kick things off.

Docker

Obviously we need the same mechanism we used previously to get the built image into our private repository:

# docker build -t idio-ci-image .

# docker image tag idio-ci-image:latest docker-registry:5000/idio-ci-image:latest

# docker push docker-registry:5000/idio-ci-image:latest

Document Actions