summary refs log tree commit diff
path: root/contrib/docker/docker-compose.yml
blob: 36d5fd53096a17a6a38b943e9ca68cd9c5c92a1e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# This compose file is compatible with Compose itself, it might need some
# adjustments to run properly with stack.

version: '3'

services:

  synapse:
    build:
      context: ../..
      dockerfile: docker/Dockerfile
    image: docker.io/matrixdotorg/synapse:latest
    # Since synapse does not retry to connect to the database, restart upon
    # failure
    restart: unless-stopped
    # See the readme for a full documentation of the environment settings
    # NOTE: You must edit homeserver.yaml to use postgres, it defaults to sqlite
    environment:
      - SYNAPSE_CONFIG_PATH=/data/homeserver.yaml
    volumes:
      # You may either store all the files in a local folder
      - ./files:/data
      # .. or you may split this between different storage points
      # - ./files:/data
      # - /path/to/ssd:/data/uploads
      # - /path/to/large_hdd:/data/media
    depends_on:
      - db
    # In order to expose Synapse, remove one of the following, you might for
    # instance expose the TLS port directly:
    ports:
      - 8448:8448/tcp
    # ... or use a reverse proxy, here is an example for traefik:
    labels:
      # The following lines are valid for Traefik version 1.x:
      - traefik.enable=true
      - traefik.frontend.rule=Host:my.matrix.Host
      - traefik.port=8008
      # Alternatively, for Traefik version 2.0:
      - traefik.enable=true
      - traefik.http.routers.http-synapse.entryPoints=http
      - traefik.http.routers.http-synapse.rule=Host(`my.matrix.host`)
      - traefik.http.middlewares.https_redirect.redirectscheme.scheme=https
      - traefik.http.middlewares.https_redirect.redirectscheme.permanent=true
      - traefik.http.routers.http-synapse.middlewares=https_redirect
      - traefik.http.routers.https-synapse.entryPoints=https
      - traefik.http.routers.https-synapse.rule=Host(`my.matrix.host`)
      - traefik.http.routers.https-synapse.service=synapse
      - traefik.http.routers.https-synapse.tls=true
      - traefik.http.services.synapse.loadbalancer.server.port=8008
      - traefik.http.routers.https-synapse.tls.certResolver=le-ssl

  db:
    image: docker.io/postgres:12-alpine
    # Change that password, of course!
    environment:
      - POSTGRES_USER=synapse
      - POSTGRES_PASSWORD=changeme
      # ensure the database gets created correctly
      # https://element-hq.github.io/synapse/latest/postgres.html#set-up-database
      - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
    volumes:
      # You may store the database tables in a local folder..
      - ./schemas:/var/lib/postgresql/data
      # .. or store them on some high performance storage for better results
      # - /path/to/ssd/storage:/var/lib/postgresql/data