Skip to content

Commit

Permalink
Fix self-building for Synapse v1.51.0 (requires BuildKit)
Browse files Browse the repository at this point in the history
Synapse v1.51.0 requires to be built with BuildKit since
matrix-org/synapse#11691

The `docker_image` Ansible module does not support BuildKit
(ansible-collections/community.general#514),
so we had to switch to a `docker build` call.
spantaleev committed Jan 26, 2022
1 parent cf46b7f commit ad082b3
Showing 1 changed file with 26 additions and 18 deletions.
44 changes: 26 additions & 18 deletions roles/matrix-synapse/tasks/synapse/setup_install.yml
Original file line number Diff line number Diff line change
@@ -18,25 +18,33 @@
group: "{{ matrix_user_groupname }}"
when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists"

- name: Ensure Synapse repository is present on self-build
git:
repo: "{{ matrix_synapse_container_image_self_build_repo }}"
dest: "{{ matrix_synapse_docker_src_files_path }}"
version: "{{ matrix_synapse_docker_image.split(':')[1] }}"
force: "yes"
register: matrix_synapse_git_pull_results
when: "matrix_synapse_container_image_self_build|bool"
- block:
- name: Ensure Synapse repository is present on self-build
git:
repo: "{{ matrix_synapse_container_image_self_build_repo }}"
dest: "{{ matrix_synapse_docker_src_files_path }}"
version: "{{ matrix_synapse_docker_image.split(':')[1] }}"
force: "yes"
register: matrix_synapse_git_pull_results

- name: Ensure Synapse Docker image is built
docker_image:
name: "{{ matrix_synapse_docker_image }}"
source: build
force_source: "{{ matrix_synapse_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_synapse_git_pull_results.changed }}"
build:
dockerfile: docker/Dockerfile
path: "{{ matrix_synapse_docker_src_files_path }}"
pull: yes
- name: Check if Synapse Docker image exists
command: "{{ matrix_host_command_docker }} images --quiet --filter 'reference={{ matrix_synapse_docker_image }}'"
register: matrix_synapse_docker_image_check_result

# 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 Synapse Docker image is built
shell:
chdir: "{{ matrix_synapse_docker_src_files_path }}"
cmd: |
{{ matrix_host_command_docker }} build \
-t "{{ matrix_synapse_docker_image }}" \
-f docker/Dockerfile \
.
environment:
DOCKER_BUILDKIT: 1
when: "matrix_synapse_git_pull_results.changed|bool or matrix_synapse_docker_image_check_result.stdout == ''"
when: "matrix_synapse_container_image_self_build|bool"

- name: Ensure Synapse Docker image is pulled

0 comments on commit ad082b3

Please sign in to comment.