Make buildx builder image configurable

* Some users might want to override this in an environment where the
  builder images are managed
* This adds the same configuration to the `docker-` and `container-`
  jobs and roles. Converting between them should follow the same pattern
as with the other job/role vars.

Change-Id: I72fd59c36452e4520d077b645fb7627ba6a5443c
This commit is contained in:
Jan Gutter
2025-09-12 15:53:30 +01:00
parent ca4935d71c
commit f50d0b2248
8 changed files with 28 additions and 4 deletions

View File

@@ -223,4 +223,9 @@ entire container and upload it.
A dictionary of key value pairs to add to the container build environment. A dictionary of key value pairs to add to the container build environment.
This may be useful to enable buildkit with docker builds for example. This may be useful to enable buildkit with docker builds for example.
.. zuul:jobvar:: container_builder_image
:default: quay.io/opendevmirror/buildkit:buildx-stable-1
The image used to create buildx builders from.
.. _anchors: https://yaml.org/spec/1.2/spec.html#&%20anchor// .. _anchors: https://yaml.org/spec/1.2/spec.html#&%20anchor//

View File

@@ -77,4 +77,9 @@ used to supply the same data to all three jobs.
A list of tags to be added to the image when promoted. A list of tags to be added to the image when promoted.
.. zuul:jobvar:: docker_builder_image
:default: quay.io/opendevmirror/buildkit:buildx-stable-1
The image used to create buildx builders from.
.. _anchors: https://yaml.org/spec/1.2/spec.html#&%20anchor// .. _anchors: https://yaml.org/spec/1.2/spec.html#&%20anchor//

View File

@@ -270,6 +270,11 @@ promote job assumes `skopeo` is available on the executor.
A dictionary of key value pairs to add to the container build environment. A dictionary of key value pairs to add to the container build environment.
This may be useful to enable buildkit with docker builds for example. This may be useful to enable buildkit with docker builds for example.
.. zuul:rolevar:: container_builder_image
:default: quay.io/opendevmirror/buildkit:buildx-stable-1
The image used to create buildx builders from.
.. zuul:rolevar:: promote_container_image_method .. zuul:rolevar:: promote_container_image_method
:default: tag :default: tag

View File

@@ -1,3 +1,5 @@
zuul_work_dir: "{{ zuul.project.src_dir }}" zuul_work_dir: "{{ zuul.project.src_dir }}"
container_command: podman container_command: podman
container_build_extra_env: {} container_build_extra_env: {}
# synced with roles/build-docker-image/defaults/main.yaml
container_builder_image: quay.io/opendevmirror/buildkit:buildx-stable-1

View File

@@ -9,7 +9,7 @@
# step below. More info here: # step below. More info here:
# https://docs.docker.com/reference/cli/docker/buildx/create/#buildkitd-config # https://docs.docker.com/reference/cli/docker/buildx/create/#buildkitd-config
- name: Create builder - name: Create builder
command: "docker buildx create --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver=docker-container --driver-opt image=quay.io/opendevmirror/buildkit:buildx-stable-1 --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %}" command: "docker buildx create --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver=docker-container --driver-opt image={{ container_builder_image }} --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %}"
when: inventory_hostname == ansible_play_hosts[0] when: inventory_hostname == ansible_play_hosts[0]
- name: Add host key to known_hosts - name: Add host key to known_hosts
@@ -18,7 +18,7 @@
delegate_to: "{{ ansible_play_hosts[0] }}" delegate_to: "{{ ansible_play_hosts[0] }}"
- name: Append builders from other nodes - name: Append builders from other nodes
command: "docker buildx create --append --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver-opt image=quay.io/opendevmirror/buildkit:buildx-stable-1 --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %} ssh://{{ ansible_user }}@{{ ansible_host }}" command: "docker buildx create --append --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver-opt image={{ container_builder_image }} --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %} ssh://{{ ansible_user }}@{{ ansible_host }}"
when: inventory_hostname != ansible_play_hosts[0] when: inventory_hostname != ansible_play_hosts[0]
delegate_to: "{{ ansible_play_hosts[0] }}" delegate_to: "{{ ansible_play_hosts[0] }}"

View File

@@ -163,4 +163,9 @@ using this role.
``linux/ppc64le``, ``linux/s390x``, ``linux/386``, ``linux/ppc64le``, ``linux/s390x``, ``linux/386``,
``linux/arm/v7``, ``linux/arm/v6``. ``linux/arm/v7``, ``linux/arm/v6``.
.. zuul:rolevar:: docker_builder_image
:default: quay.io/opendevmirror/buildkit:buildx-stable-1
The image used to create buildx builders from.
.. _anchors: https://yaml.org/spec/1.2/spec.html#&%20anchor// .. _anchors: https://yaml.org/spec/1.2/spec.html#&%20anchor//

View File

@@ -2,3 +2,5 @@ zuul_work_dir: "{{ zuul.project.src_dir }}"
docker_dockerfile: "Dockerfile" docker_dockerfile: "Dockerfile"
docker_registry: '' docker_registry: ''
docker_use_buildkit: false docker_use_buildkit: false
# synced with roles/build-container-image/defaults/main.yaml
docker_builder_image: quay.io/opendevmirror/buildkit:buildx-stable-1

View File

@@ -11,7 +11,7 @@
# step below. More info here: # step below. More info here:
# https://docs.docker.com/reference/cli/docker/buildx/create/#buildkitd-config # https://docs.docker.com/reference/cli/docker/buildx/create/#buildkitd-config
- name: Create builder - name: Create builder
command: "docker buildx create --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver=docker-container --driver-opt image=quay.io/opendevmirror/buildkit:buildx-stable-1 --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %}" command: "docker buildx create --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver=docker-container --driver-opt image={{ docker_builder_image }} --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %}"
environment: environment:
DOCKER_CLI_EXPERIMENTAL: enabled DOCKER_CLI_EXPERIMENTAL: enabled
when: inventory_hostname == ansible_play_hosts[0] when: inventory_hostname == ansible_play_hosts[0]
@@ -22,7 +22,7 @@
delegate_to: "{{ ansible_play_hosts[0] }}" delegate_to: "{{ ansible_play_hosts[0] }}"
- name: Append builders from other nodes - name: Append builders from other nodes
command: "docker buildx create --append --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver=docker-container --driver-opt image=quay.io/opendevmirror/buildkit:buildx-stable-1 --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %} ssh://{{ ansible_user }}@{{ ansible_host }}" command: "docker buildx create --append --name mybuilder --node {{ inventory_hostname | replace('-', '_') }} --driver=docker-container --driver-opt image={{ docker_builder_image }} --driver-opt network=host{% if buildset_registry is defined %} --config /etc/buildkit/buildkitd.toml {% endif %} ssh://{{ ansible_user }}@{{ ansible_host }}"
environment: environment:
DOCKER_CLI_EXPERIMENTAL: enabled DOCKER_CLI_EXPERIMENTAL: enabled
when: inventory_hostname != ansible_play_hosts[0] when: inventory_hostname != ansible_play_hosts[0]