Helper functions for building and delivering Deckhouse modules using Gitlab CI.
This repository contains code for Gitlab CI job templates that can be reused. The templates are located in the templates directory.
To connect a template, you need to add the following code to your .gitlab-ci.yml:
include:
- remote: 'https://raw.githubusercontent.com/deckhouse/modules-gitlab-ci/refs/heads/main/templates/Setup.gitlab-ci.yml'
- remote: 'https://raw.githubusercontent.com/deckhouse/modules-gitlab-ci/refs/heads/main/templates/Build.gitlab-ci.yml'
default:
tags:
- my-runner
Build:
extends: .buildInstead of
/main/, you can specify a specific commit to ensure changes do not affect your CI.
The examples folder contains examples of .gitlab-ci.yml that can be assembled from the templates.
In templates/multi-repo the CI workflow differs from basic CI (which in templates) in the following key aspects:
- In
multi-repoworkflow we can push todevandprodregistries separately with their own rules (seejobs/multi-repoand/orexamples/multi-repo-module.gitlab-ci.ymlfor example jobs). - All werf's caches and other artifacts (from
buildstage) are stored in Gitlab's module's registry by default. And only final images are pushed to the dev/prod registries. So, even in dev-registry there should be no "build-time garbage" and/or some "extra" images/layers for each module.
- [General] There is additional stage
lintbeforebuildandcleanupstage afterdeploy. - [General] All
onlysections (likeonly: [tags, branches]) replaced with correspondingrulessection. - [General] Added
Scheduled cleanupjob to cleanup Gitlab's registry by pipeline schedule - [General] Added
Auto cleanupjob to cleanup Gitlab's registry BEFOREbuildstage. Can be disabled viaAUTO_CLEANUP="false"variable. - [General] Added
.default_ruleshidden job (seetemplates/multi-repo/Setup.gitlab-ci.yml) for easy modification of this whole workflow. - [General] Added
.deploy-prod-ruleshidden job (seetemplates/multi-repo/Deploy.gitlab-ci.yml) for easy modification ofdeploy to productionworkflow. - [General] Added
jobs/multi-repojobs files which user can include and use in their own workflow. - [General] Added ability to specify which module's
EDITION(CE,EE, etc) should be pushed to PRODUCTION registry. - [Refactor] Default
before_scriptsection (seetemplates/Setup.gitlab-ci.yml) moved to.setup/before_scriptjob. - [Refactor]
dmt lintjob moved tolintstage in dedicatedtemplates/multi-repo/Lint.gitlab-ci.ymlfile. - [Refactor] All werf's caches and other artifacts (from
buildstage) are stored in Gitlab's registry (${CI_REGISTRY_IMAGE}/${MODULES_MODULE_NAME}) by default. - [Refactor] Images publishing (via
crane copy) and module's self-registration processes moved to dedicated hidden job.publish(seetemplates/multi-repo/Deploy.gitlab-ci.yml).
The templates now support signing of container images and ELF binaries within those images using werf's built-in signing capabilities.
- Image signing: Container image manifests are signed using certificates
- Binary signing: ELF binaries within images are signed using GPG keys
To enable signing, configure the following variables in your GitLab CI/CD project settings:
WERF_SIGN_CERT- Certificate for image signing (base64 encoded)WERF_SIGN_INTERMEDIATES- Intermediate certificates (base64 encoded)WERF_SIGN_KEY- Private key for signing (base64 encoded)VAULT_ROLE_ID- Vault role ID for accessing GPG keysVAULT_SECRET_ID- Vault secret ID for accessing GPG keysVAULT_ADDR- Vault URLWERF_ELF_PGP_PRIVATE_KEY_FINGERPRINT- GPG key fingerprint for binary signingWERF_ELF_PGP_PRIVATE_KEY_PASSPHRASE- GPG key passphrase
The signing is enabled by default when using the templates. The following environment variables are automatically configured:
WERF_SIGN_MANIFEST: "true" # Enable image manifest signing
WERF_BSIGN_ELF_FILES: "1" # Enable ELF binary signing
WERF_ANNOTATE_LAYERS_WITH_DM_VERITY_ROOT_HASH: "true" # Enable dm-verity annotations$MODULES_REGISTRY - base URL for the registry, e.g. registry.example.com
$MODULES_REGISTRY_PATH - path to modules repository in registry, e.g. deckhouse/modules
$MODULES_MODULE_NAME (Optional) - module name, by default it is equal to the project name
$RELEASE_CHANNEL - lowercase release channel name, e.g., alpha, stable, early-access