A compact docker image (32MB) enabling monorepo pipelines with Gitlab CI docker executors, cf.: awesome-inc/monorepo.gitlab containing docker
, docker-compose
, bash
, curl
and jq
.
This is probably for you if you are a fan of
Monorepos can still be quite a challenge for existing deployment platforms such as Jenkins or GitLab CI because simply building all projects in the monorepo on each commit just won't scale well. With monorepos you need to sort out what and when to build.
awesome-inc/monorepo.gitlab addresses how to do this for GitLab CI. It basically comes down to checking the git diff and only building projects that have been changed.
What this repository adds is a docker image and a recipe that can be used with Docker executors (instead of e.g. Shell executors).
Docker executors can be considered the default for GitLab CI. As a rule of thumb they are the probably the best choice, even if you have strong reasons for not moving to the cloud yet and want to self-host & maintain all your GitLab Runners yourself (which i certainly did in the past, cf.: riemers/ansible-gitlab-runner).
So here is the recipe to have a nice monorepo pipeline with GitLab CI all using Docker.
First, check you have enabled monorepo support for GitLab CI using awesome-inc/monorepo.gitlab.
Next, you need to enable the docker-in-docker executor. In your .gitlab-ci.yml
add
variables:
# cf.: https://docs.gitlab.com/ee/ci/docker/using_docker_build.html
DOCKER_HOST: tcp://docker:2375/
DOCKER_DRIVER: overlay2
services:
- docker:dind
Finally, use our docker image for building, e.g.
image:
name: awesomeinc/docker.gitlab.monorepo:0.1.0
entrypoint: [""] # force an empty entrypoint, cf.: https://gitlab.com/gitlab-org/gitlab-runner/issues/2692#workaround
A real life example on GitLab is e.g. mkoertgen/hello.docker-sonar.