When you build from a Dockerfile, it runs in a given "context"; that is the directory the Dockerfile is in and the directories below it. It can not access anything outside that context during the build. When building a container for a project in the gate, you may wish to install sibling projects that Zuul has checked-out into your container (i.e. so that Depends-On works). As mentioned, because /home/zuul/src/<project> is not in the context of the current project, you will not be able to access this source code during the container build. So to help facilitate dependencies, add a siblings: tag which can copy some or all of the required-projects already specified for the job into a special sub-directory of the current source. Because all the code is now in the same context, this will allow build scripts to be written that look for directories in .zuul-siblings and can install the source code from there. To further help the scripts, the ZUUL_SIBLINGS arg is set for the docker build giving the copied paths. The test is updated with some paths to test the copy. Change-Id: I079d823e7194e15b1b496aea0f53f70f6b563f02
4.6 KiB
This is one of a collection of roles which are designed to work together to build, upload, and promote docker images in a gating context:
- :zuul
build-docker-image
: Build the images. - :zuul
upload-docker-image
: Stage the images on dockerhub. - :zuul
promote-docker-image
: Promote previously uploaded images.
The :zuulbuild-docker-image
role is designed to be used in
check and gate pipelines and simply builds the images. It
can be used to verify that the build functions, or it can be followed by
the use of subsequent roles to upload the images to Docker Hub.
The :zuulupload-docker-image
role uploads the images to Docker
Hub, but only with a single tag corresponding to the change ID. This
role is designed to be used in a job in a gate pipeline so that the build produced by the
gate is staged and can later be promoted to production if the change is
successful.
The :zuulpromote-docker-image
role is designed to be used in a
promote pipeline. It requires no nodes
and runs very quickly on the Zuul executor. It simply re-tags a
previously uploaded image for a change with whatever tags are supplied
by :zuulbuild-docker-image.docker_images.tags
. It also
removes the change ID tag from the repository in Docker Hub, and removes
any similar change ID tags more than 24 hours old. This keeps the
repository tidy in the case that gated changes fail to merge after
uploading their staged images.
They all accept the same input data, principally a list of dictionaries representing the images to build. YAML anchors can be used to supply the same data to all three jobs.
Use the :zuulinstall-docker
role to install Docker before using
this role.
Role Variables