Add self-building support to matrix-corporal

This commit is contained in:
Slavi Pantaleev 2020-12-04 01:48:08 +02:00
parent b3d91ed488
commit a5ae7e9ef0
4 changed files with 31 additions and 2 deletions

View File

@ -15,6 +15,7 @@ List of roles where self-building the Docker image is currently possible:
- `matrix-client-element`
- `matrix-registration`
- `matrix-coturn`
- `matrix-corporal`
- `matrix-ma1sd`
- `matrix-mailer`
- `matrix-bridge-mautrix-facebook`

View File

@ -541,6 +541,8 @@ matrix_bot_matrix_reminder_bot_enabled: false
matrix_corporal_enabled: false
matrix_corporal_container_image_self_build: "{{ matrix_architecture != 'amd64' }}"
# Normally, matrix-nginx-proxy is enabled and nginx can reach matrix-corporal over the container network.
# If matrix-nginx-proxy is not enabled, or you otherwise have a need for it, you can expose
# matrix-corporal's web-server ports to the local host.

View File

@ -3,6 +3,9 @@
matrix_corporal_enabled: true
matrix_corporal_container_image_self_build: false
matrix_corporal_container_image_self_build_repo: "https://github.com/devture/matrix-corporal.git"
# Controls whether the matrix-corporal container exposes its gateway HTTP port (tcp/41080 in the container).
#
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:41080"), or empty string to not expose.
@ -19,10 +22,13 @@ matrix_corporal_container_extra_arguments: []
# List of systemd services that matrix-corporal.service depends on
matrix_corporal_systemd_required_services_list: ['docker.service']
matrix_corporal_docker_image: "docker.io/devture/matrix-corporal:1.11.0"
matrix_corporal_docker_image: "{{ matrix_corporal_docker_image_name_prefix }}devture/matrix-corporal:{{ matrix_corporal_docker_image_tag }}"
matrix_corporal_docker_image_name_prefix: "{{ 'localhost/' if matrix_synapse_container_image_self_build else 'docker.io/' }}"
matrix_corporal_docker_image_tag: "1.11.0"
matrix_corporal_docker_image_force_pull: "{{ matrix_corporal_docker_image.endswith(':latest') }}"
matrix_corporal_base_path: "{{ matrix_base_data_path }}/corporal"
matrix_corporal_container_src_files_path: "{{ matrix_corporal_base_path }}/container-src"
matrix_corporal_config_dir_path: "{{ matrix_corporal_base_path }}/config"
matrix_corporal_cache_dir_path: "{{ matrix_corporal_base_path }}/cache"
matrix_corporal_var_dir_path: "{{ matrix_corporal_base_path }}/var"

View File

@ -17,13 +17,33 @@
- "{{ matrix_corporal_var_dir_path }}"
when: matrix_corporal_enabled|bool
- name: Ensure Matrix Corporal repository is present on self-build
git:
repo: "{{ matrix_corporal_container_image_self_build_repo }}"
dest: "{{ matrix_corporal_container_src_files_path }}"
version: "{{ matrix_corporal_docker_image.split(':')[1] }}"
force: "yes"
register: matrix_corporal_git_pull_results
when: "matrix_corporal_enabled|bool and matrix_corporal_container_image_self_build|bool"
- name: Ensure Matrix Corporal Docker image is built
docker_image:
name: "{{ matrix_corporal_docker_image }}"
source: build
force_source: "{{ matrix_corporal_git_pull_results.changed }}"
build:
dockerfile: etc/docker/Dockerfile
path: "{{ matrix_corporal_container_src_files_path }}"
pull: yes
when: "matrix_corporal_enabled|bool and matrix_corporal_container_image_self_build|bool"
- name: Ensure Matrix Corporal Docker image is pulled
docker_image:
name: "{{ matrix_corporal_docker_image }}"
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
force_source: "{{ matrix_corporal_docker_image_force_pull 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_corporal_docker_image_force_pull }}"
when: matrix_corporal_enabled|bool
when: "matrix_corporal_enabled|bool and not matrix_corporal_container_image_self_build|bool"
- name: Ensure Matrix Corporal config installed
copy: