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
79 lines
3.1 KiB
YAML
79 lines
3.1 KiB
YAML
- name: Validate zj_image.repository is full "url"
|
|
when:
|
|
- "'/' not in zj_image.repository"
|
|
fail:
|
|
msg: "{{ zj_image.repository }} must be a full container image url including registry location"
|
|
|
|
- name: Set container filename arg
|
|
set_fact:
|
|
containerfile: "{{ zj_image.container_filename | default(container_filename) | default('') }}"
|
|
|
|
- name: Set up siblings
|
|
include_tasks: siblings.yaml
|
|
|
|
# The command below always tags the images for the temp_registry (so
|
|
# they can be pulled back onto the host image cache), and also tags
|
|
# them for the buildset registry if one is present.
|
|
- name: Set base docker build command
|
|
set_fact:
|
|
docker_buildx_command: >-
|
|
docker buildx build {{ zj_image.path | default('.') }}
|
|
{% if containerfile %}-f {{ containerfile }}{% endif %}
|
|
--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 {{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ tag }}
|
|
{% if buildset_registry | default(false) -%}
|
|
--tag {{ buildset_registry_alias }}:{{ buildset_registry.port }}/{{ zj_image.repository }}:{{ tag }}
|
|
{% endif -%}
|
|
{% 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 }}"
|
|
|
|
- name: Build and push images for all arches
|
|
command: "{{ docker_buildx_command }} {% if _multiarch %}--platform={{ zj_image.arch | join(',') }}{% endif %} --push"
|
|
args:
|
|
chdir: "{{ zuul_work_dir }}/{{ zj_image.context }}"
|
|
|
|
- name: Pull images from temporary registry
|
|
command: >-
|
|
docker pull {{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ zj_image_tag }}
|
|
loop: "{{ zj_image.tags | default(['latest']) }}"
|
|
loop_control:
|
|
loop_var: zj_image_tag
|
|
|
|
- name: Locally tag for changes so push works later
|
|
command: >-
|
|
docker tag
|
|
{{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ zj_image_tag }}
|
|
{{ zj_image.repository }}:change_{{ zuul.change }}_{{ zj_image_tag }}
|
|
loop: "{{ zj_image.tags | default(['latest']) }}"
|
|
loop_control:
|
|
loop_var: zj_image_tag
|
|
when: zuul.change | default(false)
|
|
|
|
- name: Locally tag for changes so push works later
|
|
command: >-
|
|
docker tag
|
|
{{ temp_registry.host }}:{{ temp_registry.port }}/{{ zj_image.repository }}:{{ zj_image_tag }}
|
|
{{ zj_image.repository }}:{{ zj_image_tag }}
|
|
loop: "{{ zj_image.tags | default(['latest']) }}"
|
|
loop_control:
|
|
loop_var: zj_image_tag
|
|
|
|
- name: Cleanup sibling source directory
|
|
include_tasks: clean-siblings.yaml
|