Skip to main content

Monorepo Pipeline Template

The docker-monorepo.yml pipeline template builds and deploys several applications that live in one repository. Everything else (branches, versions, environments, Argo CD) works as in docker.yml.

Monorepo or multirepo​

Multirepo (default)Monorepo
Repositoryone applicationseveral applications (e.g. api, web, worker)
Pipeline templatenode.yml, docker.yml, ...docker-monorepo.yml
Images$CI_REGISTRY_IMAGE:<version>$CI_REGISTRY_IMAGE/<app>:<version>
Tenant values.image.tag.apps.<app>.image.tag
Helm chartnode, app, craft, ...apps
Argo CDone Applicationone Application for all the apps

Use the monorepo template when the applications share code and are released together (one release/x.y.z for all of them). If an application has its own lifecycle and its own team, keep it in its own repository.

Usage​

.gitlab-ci.yml:

include:
- project: 'welance/platform/pipelines/templates/pipeline/git-flow'
ref: release/1.2.0
file: 'docker-monorepo.yml'
variables:
PROJECT_ID: 'r001-11'

welance.yaml at the root of the repository lists the applications:

apps:
api:
target: api-runtime # Dockerfile target (optional)
web:
context: apps/web # default .
dockerfile: apps/web/Dockerfile # default <context>/Dockerfile
tools:
target: tools-runtime
deploy: false # built and pushed, not deployed

The manifest is the only place where the applications are declared: the pipeline reads it, the .gitlab-ci.yml stays an include. Set WELANCE_MANIFEST to use a different path.

What the pipeline does​

  1. build (ci-jobs/build/docker-build-apps.yml): one docker buildx build per application, pushed as $CI_REGISTRY_IMAGE/<app>:<version>, with a BuildKit layer cache in the registry ($CI_REGISTRY_IMAGE/cache:<app>), so multi-stage builds only rebuild the layers that changed.
  2. deploy (ci-jobs/deploy/gitops-apps-and-value-sync.yml): in the tenant values.yaml it writes .apps.<app>.image.tag for every application without deploy: false and .image.commit.* once, writes env.yaml from the environment file, commits and syncs the Argo CD Application.
  3. release: as in the other templates.

Every application gets its own tag key, so each Deployment only ever runs its own image. Today all the applications of a pipeline share the same version.

Tenant​

The tenant uses the apps chart: one Application, one values.yaml with an entry per application under apps.