Skip to content

Commit b5d8444

Browse files
committed
Add self-building support to matrix-bridge-appservice-webhooks
1 parent 096c960 commit b5d8444

File tree

4 files changed

+46
-12
lines changed

4 files changed

+46
-12
lines changed

docs/self-building.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ List of roles where self-building the Docker image is currently possible:
2222
- `matrix-mailer`
2323
- `matrix-bridge-appservice-irc`
2424
- `matrix-bridge-appservice-slack`
25+
- `matrix-bridge-appservice-webhooks`
2526
- `matrix-bridge-mautrix-facebook`
2627
- `matrix-bridge-mautrix-hangouts`
2728
- `matrix-bridge-mautrix-telegram`

group_vars/matrix_servers

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ matrix_appservice_discord_database_password: "{{ matrix_synapse_macaroon_secret_
104104
# We don't enable bridges by default.
105105
matrix_appservice_webhooks_enabled: false
106106

107+
matrix_appservice_webhooks_container_image_self_build: "{{ matrix_architecture != 'amd64' }}"
108+
107109
# Normally, matrix-nginx-proxy is enabled and nginx can reach matrix-appservice-webhooks over the container network.
108110
# If matrix-nginx-proxy is not enabled, or you otherwise have a need for it, you can expose
109111
# matrix-appservice-webhooks' client-server port to the local host.

roles/matrix-bridge-appservice-webhooks/defaults/main.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@
33

44
matrix_appservice_webhooks_enabled: true
55

6+
matrix_appservice_webhooks_container_image_self_build: false
7+
matrix_appservice_webhooks_container_image_self_build_repo: "https://github.com/turt2live/matrix-appservice-webhooks"
8+
matrix_appservice_webhooks_container_image_self_build_repo_version: "{{ 'master' if matrix_appservice_webhooks_version == 'latest' else matrix_appservice_webhooks_version }}"
9+
matrix_appservice_webhooks_container_image_self_build_repo_dockerfile_path: "Dockerfile"
10+
611
matrix_appservice_webhooks_version: latest
7-
matrix_appservice_webhooks_docker_image: "{{ matrix_container_global_registry_prefix }}turt2live/matrix-appservice-webhooks:{{ matrix_appservice_webhooks_version }}"
12+
matrix_appservice_webhooks_docker_image: "{{ matrix_appservice_webhooks_docker_image_name_prefix }}turt2live/matrix-appservice-webhooks:{{ matrix_appservice_webhooks_version }}"
13+
matrix_appservice_webhooks_docker_image_name_prefix: "{{ 'localhost/' if matrix_appservice_webhooks_container_image_self_build else matrix_container_global_registry_prefix }}"
814
matrix_appservice_webhooks_docker_image_force_pull: "{{ matrix_appservice_webhooks_docker_image.endswith(':latest') }}"
915

1016
matrix_appservice_webhooks_base_path: "{{ matrix_base_data_path }}/appservice-webhooks"
1117
matrix_appservice_webhooks_config_path: "{{ matrix_appservice_webhooks_base_path }}/config"
1218
matrix_appservice_webhooks_data_path: "{{ matrix_appservice_webhooks_base_path }}/data"
19+
matrix_appservice_webhooks_docker_src_files_path: "{{ matrix_appservice_webhooks_base_path }}/docker-src"
1320

1421
# If nginx-proxy is disabled, the bridge itself expects its endpoint to be on its own domain (e.g. "localhost:6789")
1522
matrix_appservice_webhooks_public_endpoint: /appservice-webhooks

roles/matrix-bridge-appservice-webhooks/tasks/setup_install.yml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,47 @@
11
---
22

3-
- name: Ensure Appservice webhooks image is pulled
4-
docker_image:
5-
name: "{{ matrix_appservice_webhooks_docker_image }}"
6-
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
7-
force_source: "{{ matrix_appservice_webhooks_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
8-
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_webhooks_docker_image_force_pull }}"
9-
103
- name: Ensure AppService webhooks paths exist
114
file:
12-
path: "{{ item }}"
5+
path: "{{ item.path }}"
136
state: directory
147
mode: 0750
158
owner: "{{ matrix_user_username }}"
169
group: "{{ matrix_user_groupname }}"
1710
with_items:
18-
- "{{ matrix_appservice_webhooks_base_path }}"
19-
- "{{ matrix_appservice_webhooks_config_path }}"
20-
- "{{ matrix_appservice_webhooks_data_path }}"
11+
- { path: "{{ matrix_appservice_webhooks_base_path }}", when: true }
12+
- { path: "{{ matrix_appservice_webhooks_config_path }}", when: true }
13+
- { path: "{{ matrix_appservice_webhooks_data_path }}", when: true }
14+
- { path: "{{ matrix_appservice_webhooks_docker_src_files_path }}", when: "{{ matrix_appservice_webhooks_container_image_self_build }}"}
15+
when: "item.when|bool"
16+
17+
- name: Ensure Appservice webhooks image is pulled
18+
docker_image:
19+
name: "{{ matrix_appservice_webhooks_docker_image }}"
20+
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
21+
force_source: "{{ matrix_appservice_webhooks_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
22+
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_webhooks_docker_image_force_pull }}"
23+
when: "not matrix_appservice_webhooks_container_image_self_build|bool"
24+
25+
- block:
26+
- name: Ensure Appservice webhooks repository is present on self-build
27+
git:
28+
repo: "{{ matrix_appservice_webhooks_container_image_self_build_repo }}"
29+
dest: "{{ matrix_appservice_webhooks_docker_src_files_path }}"
30+
version: "{{ matrix_appservice_webhooks_container_image_self_build_repo_version }}"
31+
force: "yes"
32+
register: matrix_appservice_webhooks_git_pull_results
33+
34+
- name: Ensure Appservice webhooks Docker image is built
35+
docker_image:
36+
name: "{{ matrix_appservice_webhooks_docker_image }}"
37+
source: build
38+
force_source: "{{ matrix_appservice_webhooks_git_pull_results.changed if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}"
39+
force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_appservice_webhooks_git_pull_results.changed }}"
40+
build:
41+
dockerfile: "{{ matrix_appservice_webhooks_container_image_self_build_repo_dockerfile_path }}"
42+
path: "{{ matrix_appservice_webhooks_docker_src_files_path }}"
43+
pull: yes
44+
when: "matrix_appservice_webhooks_container_image_self_build|bool"
2145

2246
- name: Ensure Matrix Appservice webhooks config is installed
2347
copy:

0 commit comments

Comments
 (0)