0b0cb18a60
When you build from a Dockerfile, it runs in a given "context"; that is the directory the Dockerfile is in and the directories below it. It can not access anything outside that context during the build. When building a container for a project in the gate, you may wish to install sibling projects that Zuul has checked-out into your container (i.e. so that Depends-On works). As mentioned, because /home/zuul/src/<project> is not in the context of the current project, you will not be able to access this source code during the container build. So to help facilitate dependencies, add a siblings: tag which can copy some or all of the required-projects already specified for the job into a special sub-directory of the current source. Because all the code is now in the same context, this will allow build scripts to be written that look for directories in .zuul-siblings and can install the source code from there. To further help the scripts, the ZUUL_SIBLINGS arg is set for the docker build giving the copied paths. The test is updated with some paths to test the copy. Change-Id: I079d823e7194e15b1b496aea0f53f70f6b563f02
38 lines
1.5 KiB
YAML
38 lines
1.5 KiB
YAML
# This can be removed if we add this functionality to Zuul directly
|
|
- name: Load information from zuul_return
|
|
when: buildset_registry is not defined
|
|
set_fact:
|
|
buildset_registry: "{{ (lookup('file', zuul.executor.work_root + '/results.json') | from_json)['buildset_registry'] }}"
|
|
ignore_errors: true
|
|
|
|
- name: Build docker images
|
|
include_tasks: build.yaml
|
|
loop: "{{ docker_images }}"
|
|
|
|
# Docker doesn't understand docker push [1234:5678::]:5000/image/path:tag
|
|
# so we set up /etc/hosts with a registry alias name to support ipv6 and 4.
|
|
- name: Configure /etc/hosts for buildset_registry to workaround docker not understanding ipv6 addresses
|
|
become: yes
|
|
lineinfile:
|
|
path: /etc/hosts
|
|
state: present
|
|
regex: "^{{ buildset_registry.host }}\tzuul-jobs.buildset-registry$"
|
|
line: "{{ buildset_registry.host }}\tzuul-jobs.buildset-registry"
|
|
insertafter: EOF
|
|
when: buildset_registry is defined and buildset_registry.host | ipaddr
|
|
- name: Set buildset_registry alias variable when using ip
|
|
set_fact:
|
|
buildset_registry_alias: zuul-jobs.buildset-registry
|
|
when: buildset_registry is defined and buildset_registry.host | ipaddr
|
|
- name: Set buildset_registry alias variable when using name
|
|
set_fact:
|
|
buildset_registry_alias: "{{ buildset_registry.host }}"
|
|
when: buildset_registry is defined and not ( buildset_registry.host | ipaddr )
|
|
# Push each image.
|
|
- name: Push image to buildset registry
|
|
when: buildset_registry is defined
|
|
include_tasks: push.yaml
|
|
loop: "{{ docker_images }}"
|
|
loop_control:
|
|
loop_var: image
|