Feat: config pour déployer matrix

This commit is contained in:
Bertrand Benjamin 2022-02-10 20:47:52 +01:00
parent a97deb4efb
commit 80a6fabc66
6 changed files with 2812 additions and 4 deletions

8
.gitignore vendored
View File

@ -1,3 +1,5 @@
./matrix/postgres/data/
./matrix/synapse/media_store/
./traefik/certs/
matrix/postgres/data/
matrix/nginx/www/
matrix/synapse/media_store/
traefik/certs/

View File

@ -6,7 +6,7 @@ https://github.com/matusnovak/homelab
## Traefik
Avant de lancer les contenaires, il faut gérer les certificats
### Before
mkcert -install
mkcert -key-file ./certs/local-key.pem -cert-file ./certs/local-cert.pem localdev 'docker.localdev' '*.docker.localdev'
@ -17,6 +17,14 @@ https://zestedesavoir.com/billets/3355/traefik-v2-https-ssl-en-localhost/
## Matrix
### Before
Make some direcories
mkdir -p nginx/www
mkdir -p postgres/data
mkdir -p synapse/media_store
### Sources
https://gist.github.com/matusnovak/37109e60abe79f4b59fc9fbda10896da

71
matrix/docker-compose.yml Normal file
View File

@ -0,0 +1,71 @@
version: '3'
services:
postgres:
image: "postgres:14.1"
restart: "unless-stopped"
environment:
POSTGRES_PASSWORD: "admin"
volumes:
- "./postgres/data:/var/lib/postgresql/data"
- ./postgres/init.sql:/docker-entrypoint-initdb.d/init.sql
networks:
- matrix
redis:
image: "redis:latest"
restart: "unless-stopped"
networks:
- matrix
synapse:
image: "matrixdotorg/synapse:latest"
restart: "unless-stopped"
environment:
SYNAPSE_CONFIG_DIR: "/data"
SYNAPSE_CONFIG_PATH: "/data/homeserver.yaml"
UID: "1000"
GID: "1000"
TZ: "Europe/Paris"
volumes:
- "./synapse:/data"
labels:
- "traefik.enable=true"
- "traefik.http.services.synapse.loadbalancer.server.port=8008"
- "traefik.http.routers.synapse.rule=Host(`synapse.combava.lan`)"
- "traefik.http.routers.synapse.entrypoints=https"
- "traefik.http.routers.synapse.tls=true"
networks:
- gateway
- matrix
nginx:
image: "nginx:latest"
restart: "unless-stopped"
volumes:
- "./nginx/matrix.conf:/etc/nginx/conf.d/matrix.conf"
- ./nginx/www:/var/www/
labels:
- "traefik.enable=true"
- "traefik.http.routers.matrix.rule=Host(`matrix.combava.lan`)"
- "traefik.http.routers.matrix.entrypoints=https"
- "traefik.http.routers.matrix.tls=true"
networks:
- gateway
element:
image: "vectorim/element-web:latest"
volumes:
- "./element/config.json:/app/config.json:ro"
labels:
- "traefik.enable=true"
- "traefik.http.services.element.loadbalancer.server.port=80"
- "traefik.http.routers.element.rule=Host(`element.combava.lan`)"
- "traefik.http.routers.element.entrypoints=https"
- "traefik.http.routers.element.tls=true"
networks:
- gateway
networks:
matrix:
gateway:
external: true

18
matrix/nginx/matrix.conf Normal file
View File

@ -0,0 +1,18 @@
server {
listen 80 default_server;
server_name matrix.combava.lan;
# Traefik -> nginx -> synapse
location /_matrix {
proxy_pass http://synapse:8008;
proxy_set_header X-Forwarded-For $remote_addr;
client_max_body_size 128m;
}
location /.well-known/matrix/ {
root /var/www/;
default_type application/json;
add_header Access-Control-Allow-Origin *;
}
}

5
matrix/postgres/init.sql Normal file
View File

@ -0,0 +1,5 @@
CREATE ROLE synapse;
ALTER ROLE synapse WITH PASSWORD 'password';
ALTER ROLE synapse WITH LOGIN;
CREATE DATABASE synapse ENCODING 'UTF8' LC_COLLATE='C' LC_CTYPE='C' template=template0 OWNER synapse;
GRANT ALL PRIVILEGES ON DATABASE synapse TO synapse;

File diff suppressed because it is too large Load Diff