2020-08-12 21:17:53 +02:00
# Deploy using Docker
2022-02-06 17:48:06 +01:00
{{#include ../_getting_help.md}}
2020-08-04 22:06:13 +02:00
> **Note:** To run and use Conduit you should probably use it with a Domain or Subdomain behind a reverse proxy (like Nginx, Traefik, Apache, ...) with a Lets Encrypt certificate.
2022-02-06 17:48:06 +01:00
### Get the image
[![Image Size][shield]][dh] [![Image pulls][pulls]][dh]
You can download the latest release version of Conduit as a pre-built multi-arch docker image from [Docker Hub][dh]:
```bash
docker pull matrixconduit/matrix-conduit:latest
```
If you are feeling adventurous, you can also use the unstable, in-development version:
```bash
docker pull matrixconduit/matrix-conduit:next
```
[dh]: https://hub.docker.com/r/matrixconduit/matrix-conduit
[shield]: https://img.shields.io/docker/image-size/matrixconduit/matrix-conduit/latest
[pulls]: https://img.shields.io/docker/pulls/matrixconduit/matrix-conduit
\
2020-08-12 21:17:53 +02:00
2022-02-06 17:48:06 +01:00
< details >
< summary > Want to build your own image?< / summary >
2020-08-12 21:17:53 +02:00
2022-02-06 17:48:06 +01:00
Clone the repo and enter it:
2020-08-04 22:06:13 +02:00
2022-02-06 17:48:06 +01:00
```bash
git clone --depth 1 https://gitlab.com/famedly/conduit.git
cd conduit
```
2020-08-04 22:06:13 +02:00
2022-02-06 17:48:06 +01:00
Then, build the image:
2020-08-04 22:06:13 +02:00
2021-11-21 17:34:08 +00:00
```bash
docker build --tag matrixconduit/matrix-conduit:latest .
2020-08-04 22:06:13 +02:00
```
2022-02-06 17:48:06 +01:00
> ⏳ This can take quite some time, as it does a full release build. Depending on your hardware, this may take between 15 and 60 minutes.
2020-08-12 21:17:53 +02:00
2022-02-06 17:48:06 +01:00
If you want to change the userid:groupid under which Conduit will run in the container, you can customize them with build args:
```bash
docker build \
--build-arg USER_ID=1000 \
--build-arg GROUP_ID=1000 \
--tag matrixconduit/matrix-conduit:latest .
```
By default, `USER_ID` and `GROUP_ID` are both set to `1000` .
2020-08-12 21:17:53 +02:00
2022-02-06 17:48:06 +01:00
< / details >
### Run
2020-08-04 22:06:13 +02:00
2021-11-21 17:34:08 +00:00
```bash
2022-02-06 17:48:06 +01:00
docker run -d -p 6167:6167 \
2022-02-13 12:38:13 +00:00
-v db:/var/lib/matrix-conduit/ \
-e CONDUIT_SERVER_NAME="your.server.name" \
-e CONDUIT_DATABASE_BACKEND="rocksdb" \
2022-02-06 17:48:06 +01:00
-e CONDUIT_ALLOW_REGISTRATION="true" \
-e CONDUIT_ALLOW_FEDERATION="true" \
2022-02-13 12:38:13 +00:00
-e CONDUIT_MAX_REQUEST_SIZE="20_000_000" \
2022-02-06 17:48:06 +01:00
-e CONDUIT_TRUSTED_SERVERS='[\"matrix.org\"]' \
2022-02-13 12:38:13 +00:00
-e CONDUIT_MAX_CONCURRENT_REQUESTS="100" \
-e CONDUIT_LOG="info,rocket=off,_=off,sled=off" \
2022-02-06 17:48:06 +01:00
--name "conduit" \
matrixconduit/matrix-conduit:latest
2020-08-04 22:06:13 +02:00
```
2022-02-06 17:48:06 +01:00
The `-d` flag lets the container run in detached mode.
2021-08-17 14:44:53 +02:00
2022-02-06 17:48:06 +01:00
> ⚠️ When running Conduit with docker, you are expected to configure it only with environment variables, not via a config.toml.
>
> Where you would use `server_name` in the config.toml, use `CONDUIT_SERVER_NAME` as the env var.
2021-11-21 17:34:08 +00:00
2022-02-06 17:48:06 +01:00
If you just want to test Conduit for a short time, you can also supply the `--rm` flag, which will clean up everything related to your container after you stop it.
2020-08-04 22:06:13 +02:00
2020-08-12 21:17:53 +02:00
## Docker-compose
2022-02-19 17:06:06 +01:00
If the `docker run` command is not for you or your setup, you can also use one of the provided `docker-compose` files.
Depending on your proxy setup, you can use one of the following files;
2022-02-06 17:48:06 +01:00
2022-02-19 17:06:06 +01:00
- If you already have a `traefik` instance set up, use [`docker-compose.for-traefik.yml` ](docker-compose.for-traefik.yml )
- If you don't have a `traefik` instance set up (or any other reverse proxy), use [`docker-compose.with-traefik.yml` ](docker-compose.with-traefik.yml )
- For any other reverse proxy, use [`docker-compose.yml` ](docker-compose.yml )
2022-02-06 17:48:06 +01:00
When picking the traefik-related compose file, rename it, so it matches `docker-compose.yml` , and
2022-02-19 17:06:06 +01:00
rename the override file to `docker-compose.override.yml` . Edit the latter with the values you want
for your server.
Additional info about deploying Conduit can be found [here ](../DEPLOY.md ).
2020-08-04 22:06:13 +02:00
2020-08-12 21:17:53 +02:00
### Build
2020-08-04 22:06:13 +02:00
To build the Conduit image with docker-compose, you first need to open and modify the `docker-compose.yml` file. There you need to comment the `image:` option and uncomment the `build:` option. Then call docker-compose with:
2021-11-21 17:34:08 +00:00
```bash
docker-compose up
2020-08-04 22:06:13 +02:00
```
2021-11-21 17:34:08 +00:00
This will also start the container right afterwards, so if want it to run in detached mode, you also should use the `-d` flag.
2020-08-12 21:17:53 +02:00
### Run
2021-08-17 14:44:53 +02:00
If you already have built the image or want to use one from the registries, you can just start the container and everything else in the compose file in detached mode with:
2020-08-04 22:06:13 +02:00
2021-11-21 17:34:08 +00:00
```bash
2020-08-04 22:06:13 +02:00
docker-compose up -d
```
2021-08-17 14:44:53 +02:00
> **Note:** Don't forget to modify and adjust the compose file to your needs.
### Use Traefik as Proxy
2022-02-06 17:48:06 +01:00
As a container user, you probably know about Traefik. It is an easy to use reverse proxy for making
2022-02-19 17:06:06 +01:00
containerized app and services available through the web. With the two provided files,
[`docker-compose.for-traefik.yml` ](docker-compose.for-traefik.yml ) (or
[`docker-compose.with-traefik.yml` ](docker-compose.with-traefik.yml )) and
[`docker-compose.override.yml` ](docker-compose.override.traefik.yml ), it is equally easy to deploy
and use Conduit, with a little caveat. If you already took a look at the files, then you should have
seen the `well-known` service, and that is the little caveat. Traefik is simply a proxy and
loadbalancer and is not able to serve any kind of content, but for Conduit to federate, we need to
either expose ports `443` and `8448` or serve two endpoints `.well-known/matrix/client` and
`.well-known/matrix/server` .
2021-08-17 14:44:53 +02:00
With the service `well-known` we use a single `nginx` container that will serve those two files.
2022-02-06 17:48:06 +01:00
So... step by step:
2021-08-17 14:44:53 +02:00
1. Copy [`docker-compose.traefik.yml` ](docker-compose.traefik.yml ) and [`docker-compose.override.traefik.yml` ](docker-compose.override.traefik.yml ) from the repository and remove `.traefik` from the filenames.
2. Open both files and modify/adjust them to your needs. Meaning, change the `CONDUIT_SERVER_NAME` and the volume host mappings according to your needs.
2022-02-06 17:48:06 +01:00
3. Configure Conduit per env vars.
2021-08-17 14:44:53 +02:00
4. Uncomment the `element-web` service if you want to host your own Element Web Client and create a `element_config.json` .
5. Create the files needed by the `well-known` service.
2021-11-21 17:34:08 +00:00
- `./nginx/matrix.conf` (relative to the compose file, you can change this, but then also need to change the volume mapping)
```nginx
server {
server_name < SUBDOMAIN > .< DOMAIN > ;
listen 80 default_server;
2022-01-07 13:06:21 +00:00
location /.well-known/matrix/server {
return 200 '{"m.server": "< SUBDOMAIN > .< DOMAIN > :443"}';
add_header Content-Type application/json;
2021-11-21 17:34:08 +00:00
}
2022-01-07 13:06:21 +00:00
location /.well-known/matrix/client {
return 200 '{"m.homeserver": {"base_url": "https://< SUBDOMAIN > .< DOMAIN > "}}';
add_header Content-Type application/json;
add_header "Access-Control-Allow-Origin" *;
}
location / {
return 404;
}
2021-11-21 17:34:08 +00:00
}
```
2021-08-17 14:44:53 +02:00
6. Run `docker-compose up -d`
2022-02-12 10:29:04 +01:00
7. Connect to your homeserver with your preferred client and create a user. You should do this immediately after starting Conduit, because the first created user is the admin.