diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..c142139 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.env +data/ +misc/ +progs/ diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..dd815b6 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,288 @@ +version: '3' + +services: + #autoheal: + # restart: always + # image: willfarrell/autoheal + # environment: + # - AUTOHEAL_CONTAINER_LABEL=synapse-autoheal + # volumes: + # - /var/run/docker.sock:/var/run/docker.sock + + postgres: + image: postgres:latest + environment: + - POSTGRES_USER=synapse + - POSTGRES_PASSWORD + - POSTGRES_DB=synapsedb + - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C + volumes: + - ./data/postgres:/var/lib/postgresql/data/ + - ./progs:/progs + networks: + default: + grafana: + aliases: + - synapse_postgres + restart: always + healthcheck: + test: pg_isready -U synapse -d synapsedb + interval: 10s + timeout: 5s + retries: 5 + + redis: + image: redis:latest + restart: always + networks: + default: + grafana: + aliases: + - synapse_redis + healthcheck: + test: ["CMD", "redis-cli", "ping"] + interval: 10s + timeout: 3s + retries: 3 + + synapse: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + environment: + - SYNAPSE_CONFIG_PATH=/data/homeserver.yaml + volumes: + - ./data/synapse:/data + depends_on: + postgres: + condition: service_healthy + redis: + condition: service_healthy + ports: + - 127.0.0.1:8008:8008/tcp + labels: + synapse-autoheal: "true" + mem_limit: 2G + + sender1: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/sender1.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.federation_sender + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + healthcheck: + disable: true + mem_limit: 2G + + sender2: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/sender2.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.federation_sender + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + healthcheck: + disable: true + mem_limit: 2G + + sender3: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/sender3.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.federation_sender + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + healthcheck: + disable: true + mem_limit: 2G + + sender4: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/sender4.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.federation_sender + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + healthcheck: + disable: true + mem_limit: 2G + + media: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/media.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.media_repository + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + ports: + - 127.0.0.1:8009:8008 + labels: + synapse-autoheal: "true" + mem_limit: 2G + + generic1: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/generic.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.generic_worker + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + ports: + - 127.0.0.1:8010:8008/tcp + labels: + synapse-autoheal: "true" + mem_limit: 2G + + generic2: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/generic.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.generic_worker + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + ports: + - 127.0.0.1:8011:8008/tcp + labels: + synapse-autoheal: "true" + mem_limit: 2G + + generic3: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/generic.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.generic_worker + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + ports: + - 127.0.0.1:8012:8008/tcp + labels: + synapse-autoheal: "true" + mem_limit: 2G + + generic4: + image: matrixdotorg/synapse:$SYNAPSE_TAG + restart: always + command: ["run", "--config-path=/data/homeserver.yaml", "--config-path=/workers/replication.yaml", "--config-path=/workers/generic.yaml"] + environment: + - SYNAPSE_WORKER=synapse.app.generic_worker + volumes: + - ./data/synapse:/data + - ./workers:/workers + depends_on: + synapse: + condition: service_healthy + ports: + - 127.0.0.1:8013:8008/tcp + labels: + synapse-autoheal: "true" + mem_limit: 2G + + #synapse-admin: + # image: awesometechnologies/synapse-admin:latest + # restart: always + # ports: + # - 127.0.0.1:8007:80 + # environment: + # - REACT_APP_SERVER=https://matrix.boba.best + # healthcheck: + # test: curl -fSs http://localhost:80 || exit 1 + # interval: 15s + # timeout: 5s + # retries: 5 + # labels: + # synapse-autoheal: "true" + + #borgmatic: + # image: b3vis/borgmatic:latest + # restart: always + # volumes: + # - ./data:/mnt/source/data:ro + # - ./borgmatic/etc:/etc/borgmatic.d:Z + # - ./borgmatic/state:/root/.config/borg:Z + # - ./borgmatic/ssh:/root/.ssh:Z + # environment: + # - TZ=America/Chicago + # - BORG_PASSPHRASE + # depends_on: + # postgres: + # condition: service_healthy + + prometheus: + image: prom/prometheus:latest + restart: always + command: + - --config.file=/etc/prometheus/prometheus.yml + volumes: + - ./data/prometheus.yml:/etc/prometheus/prometheus.yml + - ./data/prometheus:/prometheus + ports: + - 127.0.0.1:9090:9090 + networks: + default: + grafana: + aliases: + - synapse_prometheus + + redis_exporter: + image: oliver006/redis_exporter + restart: always + environment: + - REDIS_ADDR=redis://redis:6379 + depends_on: + redis: + condition: service_healthy + + postgres_exporter: + image: quay.io/prometheuscommunity/postgres-exporter:latest + restart: always + environment: + - DATA_SOURCE_NAME=postgresql://synapse:$POSTGRES_PASSWORD@postgres:5432/synapsedb?sslmode=disable + depends_on: + postgres: + condition: service_healthy + + +networks: + grafana: + external: true + name: grafana_default diff --git a/manage.sh b/manage.sh new file mode 100755 index 0000000..ab5cef4 --- /dev/null +++ b/manage.sh @@ -0,0 +1,46 @@ +#!/bin/sh + +case "$1" in + echo) + shift + echo $@ + ;; + + borgmatic) + shift + case "$1" in + sh) + sudo docker-compose exec borgmatic sh + ;; + *) + echo "You have to choose a subcommand too, dummy." + ;; + esac + ;; + + logs) + shift + sudo docker-compose logs -f --tail=0 + ;; + + postgres) + shift + case "$1" in + bash) + sudo docker-compose exec postgres bash + ;; + *) + echo "You have to choose a subcommand too, dummy." + ;; + esac + ;; + + psql) + shift + sudo docker-compose exec postgres psql -U synapse -d synapsedb $@ + ;; + + *) + echo "You have to choose a command, dummy." + ;; +esac diff --git a/workers/generic.yaml b/workers/generic.yaml new file mode 100644 index 0000000..b048360 --- /dev/null +++ b/workers/generic.yaml @@ -0,0 +1,11 @@ +worker_app: synapse.app.generic_worker + +worker_listeners: + - type: http + port: 8008 + x_forwarded: true + resources: + - names: + - client + - federation + - metrics diff --git a/workers/media.yaml b/workers/media.yaml new file mode 100644 index 0000000..8fe3c24 --- /dev/null +++ b/workers/media.yaml @@ -0,0 +1,11 @@ +worker_app: synapse.app.media_repository +worker_name: media + +worker_listeners: + - type: http + port: 8008 + x_forwarded: true + resources: + - names: + - media + - metrics diff --git a/workers/replication.yaml b/workers/replication.yaml new file mode 100644 index 0000000..1d4cf98 --- /dev/null +++ b/workers/replication.yaml @@ -0,0 +1,2 @@ +worker_replication_host: synapse +worker_replication_http_port: 9093 diff --git a/workers/sender1.yaml b/workers/sender1.yaml new file mode 100644 index 0000000..32f4b84 --- /dev/null +++ b/workers/sender1.yaml @@ -0,0 +1,10 @@ +worker_app: synapse.app.federation_sender +worker_name: sender1 + +worker_listeners: + - type: http + port: 8008 + x_forwarded: true + resources: + - names: + - metrics diff --git a/workers/sender2.yaml b/workers/sender2.yaml new file mode 100644 index 0000000..c4861c3 --- /dev/null +++ b/workers/sender2.yaml @@ -0,0 +1,10 @@ +worker_app: synapse.app.federation_sender +worker_name: sender2 + +worker_listeners: + - type: http + port: 8008 + x_forwarded: true + resources: + - names: + - metrics diff --git a/workers/sender3.yaml b/workers/sender3.yaml new file mode 100644 index 0000000..52527b0 --- /dev/null +++ b/workers/sender3.yaml @@ -0,0 +1,10 @@ +worker_app: synapse.app.federation_sender +worker_name: sender3 + +worker_listeners: + - type: http + port: 8008 + x_forwarded: true + resources: + - names: + - metrics diff --git a/workers/sender4.yaml b/workers/sender4.yaml new file mode 100644 index 0000000..eee0b81 --- /dev/null +++ b/workers/sender4.yaml @@ -0,0 +1,10 @@ +worker_app: synapse.app.federation_sender +worker_name: sender4 + +worker_listeners: + - type: http + port: 8008 + x_forwarded: true + resources: + - names: + - metrics