Skip to content

Commit

Permalink
Moves matrix_dendrite_container_image_self_build
Browse files Browse the repository at this point in the history
to a conditional block, similar to synapse. Also adds the
DOCKER_BUILDKIT=1 explicitly to ensure buildkit is used.
  • Loading branch information
ibeckermayer committed May 10, 2023
1 parent 2bd94a5 commit d448cad
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions roles/custom/matrix-dendrite/tasks/setup_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@
delay: "{{ devture_playbook_help_container_retries_delay }}"
until: result is not failed

- name: Ensure Dendrite repository is present on self-build
ansible.builtin.git:
repo: "{{ matrix_dendrite_container_image_self_build_repo }}"
dest: "{{ matrix_dendrite_docker_src_files_path }}"
version: "{{ matrix_dendrite_docker_image.split(':')[1] }}"
force: "yes"
become: true
become_user: "{{ matrix_user_username }}"
register: matrix_dendrite_git_pull_results
when: "matrix_dendrite_container_image_self_build | bool"

# We do this so that the signing key would get generated.
# We don't use the `docker_container` module, because using it with `cap_drop` requires
# a very recent version, which is not available for a lot of people yet.
Expand Down Expand Up @@ -88,10 +77,32 @@
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"

- name: Ensure Dendrite Docker image is built
ansible.builtin.command:
cmd: "{{ devture_systemd_docker_base_host_command_docker }} build -t {{ matrix_dendrite_docker_image }} {{ matrix_dendrite_docker_src_files_path }}"
when: "matrix_dendrite_container_image_self_build | bool"
- when: "matrix_dendrite_container_image_self_build | bool"
block:
- name: Ensure Dendrite repository is present on self-build
ansible.builtin.git:
repo: "{{ matrix_dendrite_container_image_self_build_repo }}"
dest: "{{ matrix_dendrite_docker_src_files_path }}"
version: "{{ matrix_dendrite_docker_image.split(':')[1] }}"
force: "yes"
become: true
become_user: "{{ matrix_user_username }}"
register: matrix_dendrite_git_pull_results

- name: Check if Dendrite Docker image exists
ansible.builtin.command: "{{ devture_systemd_docker_base_host_command_docker }} images --quiet --filter 'reference={{ matrix_dendrite_docker_image }}'"
register: matrix_dendrite_docker_image_check_result
changed_when: false

# Invoking the `docker build` command here, instead of calling the `docker_image` Ansible module,
# because the latter does not support BuildKit.
# See: https://github.com/ansible-collections/community.general/issues/514
- name: Ensure Dendrite Docker image is built

Check failure on line 100 in roles/custom/matrix-dendrite/tasks/setup_install.yml

View workflow job for this annotation

GitHub Actions / ansible-lint

no-changed-when

Commands should not change things if nothing needs doing.
ansible.builtin.command:
cmd: "{{ devture_systemd_docker_base_host_command_docker }} build -t {{ matrix_dendrite_docker_image }} {{ matrix_dendrite_docker_src_files_path }}"
environment:
DOCKER_BUILDKIT: 1
when: "matrix_dendrite_git_pull_results.changed | bool or matrix_dendrite_docker_image_check_result.stdout == ''"

- name: Ensure Dendrite container network is created
community.general.docker_network:
Expand Down

0 comments on commit d448cad

Please sign in to comment.