summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean-Philippe Evrard <jean-philippe@evrard.me>2019-01-24 11:28:02 +0100
committerJean-Philippe Evrard <jean-philippe@evrard.me>2019-01-26 08:26:06 +0000
commit0e50a2bb89525874c6f12b458356a5f6feff78c2 (patch)
treec5c915e56d030b3f88f60d89f41ae6c6ec9c0a8c
parentcaebca1387f0ec1bbf218ee963381169856a36c4 (diff)
Allow different filenames for Dockerfiles
In certain build projects, multiple Dockerfiles exist (for example, one per distro) to simplify reading. However, this role is hardwired to use dockerfiles only named "Dockerfile". This is a problem, as you can't override the filename neither per image, or globally. This should fix the problem, allowing certain images to be build by providing the dockerfile argument in docker_images, but also have a globally overridable flag if you are using a different convention (for example Dockerfile.distro_minordistroversion). Change-Id: I075c365bc9f4f85f9ada832d22d1f1e213e68e21
Notes
Notes (review): Code-Review+1: Tobias Henkel <tobias.henkel@bmw.de> Code-Review+2: Clint 'SpamapS' Byrum <clint@fewbar.com> Code-Review+2: Andreas Jaeger <jaegerandi@gmail.com> Workflow+1: Andreas Jaeger <jaegerandi@gmail.com> Verified+2: Zuul Submitted-by: Zuul Submitted-at: Fri, 01 Feb 2019 07:58:04 +0000 Reviewed-on: https://review.openstack.org/632979 Project: openstack-infra/zuul-jobs Branch: refs/heads/master
-rw-r--r--roles/build-docker-image/common.rst15
-rw-r--r--roles/build-docker-image/defaults/main.yaml1
-rw-r--r--roles/build-docker-image/tasks/main.yaml2
3 files changed, 17 insertions, 1 deletions
diff --git a/roles/build-docker-image/common.rst b/roles/build-docker-image/common.rst
index affb19f..95d37ad 100644
--- a/roles/build-docker-image/common.rst
+++ b/roles/build-docker-image/common.rst
@@ -42,6 +42,15 @@ using this role.
42 The project directory. Serves as the base for 42 The project directory. Serves as the base for
43 :zuul:rolevar:`build-docker-image.docker_images.context`. 43 :zuul:rolevar:`build-docker-image.docker_images.context`.
44 44
45.. zuul:rolevar:: docker_dockerfile
46 :default: Dockerfile
47
48 The default Dockerfile name to use. Serves as the base for
49 :zuul:rolevar:`build-docker-image.docker_images.dockerfile`.
50 This allows a global overriding of Dockerfile name, for example
51 when building all images from different folders with similarily
52 named dockerfiles.
53
45.. zuul:rolevar:: docker_credentials 54.. zuul:rolevar:: docker_credentials
46 :type: dict 55 :type: dict
47 56
@@ -75,6 +84,12 @@ using this role.
75 The docker build context; this should be a directory underneath 84 The docker build context; this should be a directory underneath
76 :zuul:rolevar:`build-docker-image.zuul_work_dir`. 85 :zuul:rolevar:`build-docker-image.zuul_work_dir`.
77 86
87 .. zuul:rolevar:: dockerfile
88
89 The filename of the dockerfile, present in the context folder,
90 used for building the image. Provide this if you are using
91 a non-standard filename for a specific image.
92
78 .. zuul:rolevar:: repository 93 .. zuul:rolevar:: repository
79 94
80 The name of the target repository in dockerhub for the 95 The name of the target repository in dockerhub for the
diff --git a/roles/build-docker-image/defaults/main.yaml b/roles/build-docker-image/defaults/main.yaml
index 9739eb1..d702500 100644
--- a/roles/build-docker-image/defaults/main.yaml
+++ b/roles/build-docker-image/defaults/main.yaml
@@ -1 +1,2 @@
1zuul_work_dir: "{{ zuul.project.src_dir }}" 1zuul_work_dir: "{{ zuul.project.src_dir }}"
2docker_dockerfile: "Dockerfile"
diff --git a/roles/build-docker-image/tasks/main.yaml b/roles/build-docker-image/tasks/main.yaml
index 5b8fe61..653dc54 100644
--- a/roles/build-docker-image/tasks/main.yaml
+++ b/roles/build-docker-image/tasks/main.yaml
@@ -1,6 +1,6 @@
1- name: Build a docker image 1- name: Build a docker image
2 command: >- 2 command: >-
3 docker build {{ item.path | default('.') }} -f Dockerfile 3 docker build {{ item.path | default('.') }} -f {{ item.dockerfile | default(docker_dockerfile) }}
4 {% if item.target | default(false) -%} 4 {% if item.target | default(false) -%}
5 --target {{ item.target }} 5 --target {{ item.target }}
6 {% endif -%} 6 {% endif -%}