From d1a2dfa6f554ff8028906d4da4a7a0a79960f87d Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Mon, 14 Jan 2019 21:53:06 +0000 Subject: [PATCH] Add support for per-image build-arg settings Change-Id: Ia14397389be0c7178c1879844cd675a3d291a3d0 --- .zuul.yaml | 4 ++++ docker/gitea/Dockerfile | 2 +- playbooks/zuul/build-image/run.yaml | 10 +++++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/.zuul.yaml b/.zuul.yaml index a8c2354920..306bf64719 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -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 diff --git a/docker/gitea/Dockerfile b/docker/gitea/Dockerfile index 344b44301d..21e1b22284 100644 --- a/docker/gitea/Dockerfile +++ b/docker/gitea/Dockerfile @@ -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..... diff --git a/playbooks/zuul/build-image/run.yaml b/playbooks/zuul/build-image/run.yaml index 02b62dc1bf..bfa6e7250d 100644 --- a/playbooks/zuul/build-image/run.yaml +++ b/playbooks/zuul/build-image/run.yaml @@ -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 }}"