diff --git a/roles/build-docker-image/common.rst b/roles/build-docker-image/common.rst index affb19fc4..95d37adcf 100644 --- a/roles/build-docker-image/common.rst +++ b/roles/build-docker-image/common.rst @@ -42,6 +42,15 @@ using this role. The project directory. Serves as the base for :zuul:rolevar:`build-docker-image.docker_images.context`. +.. zuul:rolevar:: docker_dockerfile + :default: Dockerfile + + The default Dockerfile name to use. Serves as the base for + :zuul:rolevar:`build-docker-image.docker_images.dockerfile`. + This allows a global overriding of Dockerfile name, for example + when building all images from different folders with similarily + named dockerfiles. + .. zuul:rolevar:: docker_credentials :type: dict @@ -75,6 +84,12 @@ using this role. The docker build context; this should be a directory underneath :zuul:rolevar:`build-docker-image.zuul_work_dir`. + .. zuul:rolevar:: dockerfile + + The filename of the dockerfile, present in the context folder, + used for building the image. Provide this if you are using + a non-standard filename for a specific image. + .. zuul:rolevar:: repository 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 9739eb171..d702500de 100644 --- a/roles/build-docker-image/defaults/main.yaml +++ b/roles/build-docker-image/defaults/main.yaml @@ -1 +1,2 @@ zuul_work_dir: "{{ zuul.project.src_dir }}" +docker_dockerfile: "Dockerfile" diff --git a/roles/build-docker-image/tasks/main.yaml b/roles/build-docker-image/tasks/main.yaml index 5b8fe616b..653dc54c1 100644 --- a/roles/build-docker-image/tasks/main.yaml +++ b/roles/build-docker-image/tasks/main.yaml @@ -1,6 +1,6 @@ - name: Build a docker image command: >- - docker build {{ item.path | default('.') }} -f Dockerfile + docker build {{ item.path | default('.') }} -f {{ item.dockerfile | default(docker_dockerfile) }} {% if item.target | default(false) -%} --target {{ item.target }} {% endif -%}