2020-08-12 22:17:53 +03:00
# Deploy using Docker
2020-08-04 23:06:13 +03: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.
2020-08-12 22:17:53 +03:00
## Docker
2023-07-13 19:54:56 +03:00
To run Conduit with Docker you can either build the image yourself or pull it from a registry.
2023-06-28 19:51:44 +03:00
### Use a registry
2023-07-21 21:33:32 +03:00
OCI images for Conduit are available in the registries listed below. We recommend using the image tagged as `latest` from GitLab's own registry.
| Registry | Image | Size | Notes |
| --------------- | --------------------------------------------------------------- | ----------------------------- | ---------------------- |
| GitLab Registry | [registry.gitlab.com/famedly/conduit/matrix-conduit:latest][gl] | ![Image Size][shield-latest] | Stable image. |
| Docker Hub | [docker.io/matrixconduit/matrix-conduit:latest][dh] | ![Image Size][shield-latest] | Stable image. |
| GitLab Registry | [registry.gitlab.com/famedly/conduit/matrix-conduit:next][gl] | ![Image Size][shield-next] | Development version. |
| Docker Hub | [docker.io/matrixconduit/matrix-conduit:next][dh] | ![Image Size][shield-next] | Development version. |
2023-06-28 19:51:44 +03:00
[dh]: https://hub.docker.com/r/matrixconduit/matrix-conduit
[gl]: https://gitlab.com/famedly/conduit/container_registry/2497937
2023-07-21 21:33:32 +03:00
[shield-latest]: https://img.shields.io/docker/image-size/matrixconduit/matrix-conduit/latest
[shield-next]: https://img.shields.io/docker/image-size/matrixconduit/matrix-conduit/next
2023-06-28 19:51:44 +03:00
Use
```bash
docker image pull < link >
```
to pull it to your machine.
### Build using a dockerfile
2020-08-12 22:17:53 +03:00
2020-08-04 23:06:13 +03:00
The Dockerfile provided by Conduit has two stages, each of which creates an image.
2021-11-21 20:34:08 +03:00
1. **Builder:** Builds the binary from local context or by cloning a git revision from the official repository.
2. **Runner:** Copies the built binary from **Builder** and sets up the runtime environment, like creating a volume to persist the database and applying the correct permissions.
2020-08-04 23:06:13 +03:00
To build the image you can use the following command
2021-11-21 20:34:08 +03:00
```bash
docker build --tag matrixconduit/matrix-conduit:latest .
2020-08-04 23:06:13 +03:00
```
2020-08-25 00:30:39 +03:00
which also will tag the resulting image as `matrixconduit/matrix-conduit:latest` .
2020-08-12 22:17:53 +03:00
2023-06-28 19:51:44 +03:00
2020-08-12 22:17:53 +03:00
### Run
2023-06-28 19:51:44 +03:00
When you have the image you can simply run it with
2020-08-04 23:06:13 +03:00
2021-11-21 20:34:08 +03:00
```bash
2022-02-13 15:38:13 +03:00
docker run -d -p 8448:6167 \
-v db:/var/lib/matrix-conduit/ \
-e CONDUIT_SERVER_NAME="your.server.name" \
-e CONDUIT_DATABASE_BACKEND="rocksdb" \
-e CONDUIT_ALLOW_REGISTRATION=true \
-e CONDUIT_ALLOW_FEDERATION=true \
-e CONDUIT_MAX_REQUEST_SIZE="20_000_000" \
-e CONDUIT_TRUSTED_SERVERS="[\"matrix.org\"]" \
-e CONDUIT_MAX_CONCURRENT_REQUESTS="100" \
2022-06-26 17:26:04 +03:00
-e CONDUIT_LOG="warn,rocket=off,_=off,sled=off" \
2023-07-21 21:33:32 +03:00
--name conduit < link >
2020-08-04 23:06:13 +03:00
```
2023-06-28 19:51:44 +03:00
or you can use [docker-compose ](#docker-compose ).
2021-08-17 15:44:53 +03:00
The `-d` flag lets the container run in detached mode. You now need to supply a `conduit.toml` config file, an example can be found [here ](../conduit-example.toml ).
2021-03-16 11:14:11 +03:00
You can pass in different env vars to change config values on the fly. You can even configure Conduit completely by using env vars, but for that you need
2021-08-17 15:44:53 +03:00
to pass `-e CONDUIT_CONFIG=""` into your container. For an overview of possible values, please take a look at the `docker-compose.yml` file.
2020-08-04 23:06:13 +03:00
If you just want to test Conduit for a short time, you can use the `--rm` flag, which will clean up everything related to your container after you stop it.
2020-08-12 22:17:53 +03:00
## Docker-compose
2022-02-19 19:06:06 +03: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;
- 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 )
When picking the traefik-related compose file, rename it so it matches `docker-compose.yml` , and
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 23:06:13 +03:00
2020-08-12 22:17:53 +03:00
### Build
2020-08-04 23:06:13 +03: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 20:34:08 +03:00
```bash
docker-compose up
2020-08-04 23:06:13 +03:00
```
2021-11-21 20:34:08 +03: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 22:17:53 +03:00
### Run
2021-08-17 15:44:53 +03: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 23:06:13 +03:00
2021-11-21 20:34:08 +03:00
```bash
2020-08-04 23:06:13 +03:00
docker-compose up -d
```
2021-08-17 15:44:53 +03:00
> **Note:** Don't forget to modify and adjust the compose file to your needs.
### Use Traefik as Proxy
2022-02-19 19:06:06 +03:00
As a container user, you probably know about Traefik. It is a easy to use reverse proxy for making
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
2023-07-29 09:26:34 +03:00
[`docker-compose.override.yml` ](docker-compose.override.yml ), it is equally easy to deploy
2022-02-19 19:06:06 +03:00
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 15:44:53 +03:00
With the service `well-known` we use a single `nginx` container that will serve those two files.
So...step by step:
2023-07-29 09:26:34 +03:00
1. Copy [`docker-compose.for-traefik.yml` ](docker-compose.for-traefik.yml ) (or
2023-07-29 11:02:56 +03:00
[`docker-compose.with-traefik.yml` ](docker-compose.with-traefik.yml )) and [`docker-compose.override.yml` ](docker-compose.override.yml ) from the repository and remove `.for-traefik` (or `.with-traefik` ) from the filename.
2021-08-17 15:44:53 +03:00
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.
3. Create the `conduit.toml` config file, an example can be found [here ](../conduit-example.toml ), or set `CONDUIT_CONFIG=""` and configure Conduit per env vars.
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 20:34:08 +03: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 16:06:21 +03:00
location /.well-known/matrix/server {
return 200 '{"m.server": "< SUBDOMAIN > .< DOMAIN > :443"}';
2022-11-08 18:56:24 +03:00
types { } default_type "application/json; charset=utf-8";
2021-11-21 20:34:08 +03:00
}
2022-01-07 16:06:21 +03:00
location /.well-known/matrix/client {
return 200 '{"m.homeserver": {"base_url": "https://< SUBDOMAIN > .< DOMAIN > "}}';
2022-11-08 18:56:24 +03:00
types { } default_type "application/json; charset=utf-8";
2022-01-07 16:06:21 +03:00
add_header "Access-Control-Allow-Origin" *;
}
location / {
return 404;
}
2021-11-21 20:34:08 +03:00
}
```
2021-08-17 15:44:53 +03:00
6. Run `docker-compose up -d`
2022-02-12 12:29:04 +03: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.