Files
zuul-jobs/roles/upload-docker-image/tasks/buildx.yaml
Clark Boylan 7739ecc0e4 Use network=host on docker buildx build
We are already creating a custom buildx builder with options set to use
host networking. However, there are reports that this isn't sufficient
to get builds working in all situations. It is reported that adding
--network=host to the build command itself does fix things. Considering
we already intend to use host networking (per the custom buildx builder
options) lets go ahead and set --network=host on build commands as well.

This upstream issue may be related:
  https://github.com/docker/buildx/issues/1688
to the problems that have been observed, but it doesn't seem to match
completely. Maybe upstream behaviors changed since this was origianlly
reported?

Change-Id: Ie8856cf49b86e89e2bc903033e7a20874b7c9f83
2025-09-05 10:00:34 -07:00

43 lines
1.7 KiB
YAML

- name: Set up siblings
include_tasks: siblings.yaml
- name: Upload tag to dockerhub
vars:
promote_tag_prefix: "{{ ('change_' + zuul.change) if (zuul.change is defined) else zuul.pipeline }}_"
# docker buildx doesn't have a separate push command, only the
# ability to push at the end of a build. We run build here with
# all the same arguments as in the buildx build tasks, so they
# should result in a noop build and just a push.
command: >-
docker buildx build {{ zj_image.path | default('.') }} -f {{ zj_image.dockerfile | default(docker_dockerfile) }}
--network=host
{% if zj_image.target | default(false) -%}
--target {{ zj_image.target }}
{% endif -%}
{% for build_arg in zj_image.build_args | default([]) -%}
--build-arg {{ build_arg }}
{% endfor -%}
{% if zj_image.siblings | default(false) -%}
--build-arg "ZUUL_SIBLINGS={{ zj_image.siblings | join(' ') }}"
{% endif -%}
{% for tag in zj_image.tags | default(['latest']) -%}
--tag {{ docker_registry | ternary(docker_registry + '/', '') }}{{ zj_image.repository }}:{{ upload_docker_image_promote | ternary(promote_tag_prefix, '') }}{{ tag }}
{% endfor -%}
{% for label in zj_image.labels | default([]) -%}
--label "{{ label }}"
{% endfor %}
{% if zuul.change | default(false) %}
--label "org.zuul-ci.change={{ zuul.change }}"
{% endif %}
--label "org.zuul-ci.change_url={{ zuul.change_url }}"
--platform={{ zj_image.arch | join(',') }}
--push
args:
chdir: "{{ zuul_work_dir }}/{{ zj_image.context }}"
environment:
DOCKER_CLI_EXPERIMENTAL: enabled
register: result
until: result.rc == 0
retries: 3
delay: 30