From f19f3bea2d83957dac90bd2bc7f1149213bd2c95 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Thu, 28 Nov 2024 11:36:16 +0200 Subject: [PATCH] Progress a bit on self-building for Schildichat This is related to https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/3831 It: - adds some missing variables - version variable to branch variable conversion While it improves the situation, it still doesn't result in a working self-building feature, because: - cloning a repository containing submodules requires special care, as described here (https://github.com/SchildiChat/schildichat-desktop/blob/c03ef20e5dc0a88cec479c9711d9941aba48ab97/README.md#initial-build-setup) - we likely better clone a specific repository version from the very beginning, instead of trying to change subsequently (and having to re-initilize submodules) though that's very different than what we're doing elsewhere and is likely very wasteful - we can't just build a `Dockerfile`, we need to invoke `make setup` (`./setup.sh`) - it's likely that the `docker-src` directory is not reusable across versions or may require special handling to clean up files, etc. --- .../defaults/main.yml | 8 ++- .../tasks/setup_install.yml | 68 +++++++++---------- 2 files changed, 41 insertions(+), 35 deletions(-) diff --git a/roles/custom/matrix-client-schildichat/defaults/main.yml b/roles/custom/matrix-client-schildichat/defaults/main.yml index bd7ab05d8..22d71f29e 100644 --- a/roles/custom/matrix-client-schildichat/defaults/main.yml +++ b/roles/custom/matrix-client-schildichat/defaults/main.yml @@ -4,6 +4,12 @@ matrix_client_schildichat_enabled: true matrix_client_schildichat_container_image_self_build: false +matrix_client_schildichat_container_image_self_build_repo: "https://github.com/SchildiChat/schildichat-desktop.git" +matrix_client_schildichat_container_image_self_build_version: "{{ 'lite' if matrix_client_schildichat_version == 'latest' else ('v' + matrix_client_schildichat_version) }}" +# Controls whether to patch webpack.config.js when self-building, so that building can pass on low-memory systems (< 4 GB RAM): +# - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357 +# - https://github.com/element-hq/element-web/issues/19544 +matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled: "{{ ansible_memtotal_mb < 4096 }}" # renovate: datasource=docker depName=ghcr.io/etkecc/schildichat-web matrix_client_schildichat_version: 1.11.36-sc.3 @@ -12,7 +18,7 @@ matrix_client_schildichat_docker_image_name_prefix: "{{ 'localhost/' if matrix_c matrix_client_schildichat_docker_image_force_pull: "{{ matrix_client_schildichat_docker_image.endswith(':latest') }}" matrix_client_schildichat_data_path: "{{ matrix_base_data_path }}/client-schildichat" -matrix_client_schildichat_docker_src_files_path: "{{ matrix_client_schildichat_data_path }}/docker-src" +matrix_client_schildichat_container_src_files_path: "{{ matrix_client_schildichat_data_path }}/docker-src" # The base container network matrix_client_schildichat_container_network: '' diff --git a/roles/custom/matrix-client-schildichat/tasks/setup_install.yml b/roles/custom/matrix-client-schildichat/tasks/setup_install.yml index 6dc9222c4..b27f5bc48 100644 --- a/roles/custom/matrix-client-schildichat/tasks/setup_install.yml +++ b/roles/custom/matrix-client-schildichat/tasks/setup_install.yml @@ -9,10 +9,10 @@ group: "{{ matrix_user_groupname }}" with_items: - {path: "{{ matrix_client_schildichat_data_path }}", when: true} - - {path: "{{ matrix_client_schildichat_docker_src_files_path }}", when: "{{ matrix_client_schildichat_container_image_self_build }}"} + - {path: "{{ matrix_client_schildichat_container_src_files_path }}", when: "{{ matrix_client_schildichat_container_image_self_build }}"} when: "item.when | bool" -- name: Ensure SchildiChat Web Docker image is pulled +- name: Ensure SchildiChat Web container image is pulled community.docker.docker_image: name: "{{ matrix_client_schildichat_docker_image }}" source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" @@ -24,40 +24,40 @@ delay: "{{ devture_playbook_help_container_retries_delay }}" until: result is not failed -- name: Ensure SchildiChat Web repository is present on self-build - ansible.builtin.git: - repo: "{{ matrix_client_schildichat_container_image_self_build_repo }}" - dest: "{{ matrix_client_schildichat_docker_src_files_path }}" - version: "{{ matrix_client_schildichat_docker_image.split(':')[1] }}" - force: "yes" - become: true - become_user: "{{ matrix_user_username }}" - register: matrix_client_schildichat_git_pull_results - when: "matrix_client_schildichat_container_image_self_build | bool" +- when: "matrix_client_schildichat_container_image_self_build | bool" + block: + - name: Ensure SchildiChat Web repository is present on self-build + ansible.builtin.git: + repo: "{{ matrix_client_schildichat_container_image_self_build_repo }}" + dest: "{{ matrix_client_schildichat_container_src_files_path }}" + version: "{{ matrix_client_schildichat_container_image_self_build_version }}" + force: "yes" + become: true + become_user: "{{ matrix_user_username }}" + register: matrix_client_schildichat_git_pull_results -# See: -# - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357 -# - https://github.com/vector-im/schildichat-web/issues/19544 -- # Update (2023-12-15): 404 -- name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices - ansible.builtin.lineinfile: - path: "{{ matrix_client_schildichat_docker_src_files_path }}/webpack.config.js" - regexp: '(\s+)splitChunks: \{' - line: '\1splitChunks: { maxSize: 100000,' - backrefs: true - owner: root - group: root - mode: '0644' - when: "matrix_client_schildichat_container_image_self_build | bool and matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled | bool" + # See: + # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357 + # - https://github.com/vector-im/schildichat-web/issues/19544 -- # Update (2023-12-15): 404 + - name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices + ansible.builtin.lineinfile: + path: "{{ matrix_client_schildichat_container_src_files_path }}/element-web/webpack.config.js" + regexp: '(\s+)splitChunks: \{' + line: '\1splitChunks: { maxSize: 100000,' + backrefs: true + owner: root + group: root + mode: '0644' + when: "matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled | bool" -- name: Ensure SchildiChat Web Docker image is built - ansible.builtin.command: - cmd: |- - {{ devture_systemd_docker_base_host_command_docker }} buildx build - --tag={{ matrix_client_schildichat_docker_image }} - --file={{ matrix_client_schildichat_docker_src_files_path }}/Dockerfile - {{ matrix_client_schildichat_docker_src_files_path }} - changed_when: true - when: matrix_client_schildichat_container_image_self_build | bool + - name: Ensure SchildiChat Web container image is built + ansible.builtin.command: + cmd: |- + {{ devture_systemd_docker_base_host_command_docker }} buildx build + --tag={{ matrix_client_schildichat_docker_image }} + --file={{ matrix_client_schildichat_container_src_files_path }}/Dockerfile + {{ matrix_client_schildichat_container_src_files_path }} + changed_when: true - name: Ensure SchildiChat Web configuration installed ansible.builtin.copy: