Fix self-building for Synapse v1.51.0 (requires BuildKit)

Synapse v1.51.0 requires to be built with BuildKit since
https://github.com/matrix-org/synapse/pull/11691

The `docker_image` Ansible module does not support BuildKit
(https://github.com/ansible-collections/community.general/issues/514),
so we had to switch to a `docker build` call.
This commit is contained in:
Slavi Pantaleev 2022-01-26 08:38:27 +02:00
parent cf46b7fed5
commit ad082b3b1b

View File

@ -18,6 +18,7 @@
group: "{{ matrix_user_groupname }}"
when: "not local_path_media_store_stat.failed and not local_path_media_store_stat.stat.exists"
- block:
- name: Ensure Synapse repository is present on self-build
git:
repo: "{{ matrix_synapse_container_image_self_build_repo }}"
@ -25,18 +26,25 @@
version: "{{ matrix_synapse_docker_image.split(':')[1] }}"
force: "yes"
register: matrix_synapse_git_pull_results
when: "matrix_synapse_container_image_self_build|bool"
- 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
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
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