This is split out from matrix-cactus-comments (see 241779b583
),
but also heavily inspired by `matrix-static-files`.
bye-bye-nginx-proxy
parent
14b252c5f0
commit
ea992496a3
@ -0,0 +1,102 @@
|
||||
---
|
||||
# Cactus Comments is a federated comment system built on Matrix.
|
||||
# This role installs the client assets (JS, CSS files).
|
||||
# Project source code URL: https://gitlab.com/cactus-comments/cactus-client
|
||||
|
||||
matrix_cactus_comments_client_enabled: true
|
||||
|
||||
matrix_cactus_comments_client_hostname: ''
|
||||
matrix_cactus_comments_client_path_prefix: /cactus-comments
|
||||
|
||||
matrix_cactus_comments_client_base_path: "{{ matrix_base_data_path }}/cactus-comments-client"
|
||||
matrix_cactus_comments_client_public_path: "{{ matrix_cactus_comments_client_base_path }}/public"
|
||||
matrix_cactus_comments_client_public_path_file_permissions: "0644"
|
||||
|
||||
# renovate: datasource=docker depName=joseluisq/static-web-server
|
||||
matrix_cactus_comments_client_version: 2.24.2
|
||||
|
||||
matrix_cactus_comments_client_container_image: "{{ matrix_container_global_registry_prefix }}joseluisq/static-web-server:{{ matrix_cactus_comments_client_container_image_tag }}"
|
||||
matrix_cactus_comments_client_container_image_tag: "{{ 'latest' if matrix_cactus_comments_client_version == 'latest' else (matrix_cactus_comments_client_version + '-alpine') }}"
|
||||
matrix_cactus_comments_client_container_image_force_pull: "{{ matrix_cactus_comments_client_container_image.endswith(':latest') }}"
|
||||
|
||||
matrix_cactus_comments_client_container_network: ""
|
||||
|
||||
matrix_cactus_comments_client_container_additional_networks: "{{ matrix_cactus_comments_client_container_additional_networks_auto + matrix_cactus_comments_client_container_additional_networks_custom }}"
|
||||
matrix_cactus_comments_client_container_additional_networks_auto: []
|
||||
matrix_cactus_comments_client_container_additional_networks_custom: []
|
||||
|
||||
# Controls whether the matrix-cactus-comments-client container exposes its HTTP port (tcp/8080 in the container).
|
||||
#
|
||||
# Takes an "<ip>:<port>" or "<port>" value (e.g. "127.0.0.1:8080"), or empty string to not expose.
|
||||
matrix_cactus_comments_client_container_http_host_bind_port: ''
|
||||
|
||||
# matrix_cactus_comments_client_container_labels_traefik_enabled controls whether labels to assist a Traefik reverse-proxy will be attached to the container.
|
||||
# See `../templates/labels.j2` for details.
|
||||
#
|
||||
# To inject your own other container labels, see `matrix_cactus_comments_client_container_labels_additional_labels`.
|
||||
matrix_cactus_comments_client_container_labels_traefik_enabled: true
|
||||
matrix_cactus_comments_client_container_labels_traefik_docker_network: "{{ matrix_cactus_comments_client_container_network }}"
|
||||
matrix_cactus_comments_client_container_labels_traefik_entrypoints: web-secure
|
||||
matrix_cactus_comments_client_container_labels_traefik_tls_certResolver: default # noqa var-naming
|
||||
|
||||
# Controls whether labels will be added that serve the /public directory.
|
||||
matrix_cactus_comments_client_container_labels_public_enabled: true
|
||||
matrix_cactus_comments_client_container_labels_public_traefik_hostname: "{{ matrix_cactus_comments_client_hostname }}"
|
||||
matrix_cactus_comments_client_container_labels_public_traefik_path_prefix: "{{ matrix_cactus_comments_client_path_prefix }}"
|
||||
matrix_cactus_comments_client_container_labels_public_traefik_rule: "Host(`{{ matrix_cactus_comments_client_container_labels_public_traefik_hostname }}`){% if matrix_cactus_comments_client_container_labels_public_traefik_path_prefix != '/' %} && PathPrefix(`{{ matrix_cactus_comments_client_container_labels_public_traefik_path_prefix }}`){% endif %}"
|
||||
matrix_cactus_comments_client_container_labels_public_traefik_priority: 0
|
||||
matrix_cactus_comments_client_container_labels_public_traefik_entrypoints: "{{ matrix_cactus_comments_client_container_labels_traefik_entrypoints }}"
|
||||
matrix_cactus_comments_client_container_labels_public_traefik_tls: "{{ matrix_cactus_comments_client_container_labels_public_traefik_entrypoints != 'web' }}"
|
||||
matrix_cactus_comments_client_container_labels_public_traefik_tls_certResolver: "{{ matrix_cactus_comments_client_container_labels_traefik_tls_certResolver }}" # noqa var-naming
|
||||
|
||||
# matrix_cactus_comments_client_container_labels_additional_labels contains a multiline string with additional labels to add to the container label file.
|
||||
# See `../templates/labels.j2` for details.
|
||||
#
|
||||
# Example:
|
||||
# matrix_cactus_comments_client_container_labels_additional_labels: |
|
||||
# my.label=1
|
||||
# another.label="here"
|
||||
matrix_cactus_comments_client_container_labels_additional_labels: ''
|
||||
|
||||
# A list of extra arguments to pass to the container
|
||||
matrix_cactus_comments_client_container_extra_arguments: []
|
||||
|
||||
# Controls the SERVER_PORT environment variable.
|
||||
# See: https://static-web-server.net/configuration/environment-variables/
|
||||
matrix_cactus_comments_client_environment_variable_server_port: 8080
|
||||
|
||||
# Controls the SERVER_LOG_LEVEL environment variable.
|
||||
# See: https://static-web-server.net/configuration/environment-variables/
|
||||
# Valid values: error, warn, info, debug or trace
|
||||
matrix_cactus_comments_client_environment_variable_server_log_level: error
|
||||
|
||||
# Controls the SERVER_LOG_REMOTE_ADDRESS environment variable.
|
||||
# See: https://static-web-server.net/configuration/environment-variables/
|
||||
matrix_cactus_comments_client_environment_variable_server_log_remote_address: false
|
||||
|
||||
# Controls the SERVER_CONFIG_FILE environment variable.
|
||||
# See: https://static-web-server.net/configuration/environment-variables/
|
||||
matrix_cactus_comments_client_environment_variable_server_config_file: /config/config.toml
|
||||
|
||||
# Additional environment variables.
|
||||
matrix_cactus_comments_client_environment_variables_additional_variables: ''
|
||||
|
||||
# The released & compiled client is uploaded to a URL that changes per commit. Therefore it is necessary to check the
|
||||
# available versions and adjust the url manually.
|
||||
# For available versions, see: https://gitlab.com/cactus-comments/cactus-client/-/releases
|
||||
# Also see: `matrix_cactus_comments_client_local_dir`
|
||||
matrix_cactus_comments_client_webclient_js_url: "https://gateway.pinata.cloud/ipfs/QmSiWN27KZZ1XE32jKwifBnS3nWTUcFGNArKzur2nmDgoL/v0.13.0/cactus.js"
|
||||
matrix_cactus_comments_client_webclient_css_url: "https://gateway.pinata.cloud/ipfs/QmSiWN27KZZ1XE32jKwifBnS3nWTUcFGNArKzur2nmDgoL/v0.13.0/style.css"
|
||||
|
||||
# matrix_cactus_comments_client_local_dir specifies a local directory (on the Ansible controller, not on the remote server) with cactus-client files to use.
|
||||
# This is an alternative to `matrix_cactus_comments_client_client_version`, to be used when you'd like to
|
||||
# provide the files locally / manually.
|
||||
matrix_cactus_comments_client_local_dir: ''
|
||||
|
||||
# List of systemd services that matrix-cactus-comments-client.service depends on
|
||||
matrix_cactus_comments_client_systemd_required_services_list: ['docker.service']
|
||||
|
||||
# List of systemd services that matrix-cactus-comments-client.service wants
|
||||
matrix_cactus_comments_client_systemd_wanted_services_list: "{{ matrix_cactus_comments_client_systemd_wanted_services_list_auto + matrix_cactus_comments_client_systemd_wanted_services_list_custom }}"
|
||||
matrix_cactus_comments_client_systemd_wanted_services_list_auto: []
|
||||
matrix_cactus_comments_client_systemd_wanted_services_list_custom: []
|
@ -0,0 +1,83 @@
|
||||
---
|
||||
|
||||
- name: Ensure matrix-cactus-comments-client paths exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ item.path }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
with_items:
|
||||
- {path: "{{ matrix_cactus_comments_client_base_path }}", when: true}
|
||||
- {path: "{{ matrix_cactus_comments_client_public_path }}", when: true}
|
||||
when: "item.when | bool"
|
||||
|
||||
- name: Ensure matrix-cactus-comments-client is configured
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ item.dest }}"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- src: "{{ role_path }}/templates/env.j2"
|
||||
dest: "{{ matrix_cactus_comments_client_base_path }}/env"
|
||||
|
||||
- src: "{{ role_path }}/templates/labels.j2"
|
||||
dest: "{{ matrix_cactus_comments_client_base_path }}/labels"
|
||||
|
||||
- when: matrix_cactus_comments_client_local_dir | length == 0
|
||||
block:
|
||||
- name: Download web client js
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ matrix_cactus_comments_client_webclient_js_url }}"
|
||||
dest: "{{ matrix_cactus_comments_client_public_path }}/cactus.js"
|
||||
mode: "{{ matrix_cactus_comments_client_public_path_file_permissions }}"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
- name: Download web client css
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ matrix_cactus_comments_client_webclient_css_url }}"
|
||||
dest: "{{ matrix_cactus_comments_client_public_path }}/style.css"
|
||||
mode: "{{ matrix_cactus_comments_client_public_path_file_permissions }}"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- when: matrix_cactus_comments_client_local_dir | length > 0
|
||||
block:
|
||||
- name: Upload locally distributed client JS
|
||||
ansible.builtin.copy:
|
||||
src: "{{ matrix_cactus_comments_client_local_dir }}/src/cactus.js"
|
||||
dest: "{{ matrix_cactus_comments_client_public_path }}/cactus.js"
|
||||
mode: "{{ matrix_cactus_comments_client_public_path_file_permissions }}"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
- name: Upload locally distributed client CSS
|
||||
ansible.builtin.copy:
|
||||
src: "{{ matrix_cactus_comments_client_local_dir }}/src/style.css"
|
||||
dest: "{{ matrix_cactus_comments_client_public_path }}/style.css"
|
||||
mode: "{{ matrix_cactus_comments_client_public_path_file_permissions }}"
|
||||
owner: "{{ matrix_user_username }}"
|
||||
group: "{{ matrix_user_groupname }}"
|
||||
|
||||
- name: Ensure matrix-cactus-comments-client container image is pulled
|
||||
community.docker.docker_image:
|
||||
name: "{{ matrix_cactus_comments_client_container_image }}"
|
||||
source: "{{ 'pull' if ansible_version.major > 2 or ansible_version.minor > 7 else omit }}"
|
||||
force_source: "{{ matrix_cactus_comments_client_container_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_cactus_comments_client_container_image_force_pull }}"
|
||||
register: result
|
||||
retries: "{{ devture_playbook_help_container_retries_count }}"
|
||||
delay: "{{ devture_playbook_help_container_retries_delay }}"
|
||||
until: result is not failed
|
||||
|
||||
- name: Ensure matrix-cactus-comments-client container network is created
|
||||
community.general.docker_network:
|
||||
name: "{{ matrix_cactus_comments_client_container_network }}"
|
||||
driver: bridge
|
||||
|
||||
- name: Ensure matrix-cactus-comments-client.service installed
|
||||
ansible.builtin.template:
|
||||
src: "{{ role_path }}/templates/systemd/matrix-cactus-comments-client.service.j2"
|
||||
dest: "{{ devture_systemd_docker_base_systemd_path }}/matrix-cactus-comments-client.service"
|
||||
mode: 0644
|
@ -0,0 +1,20 @@
|
||||
---
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-cactus-comments-client
|
||||
- install-all
|
||||
- install-cactus-comments-client
|
||||
block:
|
||||
- when: matrix_cactus_comments_client_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/validate_config.yml"
|
||||
|
||||
- when: matrix_cactus_comments_client_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/install.yml"
|
||||
|
||||
- tags:
|
||||
- setup-all
|
||||
- setup-cactus-comments-client
|
||||
block:
|
||||
- when: not matrix_cactus_comments_client_enabled | bool
|
||||
ansible.builtin.include_tasks: "{{ role_path }}/tasks/uninstall.yml"
|
@ -0,0 +1,25 @@
|
||||
---
|
||||
|
||||
- name: Check existence of matrix-cactus-comments-client service
|
||||
ansible.builtin.stat:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-cactus-comments-client.service"
|
||||
register: matrix_cactus_comments_client_service_stat
|
||||
|
||||
- when: matrix_cactus_comments_client_service_stat.stat.exists | bool
|
||||
block:
|
||||
- name: Ensure cactus comments is stopped
|
||||
ansible.builtin.service:
|
||||
name: matrix-cactus-comments-client
|
||||
state: stopped
|
||||
enabled: false
|
||||
daemon_reload: true
|
||||
|
||||
- name: Ensure matrix-cactus-comments-client.service doesn't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ devture_systemd_docker_base_systemd_path }}/matrix-cactus-comments-client.service"
|
||||
state: absent
|
||||
|
||||
- name: Ensure Matrix cactus comments paths don't exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ matrix_cactus_comments_client_base_path }}"
|
||||
state: absent
|
@ -0,0 +1,11 @@
|
||||
---
|
||||
|
||||
- name: Fail if required matrix-cactus-comments-client settings not defined
|
||||
ansible.builtin.fail:
|
||||
msg: >-
|
||||
You need to define a required configuration setting (`{{ item }}`).
|
||||
when: "vars[item] == ''"
|
||||
with_items:
|
||||
- matrix_cactus_comments_client_hostname
|
||||
- matrix_cactus_comments_client_path_prefix
|
||||
- matrix_cactus_comments_client_container_network
|
@ -0,0 +1,6 @@
|
||||
SERVER_PORT={{ matrix_cactus_comments_client_environment_variable_server_port }}
|
||||
|
||||
SERVER_LOG_LEVEL={{ matrix_cactus_comments_client_environment_variable_server_log_level }}
|
||||
SERVER_LOG_REMOTE_ADDRESS={{ 'true' if matrix_cactus_comments_client_environment_variable_server_log_remote_address else 'false' }}
|
||||
|
||||
{{ matrix_cactus_comments_client_environment_variables_additional_variables }}
|
@ -0,0 +1,47 @@
|
||||
{% if matrix_cactus_comments_client_container_labels_traefik_enabled %}
|
||||
traefik.enable=true
|
||||
|
||||
{% if matrix_cactus_comments_client_container_labels_traefik_docker_network %}
|
||||
traefik.docker.network={{ matrix_cactus_comments_client_container_labels_traefik_docker_network }}
|
||||
{% endif %}
|
||||
|
||||
traefik.http.services.matrix-cactus-comments-client.loadbalancer.server.port={{ matrix_cactus_comments_client_environment_variable_server_port }}
|
||||
|
||||
{#
|
||||
Public
|
||||
#}
|
||||
{% if matrix_cactus_comments_client_container_labels_public_enabled %}
|
||||
|
||||
{% set public_middlewares = [] %}
|
||||
|
||||
{% if matrix_cactus_comments_client_container_labels_public_traefik_path_prefix != '/' %}
|
||||
{% set public_middlewares = public_middlewares + ['matrix-cactus-comments-client-strip-prefix'] %}
|
||||
traefik.http.middlewares.matrix-cactus-comments-client-strip-prefix.stripprefix.prefixes={{ matrix_cactus_comments_client_container_labels_public_traefik_path_prefix }}
|
||||
{% endif %}
|
||||
|
||||
traefik.http.routers.matrix-cactus-comments-client-base-domain.rule={{ matrix_cactus_comments_client_container_labels_public_traefik_rule }}
|
||||
|
||||
{% if matrix_cactus_comments_client_container_labels_public_traefik_priority | int > 0 %}
|
||||
traefik.http.routers.matrix-cactus-comments-client-base-domain.priority={{ matrix_cactus_comments_client_container_labels_public_traefik_priority }}
|
||||
{% endif %}
|
||||
|
||||
{% if public_middlewares | length > 0 %}
|
||||
traefik.http.routers.matrix-cactus-comments-client-base-domain.middlewares={{ public_middlewares | join(',') }}
|
||||
{% endif %}
|
||||
|
||||
traefik.http.routers.matrix-cactus-comments-client-base-domain.service=matrix-cactus-comments-client
|
||||
traefik.http.routers.matrix-cactus-comments-client-base-domain.entrypoints={{ matrix_cactus_comments_client_container_labels_public_traefik_entrypoints }}
|
||||
|
||||
traefik.http.routers.matrix-cactus-comments-client-base-domain.tls={{ matrix_cactus_comments_client_container_labels_public_traefik_tls | to_json }}
|
||||
{% if matrix_cactus_comments_client_container_labels_public_traefik_tls %}
|
||||
traefik.http.routers.matrix-cactus-comments-client-base-domain.tls.certResolver={{ matrix_cactus_comments_client_container_labels_public_traefik_tls_certResolver }}
|
||||
{% endif %}
|
||||
|
||||
{% endif %}
|
||||
{#
|
||||
/Public
|
||||
#}
|
||||
|
||||
{% endif %}
|
||||
|
||||
{{ matrix_cactus_comments_client_container_labels_additional_labels }}
|
@ -0,0 +1,48 @@
|
||||
#jinja2: lstrip_blocks: "True"
|
||||
[Unit]
|
||||
Description=matrix-cactus-comments-client server
|
||||
{% for service in matrix_cactus_comments_client_systemd_required_services_list %}
|
||||
Requires={{ service }}
|
||||
After={{ service }}
|
||||
{% endfor %}
|
||||
{% for service in matrix_cactus_comments_client_systemd_wanted_services_list %}
|
||||
Wants={{ service }}
|
||||
{% endfor %}
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Environment="HOME={{ devture_systemd_docker_base_systemd_unit_home_path }}"
|
||||
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-cactus-comments-client 2>/dev/null || true'
|
||||
ExecStartPre=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-cactus-comments-client 2>/dev/null || true'
|
||||
|
||||
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} create \
|
||||
--rm \
|
||||
--name=matrix-cactus-comments-client \
|
||||
--log-driver=none \
|
||||
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
|
||||
--cap-drop=ALL \
|
||||
--read-only \
|
||||
--network={{ matrix_cactus_comments_client_container_network }} \
|
||||
{% if matrix_cactus_comments_client_container_http_host_bind_port %}
|
||||
-p {{ matrix_cactus_comments_client_container_http_host_bind_port }}:{{ matrix_cactus_comments_client_environment_variable_server_port }} \
|
||||
{% endif %}
|
||||
--env-file={{ matrix_cactus_comments_client_base_path }}/env \
|
||||
--label-file={{ matrix_cactus_comments_client_base_path }}/labels \
|
||||
--mount type=bind,src={{ matrix_cactus_comments_client_public_path }},dst=/public,ro \
|
||||
{{ matrix_cactus_comments_client_container_image }}
|
||||
|
||||
{% for network in matrix_cactus_comments_client_container_additional_networks %}
|
||||
ExecStartPre={{ devture_systemd_docker_base_host_command_docker }} network connect {{ network }} matrix-cactus-comments-client
|
||||
{% endfor %}
|
||||
|
||||
ExecStart={{ devture_systemd_docker_base_host_command_docker }} start --attach matrix-cactus-comments-client
|
||||
|
||||
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} stop --time={{ devture_systemd_docker_base_container_stop_grace_time_seconds }} matrix-cactus-comments-client 2>/dev/null || true'
|
||||
ExecStop=-{{ devture_systemd_docker_base_host_command_sh }} -c '{{ devture_systemd_docker_base_host_command_docker }} rm matrix-cactus-comments-client 2>/dev/null || true'
|
||||
Restart=always
|
||||
RestartSec=30
|
||||
SyslogIdentifier=matrix-cactus-comments-client
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in new issue