docker build Gitlab CI/CD jobs Template
This documentation provides an overview and explanation of the GitLab CI/CD YAML template. The template defines a job named .build_docker_container
that builds a Docker container using the specified configuration.
Stage: build
This job builds a Docker container using the nofusscomputing/docker-buildx-qemu:dev
image and the docker:23-dind
service.
Variables
-
DOCKER_IMAGE_BUILD_NAME
: The name of the Docker image to be built ($CI_PROJECT_NAME
). -
DOCKER_IMAGE_BUILD_REGISTRY
: The registry where the Docker image will be pushed ($CI_REGISTRY_IMAGE
). -
DOCKER_IMAGE_BUILD_TAG
: The tag to be applied to the Docker image ($CI_COMMIT_SHA
).
Rules
-
Rule 1: The job runs if the pipeline is triggered by a git tag and a
dockerfile
ordockerfile.j2
file exists. -
Rule 2: The job runs if the pipeline is triggered by a push to the
development
branch and adockerfile
ordockerfile.j2
file exists. It also checks for changes in thedockerfile
,dockerfile.j2
, orincludes/
directory compared to themaster
branch. -
Rule 3: The job runs if the pipeline is triggered by a push to a branch other than
master
ordevelopment
and adockerfile
ordockerfile.j2
file exists. It also checks for changes in thedockerfile
,dockerfile.j2
, orincludes/
directory compared to thedevelopment
branch. -
Rule 4: The job never runs.
Script
The script performs the following steps:
-
Updates the binary formats and enables execution of other binary formats in the kernel.
-
Creates a Docker buildx builder and sets it as the active builder.
-
Builds a multi-arch Docker image if the
DOCKER_IMAGE_BUILD_TARGET_PLATFORMS
variable is specified. It applies labels to the image and pushes it to the specified registry. It also inspects the image and performs cleanup by removing additional unknown images from the container registry. -
Builds a Docker image if the
DOCKER_IMAGE_BUILD_TARGET_PLATFORMS
variable is not specified. It applies labels to the image and pushes it to the specified registry.
gitlab-ci.yml definition
.gitlab-ci.yml | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
|
About:
This page forms part of our Project Gitlab-CI.
Page Metadata
Version: ToDo: place files short git commit hereDate Created: 2023-06-10
Date Edited: 2023-09-02
Contribution:
Would You like to contribute to our Gitlab-CI project? You can assist in the following ways:
- Edit This Page If there is a mistake or a way you can improve it.
- Add a Page to the Manual if you would like to add an item to our manual
- Raise an Issue if there is something about this page you would like to improve, and git is unfamiliar to you.
ToDo: Add the page list of contributors