Commit Graph

6 Commits (93da924aab96ea496cefb35df53913e1f291d90d)

Author SHA1 Message Date
Dustin 93da924aab buildContainerImage2: Handle names with slashes
If the provided container image name includes a `/` character, the build
will fail when copying the OCI image to a tarball:

> + buildah push git.pyrocufflink.net/containerimages/build/selinux:dev-ci oci-archive:/home/jenkins/agent/workspace/ainerImages_build.selinux_dev_ci/build/selinux-amd64.tar
> Error: lstat /home/jenkins/agent/workspace/ainerImages_build.selinux_dev_ci/build: no such file or directory

To resolve this, we need to escape the image name when constructing the
path to the tar file.
2023-10-24 18:34:11 -05:00
Dustin 96f4e59cbc buildContainerImage2: Support multiarch OCI images
The `buildContainerImage2` function is an improvement on the existing
`buildContainerImage` function, with a couple of enhancements.
Primarily, it supports building images for multiple architectures.  For
each listed architecture, a pod is launched on a matching worker node to
build the image natively.  The image is exported to an OCI archive and
"stashed" in the Jenkins workspace.  After images for all architectures
are built, another pod is launched and all of the stashed archives are
copied there and assembled into a manifest list.  Finally, the manifest
list is published to the OCI repository as usual, creating tags for the
Git branch and build number.

In addition to adding support for multiarch images, the
`buildContainerImage2` performs image builds in *unprivileged* pods.
Whereas the old function performed builds in a rootful container, the
new one configures requests pods with unique user namespaces.  The build
runs as *root* in the container, but that user is mapped to an arbitrary
unprivileged user on the host.
2023-10-05 22:12:09 -05:00
Dustin 356d9ecc1d buildContainerImage: Handle null arguments
If the `buildContainerImage` method is called without passing any
arguments at all, the `args` object will be `null`.  Attempting to
access the properties of it in that case raises a
`NullPointerException`.  Fortunately, Groovy has a `?` operator that
returns `null` when the named object is `null` and avoids accessing its
properties.
2022-12-01 20:06:59 -06:00
Dustin 579a42a5f0 Support selecting build architecture
The `buildContainerImage` method now supports an optional `arch` keyword
argument.  This argument can be used to select the architecture of the
node running the pod building the container image.  If unspecified, it
defaults to `amd64`.
2022-11-27 17:30:52 -06:00
Dustin b6f57b7c1a buildContainerImage: Allow passing arguments
The `registry`, `project`, `name`, and `tag` values can now be passed as
keyword arguments to the `buildContainerImage` function.  This will
allow jobs to override the default values if necessary.
2022-11-25 17:01:12 -06:00
Dustin fad319c83b Initial commit 2022-11-06 21:36:25 -06:00