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
  (c03ef20e5d/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.
This commit is contained in:
Slavi Pantaleev 2024-11-28 11:36:16 +02:00
parent cd1905f576
commit f19f3bea2d
2 changed files with 41 additions and 35 deletions

View File

@ -4,6 +4,12 @@
matrix_client_schildichat_enabled: true matrix_client_schildichat_enabled: true
matrix_client_schildichat_container_image_self_build: false 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 # renovate: datasource=docker depName=ghcr.io/etkecc/schildichat-web
matrix_client_schildichat_version: 1.11.36-sc.3 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_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_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 # The base container network
matrix_client_schildichat_container_network: '' matrix_client_schildichat_container_network: ''

View File

@ -9,10 +9,10 @@
group: "{{ matrix_user_groupname }}" group: "{{ matrix_user_groupname }}"
with_items: with_items:
- {path: "{{ matrix_client_schildichat_data_path }}", when: true} - {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" when: "item.when | bool"
- name: Ensure SchildiChat Web Docker image is pulled - name: Ensure SchildiChat Web container image is pulled
community.docker.docker_image: community.docker.docker_image:
name: "{{ matrix_client_schildichat_docker_image }}" name: "{{ matrix_client_schildichat_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}" 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 }}" delay: "{{ devture_playbook_help_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure SchildiChat Web repository is present on self-build - when: "matrix_client_schildichat_container_image_self_build | bool"
ansible.builtin.git: block:
repo: "{{ matrix_client_schildichat_container_image_self_build_repo }}" - name: Ensure SchildiChat Web repository is present on self-build
dest: "{{ matrix_client_schildichat_docker_src_files_path }}" ansible.builtin.git:
version: "{{ matrix_client_schildichat_docker_image.split(':')[1] }}" repo: "{{ matrix_client_schildichat_container_image_self_build_repo }}"
force: "yes" dest: "{{ matrix_client_schildichat_container_src_files_path }}"
become: true version: "{{ matrix_client_schildichat_container_image_self_build_version }}"
become_user: "{{ matrix_user_username }}" force: "yes"
register: matrix_client_schildichat_git_pull_results become: true
when: "matrix_client_schildichat_container_image_self_build | bool" become_user: "{{ matrix_user_username }}"
register: matrix_client_schildichat_git_pull_results
# See: # See:
# - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357 # - https://github.com/spantaleev/matrix-docker-ansible-deploy/issues/1357
# - https://github.com/vector-im/schildichat-web/issues/19544 -- # Update (2023-12-15): 404 # - 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 - name: Patch webpack.config.js to support building on low-memory (<4G RAM) devices
ansible.builtin.lineinfile: ansible.builtin.lineinfile:
path: "{{ matrix_client_schildichat_docker_src_files_path }}/webpack.config.js" path: "{{ matrix_client_schildichat_container_src_files_path }}/element-web/webpack.config.js"
regexp: '(\s+)splitChunks: \{' regexp: '(\s+)splitChunks: \{'
line: '\1splitChunks: { maxSize: 100000,' line: '\1splitChunks: { maxSize: 100000,'
backrefs: true backrefs: true
owner: root owner: root
group: root group: root
mode: '0644' 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" when: "matrix_client_schildichat_container_image_self_build_low_memory_system_patch_enabled | bool"
- name: Ensure SchildiChat Web Docker image is built - name: Ensure SchildiChat Web container image is built
ansible.builtin.command: ansible.builtin.command:
cmd: |- cmd: |-
{{ devture_systemd_docker_base_host_command_docker }} buildx build {{ devture_systemd_docker_base_host_command_docker }} buildx build
--tag={{ matrix_client_schildichat_docker_image }} --tag={{ matrix_client_schildichat_docker_image }}
--file={{ matrix_client_schildichat_docker_src_files_path }}/Dockerfile --file={{ matrix_client_schildichat_container_src_files_path }}/Dockerfile
{{ matrix_client_schildichat_docker_src_files_path }} {{ matrix_client_schildichat_container_src_files_path }}
changed_when: true changed_when: true
when: matrix_client_schildichat_container_image_self_build | bool
- name: Ensure SchildiChat Web configuration installed - name: Ensure SchildiChat Web configuration installed
ansible.builtin.copy: ansible.builtin.copy: