Add support for per-image build-arg settings

Change-Id: Ia14397389be0c7178c1879844cd675a3d291a3d0
This commit is contained in:
Monty Taylor 2019-01-14 21:53:06 +00:00 committed by James E. Blair
parent b0731b9840
commit d1a2dfa6f5
3 changed files with 14 additions and 2 deletions

View File

@ -69,6 +69,10 @@
docker build. Useful for building images with a Dockerfile
in the context directory but a source repository elsewhere.
.. zuul:jobvar:: build_args
Optional; if supplied, a list of values to pass to the docker
``--build-arg`` parameter.
abstract: true
pre-run: playbooks/zuul/build-image/pre.yaml
run: playbooks/zuul/build-image/run.yaml

View File

@ -112,4 +112,4 @@ EXPOSE 22
VOLUME ["/data"]
ENTRYPOINT ["/usr/bin/entrypoint"]
CMD ["/usr/sbin/sshd", "-D"]
# this comment is here to perform a test run of the job....
# this comment is here to perform a test run of the job.....

View File

@ -1,7 +1,15 @@
- hosts: all
tasks:
- name: Build a docker image
command: "docker build {{ item.path | default('.') }} -f Dockerfile {{ target | default(false) | ternary('--target ', '') }}{{ target | default('') }} --tag {{ item.repository }}:change_{{ zuul.change }}"
command: >-
docker build {{ item.path | default('.') }} -f Dockerfile
{% if target | default(false) -%}
--target {{ target }}
{% endif -%}
{% for build_arg in item.build_args | default([]) -%}
--build-arg {{ build_arg }}
{% endfor -%}
--tag {{ item.repository }}:change_{{ zuul.change }}
args:
chdir: "{{ zuul.project.src_dir }}/{{ item.context }}"
loop: "{{ images }}"