Nuke old Docker stuff (#1104)

* Remove old Docker stuff

* Move hub stuff to upper level docker directory

* Build monolith images

* Update README.md

* Update paths

* Update README.md
This commit is contained in:
Neil Alexander 2020-06-05 19:00:30 +01:00 committed by GitHub
parent e7b19d2c70
commit 67784ecb56
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 67 additions and 585 deletions

View file

@ -1,100 +1,70 @@
Development with Docker
---
# Docker images
With `docker` and `docker-compose` you can easily spin up a development environment
and start working on dendrite.
These are Docker images for Dendrite!
### Requirements
## Dockerfiles
- docker
- docker-compose (version 3+)
The `Dockerfile` builds the base image which contains all of the Dendrite
components. The `Dockerfile.component` file takes the given component, as
specified with `--buildarg component=` from the base image and produce
smaller component-specific images, which are substantially smaller and do
not contain the Go toolchain etc.
### Configuration
## Compose files
Create a directory named `cfg` in the root of the project. Copy the
`dendrite-docker.yaml` file into that directory 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`.
There are three sample `docker-compose` files:
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.deps.yml` which runs the Postgres and Kafka prerequisites
- `docker-compose.monolith.yml` which runs a monolith Dendrite deployment
- `docker-compose.polylith.yml` which runs a polylith Dendrite deployment
## Configuration
The `docker-compose` files refer to the `/etc/dendrite` volume as where the
runtime config should come from. The mounted folder must contain:
- `dendrite.yaml` configuration file (based on the sample `dendrite-config.yaml`
in the `docker/config` folder in the [Dendrite repository](https://github.com/matrix-org/dendrite)
- `matrix_key.pem` server key, as generated using `cmd/generate-keys`
- `server.crt` certificate file
- `server.key` private key file for the above certificate
To generate keys:
```
docker-compose <cmd>
go run github.com/matrix-org/dendrite/cmd/generate-keys \
--private-key=matrix_key.pem \
--tls-cert=server.crt \
--tls-key=server.key
```
### Starting a monolith server
## Starting Dendrite
For the monolith server you would need a postgres instance
Once in place, start the dependencies:
```
docker-compose up postgres
docker-compose -f docker-compose.deps.yml up
```
and the dendrite component from `bin/dendrite-monolith-server`
Wait a few seconds for Kafka and Postgres to finish starting up, and then start a monolith:
```
docker-compose up monolith
docker-compose -f docker-compose.monolith.yml up
```
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
... or start the polylith components:
```
docker-compose up kafka zookeeper postgres
docker-compose -f docker-compose.polylith.yml up
```
and the following dendrite components
## Building the images
```
docker-compose up client_api media_api sync_api room_server public_rooms_api edu_server
docker-compose up client_api_proxy
```
The `docker/images-build.sh` script will build the base image, followed by
all of the component images.
The `client-api-proxy` will be listening on `http://localhost:8008`.
The `docker/images-push.sh` script will push them to Docker Hub (subject
to permissions).
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:
- ..:/build
depends_on:
- another_component
networks:
- internal
```
If you wish to build and push your own images, rename `matrixdotorg/dendrite` to
the name of another Docker Hub repository in `images-build.sh` and `images-push.sh`.