Add a README for the docker setup

This commit is contained in:
Konstantinos Sideris 2018-01-02 17:43:39 +02:00
parent f2ec4ce2ed
commit 2b9c35308f
2 changed files with 231 additions and 0 deletions

105
docker/README.md Normal file
View file

@ -0,0 +1,105 @@
Development with Docker
---
With `docker` and `docker-compose` you can easily spin up a development environment
and start working on dendrite.
### Requirements
- docker
- docker-compose (version 3+)
### Configuration
Copy the `dendrite-docker.yaml` file to the root of the project and rename it to
`dendrite.yaml`. It already contains the defaults used in `docker-compose` for
networking so you will only have to change things like the `server_name` or to
toggle `naffka`.
You can run the following `docker-compose` commands either from the top directory
specifying the `docker-compose` file
```
docker-compose -f docker/docker-compose.yml <cmd>
```
or from within the `docker` directory
```
docker-compose <cmd>
```
### Starting a monolith server
For the monolith server you would need a postgres instance
```
docker-compose up postgres
```
and the dendrite component from `bin/dendrite-monolith-server`
```
docker-compose up monolith
```
The monolith will be listening on `http://localhost:8008`.
You would also have to make the following adjustments to `dendrite.yaml`.
- Set `use_naffka: true`
- Uncomment the `database/naffka` postgres url.
### Starting a multiprocess server
The multiprocess server requires kafka, zookeeper and postgres
```
docker-compose up kafka zookeeper postgres
```
and the following dendrite components
```
docker-compose up client_api media_api sync_api room_server public_rooms_api
docker-compose up client_api_proxy
```
The `client-api-proxy` will be listening on `http://localhost:8008`.
You would also have to make the following adjustments to `dendrite.yaml`.
- Set `use_naffka: false`
- Comment out the `database/naffka` postgres url.
### Starting federation
```
docker-compose up federation_api federation_sender
docker-compose up federation_api_proxy
```
You can point other Matrix servers to `http://localhost:8448`.
### Creating a new component
You can create a new dendrite component by adding an entry to the `docker-compose.yml`
file and creating a startup script for the component in `docker/services`.
For more information refer to the official docker-compose [documentation](https://docs.docker.com/compose/).
```yaml
new_component:
container_name: dendrite_room_server
hostname: new_component
# Start up script.
entrypoint: ["bash", "./docker/services/new-component.sh"]
# Use the common Dockerfile for all the dendrite components.
build: ./
volumes:
- type: bind
source: ../
target: /build
depends_on:
- another_component
networks:
- internal
# Define which ports to expose to the internal network.
ports:
- 1234
```

126
docker/dendrite-docker.yml Normal file
View file

@ -0,0 +1,126 @@
# The config file format version
# This is used by dendrite to tell if it understands the config format.
# This will change if the structure of the config file changes or if the meaning
# of an existing config key changes.
version: 0
# The matrix specific config
matrix:
# The name of the server. This is usually the domain name, e.g 'matrix.org', 'localhost'.
server_name: "example.com"
# The path to the PEM formatted matrix private key.
private_key: "matrix_key.pem"
# The x509 certificates used by the federation listeners for this server
federation_certificates: ["server.crt"]
# The list of identity servers trusted to verify third party identifiers by this server.
# Defaults to no trusted servers.
trusted_third_party_id_servers:
- vector.im
- matrix.org
- riot.im
# The media repository config
media:
# The base path to where the media files will be stored. May be relative or absolute.
base_path: /var/dendrite/media
# The maximum file size in bytes that is allowed to be stored on this server.
# Note: if max_file_size_bytes is set to 0, the size is unlimited.
# Note: if max_file_size_bytes is not set, it will default to 10485760 (10MB)
max_file_size_bytes: 10485760
# Whether to dynamically generate thumbnails on-the-fly if the requested resolution is not already generated
# NOTE: This is a possible denial-of-service attack vector - use at your own risk
dynamic_thumbnails: false
# A list of thumbnail sizes to be pre-generated for downloaded remote / uploaded content
# method is one of crop or scale. If omitted, it will default to scale.
# crop scales to fill the requested dimensions and crops the excess.
# scale scales to fit the requested dimensions and one dimension may be smaller than requested.
thumbnail_sizes:
- width: 32
height: 32
method: crop
- width: 96
height: 96
method: crop
- width: 320
height: 240
method: scale
- width: 640
height: 480
method: scale
- width: 800
height: 600
method: scale
# The config for the TURN server
turn:
# Whether or not guests can request TURN credentials
turn_allow_guests: true
# How long the authorization should last
turn_user_lifetime: "1h"
# The list of TURN URIs to pass to clients
turn_uris: []
# Authorization via Shared Secret
# The shared secret from coturn
turn_shared_secret: "<SECRET STRING GOES HERE>"
# Authorization via Static Username & Password
# Hardcoded Username and Password
turn_username: ""
turn_password: ""
# The config for communicating with kafka
kafka:
# Where the kafka servers are running.
addresses: ["kafka:9092"]
# Whether to use naffka instead of kafka.
# Naffka can only be used when running dendrite as a single monolithic server.
# Kafka can be used both with a monolithic server and when running the
# components as separate servers.
# If enabled database.naffka must also be specified.
use_naffka: true
# The names of the kafka topics to use.
topics:
output_room_event: roomserverOutput
output_client_data: clientapiOutput
user_updates: userUpdates
# The postgres connection configs for connecting to the databases e.g a postgres:// URI
database:
account: "postgres://dendrite:itsasecret@postgres/dendrite_account?sslmode=disable"
device: "postgres://dendrite:itsasecret@postgres/dendrite_device?sslmode=disable"
media_api: "postgres://dendrite:itsasecret@postgres/dendrite_mediaapi?sslmode=disable"
sync_api: "postgres://dendrite:itsasecret@postgres/dendrite_syncapi?sslmode=disable"
room_server: "postgres://dendrite:itsasecret@postgres/dendrite_roomserver?sslmode=disable"
server_key: "postgres://dendrite:itsasecret@postgres/dendrite_serverkey?sslmode=disable"
federation_sender: "postgres://dendrite:itsasecret@postgres/dendrite_federationsender?sslmode=disable"
public_rooms_api: "postgres://dendrite:itsasecret@postgres/dendrite_publicroomsapi?sslmode=disable"
# If using naffka you need to specify a naffka database
naffka: "postgres://dendrite:itsasecret@postgres/dendrite_naffka?sslmode=disable"
# The TCP host:port pairs to bind the internal HTTP APIs to.
# These shouldn't be exposed to the public internet.
# These aren't needed when running dendrite as a monolithic server.
listen:
room_server: "room_server:7770"
client_api: "client_api:7771"
federation_api: "federation_api:7772"
sync_api: "sync_api:7773"
media_api: "media_api:7774"
public_rooms_api: "public_rooms_api:7775"
federation_sender: "federation_sender:7776"
# The configuration for tracing the dendrite components.
tracing:
# Config for the jaeger opentracing reporter.
# See https://godoc.org/github.com/uber/jaeger-client-go/config#Configuration
# for documtation.
jaeger:
disabled: true
# A list of application service config files to use
application_services:
config_files: []