From 700f1957064c29da167d099b1b109f2d8c3e4850 Mon Sep 17 00:00:00 2001 From: Monty Taylor Date: Sat, 12 Jan 2019 17:30:14 +0000 Subject: [PATCH] Add support for passing path to docker build If we clone gerrit to ~/src/gerrit.googlesource.com/gerrit but want to keep the Dockerfile in system-config, then we need to be able to run: docker build ~/src/gerrit.googlesource.com/gerrit -f Dockerfile Most of the time the dir will just be '.', so put in a sensible default. Change-Id: I235080c05e679d2ac270cd5401b85c655fab3112 --- .zuul.yaml | 6 ++++++ playbooks/zuul/build-image/run.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.zuul.yaml b/.zuul.yaml index f20329b7b6..a8c2354920 100644 --- a/.zuul.yaml +++ b/.zuul.yaml @@ -63,6 +63,12 @@ uploaded (it will be tagged with this in the local registry). + .. zuul:jobvar:: path + + Optional; if supplied, the directory that should be passed to + docker build. Useful for building images with a Dockerfile + in the context directory but a source repository elsewhere. + abstract: true pre-run: playbooks/zuul/build-image/pre.yaml run: playbooks/zuul/build-image/run.yaml diff --git a/playbooks/zuul/build-image/run.yaml b/playbooks/zuul/build-image/run.yaml index afe1b1e2d8..02b62dc1bf 100644 --- a/playbooks/zuul/build-image/run.yaml +++ b/playbooks/zuul/build-image/run.yaml @@ -1,7 +1,7 @@ - hosts: all tasks: - name: Build a docker image - command: "docker build . {{ target | default(false) | ternary('--target ', '') }}{{ target | default('') }} --tag {{ item.repository }}:change_{{ zuul.change }}" + command: "docker build {{ item.path | default('.') }} -f Dockerfile {{ target | default(false) | ternary('--target ', '') }}{{ target | default('') }} --tag {{ item.repository }}:change_{{ zuul.change }}" args: chdir: "{{ zuul.project.src_dir }}/{{ item.context }}" loop: "{{ images }}"