Add hookshot self build for arm64 and amd64

This commit is contained in:
Arthur Brugière 2022-04-03 17:10:46 +07:00 committed by GitHub
parent a04df8151f
commit b3176957c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 46 additions and 10 deletions

View File

@ -22,6 +22,7 @@ List of roles where self-building the Docker image is currently possible:
- `matrix-dimension` - `matrix-dimension`
- `matrix-ma1sd` - `matrix-ma1sd`
- `matrix-mailer` - `matrix-mailer`
- `matrix-bridge-hookshot`
- `matrix-bridge-appservice-irc` - `matrix-bridge-appservice-irc`
- `matrix-bridge-appservice-slack` - `matrix-bridge-appservice-slack`
- `matrix-bridge-appservice-webhooks` - `matrix-bridge-appservice-webhooks`

View File

@ -671,6 +671,8 @@ matrix_heisenbridge_systemd_wanted_services_list: |
# We don't enable bridges by default. # We don't enable bridges by default.
matrix_hookshot_enabled: false matrix_hookshot_enabled: false
matrix_hookshot_container_image_self_build: "{{ matrix_architecture not in ['arm64', 'amd64'] }}"
matrix_hookshot_appservice_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'hookshot.as.tok') | to_uuid }}" matrix_hookshot_appservice_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'hookshot.as.tok') | to_uuid }}"
matrix_hookshot_homeserver_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'hookshot.hs.tok') | to_uuid }}" matrix_hookshot_homeserver_token: "{{ '%s' | format(matrix_homeserver_generic_secret_key) | password_hash('sha512', 'hookshot.hs.tok') | to_uuid }}"

View File

@ -5,12 +5,21 @@
matrix_hookshot_enabled: true matrix_hookshot_enabled: true
matrix_hookshot_container_image_self_build: false
matrix_hookshot_container_image_self_build_repo: "https://github.com/matrix-org/matrix-hookshot.git"
matrix_hookshot_container_image_self_build_branch: "{{ 'main' if matrix_hookshot_version == 'latest' else matrix_hookshot_version }}"
matrix_hookshot_version: 1.3.0 matrix_hookshot_version: 1.3.0
matrix_hookshot_docker_image: "{{ matrix_container_global_registry_prefix }}halfshot/matrix-hookshot:{{ matrix_hookshot_version }}"
matrix_hookshot_docker_image: "{{ matrix_hookshot_docker_image_name_prefix }}mautrix/whatsapp:{{ matrix_mautrix_whatsapp_version }}"
matrix_hookshot_docker_image_name_prefix: "{{ 'localhost/' if matrix_hookshot_container_image_self_build else matrix_container_global_registry_prefix }}"
matrix_hookshot_docker_image_force_pull: "{{ matrix_hookshot_docker_image.endswith(':latest') }}" matrix_hookshot_docker_image_force_pull: "{{ matrix_hookshot_docker_image.endswith(':latest') }}"
matrix_hookshot_base_path: "{{ matrix_base_data_path }}/hookshot" matrix_hookshot_base_path: "{{ matrix_base_data_path }}/hookshot"
matrix_hookshot_docker_src_files_path: "{{ matrix_hookshot_base_path }}/docker-src"
matrix_hookshot_homeserver_address: "{{ matrix_homeserver_container_url }}" matrix_hookshot_homeserver_address: "{{ matrix_homeserver_container_url }}"
matrix_hookshot_container_url: 'matrix-hookshot' matrix_hookshot_container_url: 'matrix-hookshot'

View File

@ -2,26 +2,50 @@
- import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml" - import_tasks: "{{ role_path }}/../matrix-base/tasks/util/ensure_openssl_installed.yml"
- name: Ensure hookshot paths exist
file:
path: "{{ item.path }}"
state: directory
mode: 0750
owner: "{{ matrix_user_username }}"
group: "{{ matrix_user_groupname }}"
with_items:
- { path: "{{ matrix_hookshot_base_path }}", when: true }
- { path: "{{ matrix_hookshot_docker_src_files_path }}", when: "{{ matrix_hookshot_container_image_self_build }}" }
when: item.when|bool
- name: Ensure hookshot image is pulled - name: Ensure hookshot image is pulled
docker_image: docker_image:
name: "{{ matrix_hookshot_docker_image }}" name: "{{ matrix_hookshot_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 }}"
force_source: "{{ matrix_hookshot_docker_image_force_pull if ansible_version.major > 2 or ansible_version.minor >= 8 else omit }}" force_source: "{{ matrix_hookshot_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_hookshot_docker_image_force_pull }}" force: "{{ omit if ansible_version.major > 2 or ansible_version.minor >= 8 else matrix_hookshot_docker_image_force_pull }}"
when: not matrix_hookshot_container_image_self_build
register: result register: result
retries: "{{ matrix_container_retries_count }}" retries: "{{ matrix_container_retries_count }}"
delay: "{{ matrix_container_retries_delay }}" delay: "{{ matrix_container_retries_delay }}"
until: result is not failed until: result is not failed
- name: Ensure hookshot paths exist - name: Ensure hookshot repository is present on self-build
file: git:
path: "{{ item }}" repo: "{{ matrix_hookshot_container_image_self_build_repo }}"
state: directory dest: "{{ matrix_hookshot_docker_src_files_path }}"
mode: 0750 version: "{{ matrix_hookshot_container_image_self_build_branch }}"
owner: "{{ matrix_user_username }}" force: "yes"
group: "{{ matrix_user_groupname }}" register: matrix_hookshot_git_pull_results
with_items: when: "matrix_hookshot_container_image_self_build|bool"
- "{{ matrix_hookshot_base_path }}"
- name: Ensure hookshot Docker image is built
docker_image:
name: "{{ matrix_hookshot_docker_image }}"
source: build
force_source: "{{ matrix_hookshot_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_hookshot_git_pull_results.changed }}"
build:
dockerfile: Dockerfile
path: "{{ matrix_hookshot_docker_src_files_path }}"
pull: yes
when: "matrix_hookshot_container_image_self_build|bool"
- name: Check if hookshot passkey exists - name: Check if hookshot passkey exists
stat: stat: