174 lines
6.5 KiB
YAML
174 lines
6.5 KiB
YAML
|
---
|
||
|
# Infrastructure
|
||
|
# Ansible instructions to deploy the infrastructure
|
||
|
# Copyright (C) 2019-2020 Christoph (Sheogorath) Kern
|
||
|
# Copyright (C) 2019-2020 Alexander (w4tsn) Wellbrock
|
||
|
# Copyright (C) 2020 Saibotk
|
||
|
#
|
||
|
# This program is free software: you can redistribute it and/or modify
|
||
|
# it under the terms of the GNU General Public License as published by
|
||
|
# the Free Software Foundation, version 3 of the License.
|
||
|
#
|
||
|
# This program is distributed in the hope that it will be useful,
|
||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
# GNU General Public License for more details.
|
||
|
#
|
||
|
# You should have received a copy of the GNU General Public License
|
||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
|
#
|
||
|
|
||
|
version: '2'
|
||
|
services:
|
||
|
synapse:
|
||
|
image: docker.io/matrixdotorg/synapse:{{ matrix_synapse_image_version }}
|
||
|
cpu_shares: 256
|
||
|
mem_limit: 1280mb
|
||
|
memswap_limit: 1536mb
|
||
|
read_only: true
|
||
|
restart: always
|
||
|
security_opt:
|
||
|
- no-new-privileges
|
||
|
tmpfs:
|
||
|
- "/tmp:size=64M"
|
||
|
- "/compiled:size=128K"
|
||
|
environment:
|
||
|
{% for key, value in matrix_synapse_options.items() %}
|
||
|
- "SYNAPSE_{{ key }}={{ value }}"
|
||
|
{% endfor %}
|
||
|
|
||
|
- "POSTGRES_HOST=database"
|
||
|
- "POSTGRES_PASSWORD={{ matrix_database_password }}"
|
||
|
volumes:
|
||
|
- "{{ matrix_data_location }}:/data"
|
||
|
depends_on:
|
||
|
- database
|
||
|
labels:
|
||
|
- "traefik.http.routers.matrix.rule=Host(`{{ matrix_synapse_servername }}`) && PathPrefix(`/_matrix/federation`) || Host(`{{ matrix_synapse_domain }}`) && PathPrefix(`/`)"
|
||
|
- "traefik.http.routers.matrix.entrypoints=websecure"
|
||
|
- "traefik.http.routers.matrix.tls.certresolver={{ matrix_traefik_certresolver }}"
|
||
|
- "traefik.http.routers.matrix.middlewares=matrix,compress"
|
||
|
- "traefik.http.routers.matrix.service=matrix"
|
||
|
- "traefik.http.services.matrix.loadbalancer.server.port=8008"
|
||
|
- "traefik.http.middlewares.matrix.headers.sslredirect=true"
|
||
|
- "traefik.http.middlewares.matrix.headers.stsSeconds=63072000"
|
||
|
- "traefik.http.middlewares.matrix.headers.referrerPolicy=no-referrer"
|
||
|
|
||
|
- "traefik.enable=true"
|
||
|
{% if proxy_network is defined %}
|
||
|
- "traefik.docker.network={{ proxy_network }}"
|
||
|
{% endif %}
|
||
|
{% if proxy_hiddenservice is defined and proxy_hiddenservice.content is defined %}
|
||
|
- "traefik.http.middlewares.matrix.headers.customresponseheaders.alt-svc=h2={{ proxy_hiddenservice['content'] | b64decode | trim }}:443; ma=2592000"
|
||
|
{% endif %}
|
||
|
|
||
|
networks:
|
||
|
database:
|
||
|
{% if proxy_network is defined %}
|
||
|
{{ proxy_network }}:
|
||
|
{% endif %}
|
||
|
|
||
|
database:
|
||
|
image: docker.io/postgres:{{ matrix_database_image_version }}
|
||
|
mem_limit: 512mb
|
||
|
memswap_limit: 768mb
|
||
|
read_only: true
|
||
|
security_opt:
|
||
|
- no-new-privileges
|
||
|
tmpfs:
|
||
|
- /run/postgresql:size=512K
|
||
|
- /tmp:size=128K
|
||
|
stop_grace_period: 2m
|
||
|
stop_signal: SIGINT
|
||
|
environment:
|
||
|
- "POSTGRES_USER=synapse"
|
||
|
- "POSTGRES_PASSWORD={{ matrix_database_password }}"
|
||
|
- "POSTGRES_INITDB_ARGS=--lc-collate C --lc-ctype C --encoding UTF8"
|
||
|
volumes:
|
||
|
- "{{ matrix_database_location }}:/var/lib/postgresql/data"
|
||
|
networks:
|
||
|
database:
|
||
|
restart: always
|
||
|
|
||
|
delegate:
|
||
|
image: docker.io/nginx:{{ matrix_delegate_nginx_image_version }}
|
||
|
mem_limit: 256mb
|
||
|
memswap_limit: 512mb
|
||
|
read_only: true
|
||
|
tmpfs:
|
||
|
- "/var/cache/nginx:size=10M"
|
||
|
- "/run/nginx:size=512K"
|
||
|
- "/tmp:size=128K"
|
||
|
security_opt:
|
||
|
- no-new-privileges
|
||
|
volumes:
|
||
|
- "{{ matrix_install_location }}/server-delegation.json:/usr/share/nginx/html/.well-known/matrix/server:ro"
|
||
|
- "{{ matrix_install_location }}/client-delegation.json:/usr/share/nginx/html/.well-known/matrix/client:ro"
|
||
|
- "{{ matrix_install_location }}/nginx.conf:/etc/nginx/nginx.conf:ro"
|
||
|
labels:
|
||
|
- "traefik.enable=true"
|
||
|
|
||
|
- "traefik.http.routers.matrix-delegate.rule=Host(`{{ matrix_synapse_servername }}`) && PathPrefix(`/.well-known/matrix`)"
|
||
|
- "traefik.http.routers.matrix-delegate.entrypoints=websecure"
|
||
|
- "traefik.http.routers.matrix-delegate.tls.certresolver={{ matrix_traefik_certresolver }}"
|
||
|
- "traefik.http.routers.matrix-delegate.middlewares=matrix-delegate,compress"
|
||
|
- "traefik.http.middlewares.matrix-delegate.headers.sslredirect=true"
|
||
|
- "traefik.http.middlewares.matrix-delegate.headers.stsSeconds=63072000"
|
||
|
- "traefik.http.middlewares.matrix-delegate.headers.referrerPolicy=no-referrer"
|
||
|
|
||
|
{% if proxy_network is defined %}
|
||
|
- "traefik.docker.network={{ proxy_network }}"
|
||
|
{% endif %}
|
||
|
{% if proxy_hiddenservice['content'] is defined %}
|
||
|
- "traefik.http.middlewares.matrix-delegate.headers.customresponseheaders.alt-svc:h2={{ proxy_hiddenservice['content'] | b64decode | trim }}:443; ma=2592000"
|
||
|
{% endif %}
|
||
|
restart: always
|
||
|
{% if proxy_network is defined %}
|
||
|
networks:
|
||
|
{{ proxy_network }}:
|
||
|
{% endif %}
|
||
|
|
||
|
elementweb:
|
||
|
image: docker.io/vectorim/riot-web:{{ matrix_elementweb_image_version }}
|
||
|
mem_limit: 512mb
|
||
|
memswap_limit: 768mb
|
||
|
read_only: true
|
||
|
security_opt:
|
||
|
- no-new-privileges
|
||
|
tmpfs:
|
||
|
- "/var/cache/nginx:size=10M"
|
||
|
- "/run:size=512K"
|
||
|
- "/tmp:rw,noexec,nosuid,size=10M"
|
||
|
labels:
|
||
|
- "traefik.enable=true"
|
||
|
|
||
|
- "traefik.http.routers.matrix-elementweb.rule=Host(`{{ matrix_elementweb_domain }}`) && PathPrefix(`/`)"
|
||
|
- "traefik.http.routers.matrix-elementweb.entrypoints=websecure"
|
||
|
- "traefik.http.routers.matrix-elementweb.tls.certresolver={{ matrix_traefik_certresolver }}"
|
||
|
- "traefik.http.routers.matrix-elementweb.middlewares=matrix-elementweb,compress"
|
||
|
- "traefik.http.middlewares.matrix-elementweb.headers.sslredirect=true"
|
||
|
- "traefik.http.middlewares.matrix-elementweb.headers.stsSeconds=63072000"
|
||
|
- "traefik.http.middlewares.matrix-elementweb.headers.referrerPolicy=no-referrer"
|
||
|
|
||
|
{% if proxy_network is defined %}
|
||
|
- "traefik.docker.network={{ proxy_network }}"
|
||
|
{% endif %}
|
||
|
{% if proxy_hiddenservice['content'] is defined %}
|
||
|
- "traefik.http.middlewares.matrix-elementweb.headers.customresponseheaders.alt-svc:h2={{ proxy_hiddenservice['content'] | b64decode | trim }}:443; ma=2592000"
|
||
|
{% endif %}
|
||
|
volumes:
|
||
|
- "{{ matrix_elementweb_location }}/config.json:/app/config.json:ro"
|
||
|
{% if proxy_network is defined %}
|
||
|
networks:
|
||
|
{{ proxy_network }}:
|
||
|
{% endif %}
|
||
|
restart: always
|
||
|
|
||
|
networks:
|
||
|
database:
|
||
|
internal: true
|
||
|
{% if proxy_network is defined %}
|
||
|
{{ proxy_network }}:
|
||
|
external: true
|
||
|
{% endif %}
|