From 52a96b3d8404ccfc04ab0e0ba60ed8f9963ba686 Mon Sep 17 00:00:00 2001 From: Daniel Wiesenberg Date: Fri, 12 Mar 2021 18:26:23 +0100 Subject: [PATCH 1/5] Update Dockerfile and docker-compose - Dockerfile now tracks the gitlab repository and the master branch. - docker-compose now points to conduit.toml instead of Rocket.toml and its env vars were also renamed from ROCKET_ to CONDUIT_. Furthermore vectorim/riot-web was changed to vectorim/element-web --- Dockerfile | 6 +++--- docker-compose.yml | 30 ++++++++++++++++-------------- docker/README.md | 6 +++--- docker/docker-compose.traefik.yml | 27 +++++++++++++++------------ 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/Dockerfile b/Dockerfile index a97f4cf4..594a4b81 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,7 +30,7 @@ COPY . . RUN if [[ $LOCAL == "true" ]]; then \ cargo install --path . ; \ else \ - cargo install --git "https://github.com/timokoesters/conduit.git" --rev ${GIT_REF}; \ + cargo install --git "https://gitlab.com/famedly/conduit.git" --rev ${GIT_REF}; \ fi ########################## RUNTIME IMAGE ########################## @@ -40,7 +40,7 @@ FROM alpine:3.12 ARG CREATED ARG VERSION -ARG GIT_REF=HEAD +ARG GIT_REF=origin/master # Labels according to https://github.com/opencontainers/image-spec/blob/master/annotations.md # including a custom label specifying the build command @@ -52,7 +52,7 @@ LABEL org.opencontainers.image.created=${CREATED} \ org.opencontainers.image.description="A Matrix homeserver written in Rust" \ org.opencontainers.image.url="https://conduit.rs/" \ org.opencontainers.image.revision=${GIT_REF} \ - org.opencontainers.image.source="https://git.koesters.xyz/timo/conduit.git" \ + org.opencontainers.image.source="https://gitlab.com/famedly/conduit.git" \ org.opencontainers.image.licenses="Apache-2.0" \ org.opencontainers.image.documentation="" \ org.opencontainers.image.ref.name="" \ diff --git a/docker-compose.yml b/docker-compose.yml index 7d197622..38c8a117 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -15,33 +15,35 @@ services: # CREATED: # VERSION: # LOCAL: 'false' - # GIT_REF: HEAD + # GIT_REF: origin/master restart: unless-stopped ports: - 8448:8000 volumes: - db:/srv/conduit/.local/share/conduit - ### Uncomment if you want to use Rocket.toml to configure Conduit - ### Note: Set env vars will override Rocket.toml values - # - ./Rocket.toml:/srv/conduit/Rocket.toml + ### Uncomment if you want to use conduit.toml to configure Conduit + ### Note: Set env vars will override conduit.toml values + # - ./conduit.toml:/srv/conduit/conduit.toml environment: - ROCKET_SERVER_NAME: localhost:8000 # replace with your own name + CONDUIT_SERVER_NAME: localhost:8000 # replace with your own name ### Uncomment and change values as desired - # ROCKET_LOG: normal # Available levels are: off, debug, normal, critical - # ROCKET_PORT: 8000 - # ROCKET_REGISTRATION_DISABLED: 'true' - # ROCKET_ENCRYPTION_DISABLED: 'true' - # ROCKET_FEDERATION_ENABLED: 'true' - # ROCKET_DATABASE_PATH: /srv/conduit/.local/share/conduit - # ROCKET_WORKERS: 10 - # ROCKET_MAX_REQUEST_SIZE: 20_000_000 # in bytes, ~20 MB + # CONDUIT_ADDRESS: 127.0.0.1 + # CONDUIT_PORT: 8000 + # CONDUIT_LOG: normal # Available levels are: off, debug, normal, critical + # CONDUIT_ALLOW_JAEGER: 'false' + # CONDUIT_ALLOW_REGISTRATION : 'false' + # CONDUIT_ALLOW_ENCRYPTION: 'false' + # CONDUIT_ALLOW_FEDERATION: 'false' + # CONDUIT_DATABASE_PATH: /srv/conduit/.local/share/conduit + # CONDUIT_WORKERS: 10 + # CONDUIT_MAX_REQUEST_SIZE: 20_000_000 # in bytes, ~20 MB ### Uncomment if you want to use your own Element-Web App. ### Note: You need to provide a config.json for Element and you also need a second ### Domain or Subdomain for the communication between Element and Conduit ### Config-Docs: https://github.com/vector-im/element-web/blob/develop/docs/config.md # element-web: - # image: vectorim/riot-web:latest + # image: vectorim/element-web:latest # restart: unless-stopped # ports: # - 8009:80 diff --git a/docker/README.md b/docker/README.md index f90b9a41..6ae7453c 100644 --- a/docker/README.md +++ b/docker/README.md @@ -17,13 +17,13 @@ The Dockerfile includes a few build arguments that should be supplied when build ARG LOCAL=false ARG CREATED ARG VERSION -ARG GIT_REF=HEAD +ARG GIT_REF=origin/master ``` - **CREATED:** Date and time as string (date-time as defined by RFC 3339). Will be used to create the Open Container Initiative compliant label `org.opencontainers.image.created`. Supply by it like this `$(date -u +'%Y-%m-%dT%H:%M:%SZ')` - **VERSION:** The SemVer version of Conduit, which is in the image. Will be used to create the Open Container Initiative compliant label `org.opencontainers.image.version`. If you have a `Cargo.toml` in your build context, you can get it with `$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)` - **LOCAL:** *(Optional)* A boolean value, specifies if the local build context should be used, or if the official repository will be cloned. If not supplied with the build command, it will default to `false`. -- **GIT_REF:** *(Optional)* A git ref, like `HEAD` or a commit ID. The supplied ref will be used to create the Open Container Initiative compliant label `org.opencontainers.image.revision` and will be the ref that is cloned from the repository when not building from the local context. If not supplied with the build command, it will default to `HEAD`. +- **GIT_REF:** *(Optional)* A git ref, like `HEAD` or a commit ID. The supplied ref will be used to create the Open Container Initiative compliant label `org.opencontainers.image.revision` and will be the ref that is cloned from the repository when not building from the local context. If not supplied with the build command, it will default to `origin/master`. To build the image you can use the following command @@ -40,7 +40,7 @@ which also will tag the resulting image as `matrixconduit/matrix-conduit:latest` After building the image you can simply run it with ``` bash -docker run -d -p 8448:8000 -v db:/srv/conduit/.local/share/conduit -e ROCKET_SERVER_NAME="localhost:8000" matrixconduit/matrix-conduit:latest +docker run -d -p 8448:8000 -v db:/srv/conduit/.local/share/conduit -e CONDUIT_SERVER_NAME="localhost:8000" matrixconduit/matrix-conduit:latest ``` For detached mode, you also need to use the `-d` flag. You can pass in more env vars as are shown here, for an overview of possible values, you can take a look at the `docker-compose.yml` file. diff --git a/docker/docker-compose.traefik.yml b/docker/docker-compose.traefik.yml index 111eaa5a..25497c6a 100644 --- a/docker/docker-compose.traefik.yml +++ b/docker/docker-compose.traefik.yml @@ -15,32 +15,35 @@ services: # CREATED: # VERSION: # LOCAL: 'false' - # GIT_REF: HEAD + # GIT_REF: origin/master restart: unless-stopped volumes: - db:/srv/conduit/.local/share/conduit - ### Uncomment if you want to use Rocket.toml to configure Conduit - ### Note: Set env vars will override Rocket.toml values - # - ./Rocket.toml:/srv/conduit/Rocket.toml + ### Uncomment if you want to use conduit.toml to configure Conduit + ### Note: Set env vars will override conduit.toml values + # - ./conduit.toml:/srv/conduit/conduit.toml networks: - proxy environment: ROCKET_SERVER_NAME: localhost:8000 # replace with your own name ### Uncomment and change values as desired - # ROCKET_LOG: normal # Available levels are: off, debug, normal, critical - # ROCKET_PORT: 8000 - # ROCKET_REGISTRATION_DISABLED: 'true' - # ROCKET_ENCRYPTION_DISABLED: 'true' - # ROCKET_DATABASE_PATH: /srv/conduit/.local/share/conduit - # ROCKET_WORKERS: 10 - # ROCKET_MAX_REQUEST_SIZE: 20_000_000 # in bytes, ~20 MB + # CONDUIT_ADDRESS: 127.0.0.1 + # CONDUIT_PORT: 8000 + # CONDUIT_LOG: normal # Available levels are: off, debug, normal, critical + # CONDUIT_ALLOW_JAEGER: 'false' + # CONDUIT_ALLOW_REGISTRATION : 'false' + # CONDUIT_ALLOW_ENCRYPTION: 'false' + # CONDUIT_ALLOW_FEDERATION: 'false' + # CONDUIT_DATABASE_PATH: /srv/conduit/.local/share/conduit + # CONDUIT_WORKERS: 10 + # CONDUIT_MAX_REQUEST_SIZE: 20_000_000 # in bytes, ~20 MB ### Uncomment if you want to use your own Element-Web App. ### Note: You need to provide a config.json for Element and you also need a second ### Domain or Subdomain for the communication between Element and Conduit ### Config-Docs: https://github.com/vector-im/element-web/blob/develop/docs/config.md # element-web: - # image: vectorim/riot-web:latest + # image: vectorim/element-web:latest # restart: unless-stopped # volumes: # - ./element_config.json:/app/config.json From beb428d8669d509b3199531660a3544ccff69d9a Mon Sep 17 00:00:00 2001 From: Daniel Wiesenberg Date: Fri, 12 Mar 2021 21:07:43 +0100 Subject: [PATCH 2/5] Update docker command in README Mention the need for a config. --- README.md | 4 +++- docker/README.md | 5 +++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 591313f2..3a8384fa 100644 --- a/README.md +++ b/README.md @@ -82,9 +82,11 @@ Pull and run the docker image with ``` bash docker pull matrixconduit/matrix-conduit:latest -docker run -d -p 8448:8000 -v db:/srv/conduit/.local/share/conduit matrixconduit/matrix-conduit:latest +docker run -d -p 8448:8000 -v ~/conduit.toml:/srv/conduit/conduit.toml -v db:/srv/conduit/.local/share/conduit matrixconduit/matrix-conduit:latest ``` +> Note: You also need to supply a `conduit.toml` config file, you can find an example [here](./conduit-example.toml). + Or build and run it with docker or docker-compose. [Read more](docker/README.md) diff --git a/docker/README.md b/docker/README.md index 6ae7453c..6bf36f1d 100644 --- a/docker/README.md +++ b/docker/README.md @@ -40,10 +40,11 @@ which also will tag the resulting image as `matrixconduit/matrix-conduit:latest` After building the image you can simply run it with ``` bash -docker run -d -p 8448:8000 -v db:/srv/conduit/.local/share/conduit -e CONDUIT_SERVER_NAME="localhost:8000" matrixconduit/matrix-conduit:latest +docker run -d -p 8448:8000 -v ~/conduit.toml:/srv/conduit/conduit.toml -v db:/srv/conduit/.local/share/conduit matrixconduit/matrix-conduit:latest ``` -For detached mode, you also need to use the `-d` flag. You can pass in more env vars as are shown here, for an overview of possible values, you can take a look at the `docker-compose.yml` file. +For detached mode, you also need to use the `-d` flag. You also need to supply a `conduit.toml` config file, you can find an example [here](../conduit-example.toml). +You can pass in more env vars as are shown here, for an overview of possible values, you can take a look at the `docker-compose.yml` file. 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. From 5a7ccbdfab228daca0ebecf46b9c4372d36faf6a Mon Sep 17 00:00:00 2001 From: Daniel Wiesenberg Date: Tue, 16 Mar 2021 09:14:11 +0100 Subject: [PATCH 3/5] Add CONDUIT_CONFIG to all relevant docker files And mention that an empty string can be used to configure Conduit purely with env vars. --- Dockerfile | 2 ++ README.md | 1 + docker-compose.yml | 4 +++- docker/README.md | 3 ++- docker/docker-compose.traefik.yml | 4 +++- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 594a4b81..51f146d2 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,8 @@ ARG CREATED ARG VERSION ARG GIT_REF=origin/master +ENV CONDUIT_CONFIG="/srv/conduit/conduit.toml" + # Labels according to https://github.com/opencontainers/image-spec/blob/master/annotations.md # including a custom label specifying the build command LABEL org.opencontainers.image.created=${CREATED} \ diff --git a/README.md b/README.md index 3a8384fa..ac603e68 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,7 @@ docker run -d -p 8448:8000 -v ~/conduit.toml:/srv/conduit/conduit.toml -v db:/sr ``` > Note: You also need to supply a `conduit.toml` config file, you can find an example [here](./conduit-example.toml). +> Or you can pass in `-e CONDUIT_CONFIG=""` and configure Conduit purely with env vars. Or build and run it with docker or docker-compose. [Read more](docker/README.md) diff --git a/docker-compose.yml b/docker-compose.yml index 38c8a117..cb98a112 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -29,7 +29,9 @@ services: ### Uncomment and change values as desired # CONDUIT_ADDRESS: 127.0.0.1 # CONDUIT_PORT: 8000 - # CONDUIT_LOG: normal # Available levels are: off, debug, normal, critical + # CONDUIT_CONFIG: '/srv/conduit/conduit.toml' # if want to configure purely by env vars, set this to an empty string '' + # Available levels are: error, warn, info, debug, trace - more info at: https://docs.rs/env_logger/*/env_logger/#enabling-logging + # CONDUIT_LOG: info # default is: "info,rocket=off,_=off,sled=off" # CONDUIT_ALLOW_JAEGER: 'false' # CONDUIT_ALLOW_REGISTRATION : 'false' # CONDUIT_ALLOW_ENCRYPTION: 'false' diff --git a/docker/README.md b/docker/README.md index 6bf36f1d..499d1adb 100644 --- a/docker/README.md +++ b/docker/README.md @@ -44,7 +44,8 @@ docker run -d -p 8448:8000 -v ~/conduit.toml:/srv/conduit/conduit.toml -v db:/sr ``` For detached mode, you also need to use the `-d` flag. You also need to supply a `conduit.toml` config file, you can find an example [here](../conduit-example.toml). -You can pass in more env vars as are shown here, for an overview of possible values, you can take a look at the `docker-compose.yml` file. +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 +too pass `-e CONDUIT_CONFIG=""` into your container. For an overview of possible values, please take a look at the `docker-compose.yml` file. 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. diff --git a/docker/docker-compose.traefik.yml b/docker/docker-compose.traefik.yml index 25497c6a..ef14ca95 100644 --- a/docker/docker-compose.traefik.yml +++ b/docker/docker-compose.traefik.yml @@ -29,7 +29,9 @@ services: ### Uncomment and change values as desired # CONDUIT_ADDRESS: 127.0.0.1 # CONDUIT_PORT: 8000 - # CONDUIT_LOG: normal # Available levels are: off, debug, normal, critical + # CONDUIT_CONFIG: '/srv/conduit/conduit.toml' # if want to configure purely by env vars, set this to an empty string '' + # Available levels are: error, warn, info, debug, trace - more info at: https://docs.rs/env_logger/*/env_logger/#enabling-logging + # CONDUIT_LOG: info # default is: "info,rocket=off,_=off,sled=off" # CONDUIT_ALLOW_JAEGER: 'false' # CONDUIT_ALLOW_REGISTRATION : 'false' # CONDUIT_ALLOW_ENCRYPTION: 'false' From c6625d83e691ab05f0568ed50951c676379830c8 Mon Sep 17 00:00:00 2001 From: Daniel Wiesenberg Date: Sat, 22 May 2021 16:53:08 +0200 Subject: [PATCH 4/5] Add CONDUIT_TRUSTED_SERVERS config param --- docker-compose.yml | 20 +++++++++++--------- docker/docker-compose.traefik.yml | 2 ++ 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index cb98a112..2dcf9065 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,17 +5,17 @@ services: homeserver: ### If you already built the Conduit image with 'docker build' or want to use the Docker Hub image, ### then you are ready to go. - image: matrixconduit/matrix-conduit:latest + #image: matrixconduit/matrix-conduit:latest ### If you want to build a fresh image from the sources, then comment the image line and uncomment the ### build lines. If you want meaningful labels in your built Conduit image, you should run docker-compose like this: ### CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) docker-compose up -d - # build: - # context: . - # args: - # CREATED: - # VERSION: - # LOCAL: 'false' - # GIT_REF: origin/master + build: + context: . + args: + CREATED: '2021-03-16T08:18:27Z' + VERSION: '0.1.0' + LOCAL: 'false' + GIT_REF: origin/master restart: unless-stopped ports: - 8448:8000 @@ -26,10 +26,12 @@ services: # - ./conduit.toml:/srv/conduit/conduit.toml environment: CONDUIT_SERVER_NAME: localhost:8000 # replace with your own name + CONDUIT_TRUSTED_SERVERS: + - 'matrix.org' ### Uncomment and change values as desired # CONDUIT_ADDRESS: 127.0.0.1 # CONDUIT_PORT: 8000 - # CONDUIT_CONFIG: '/srv/conduit/conduit.toml' # if want to configure purely by env vars, set this to an empty string '' + # CONDUIT_CONFIG: '/srv/conduit/conduit.toml' # if you want to configure purely by env vars, set this to an empty string '' # Available levels are: error, warn, info, debug, trace - more info at: https://docs.rs/env_logger/*/env_logger/#enabling-logging # CONDUIT_LOG: info # default is: "info,rocket=off,_=off,sled=off" # CONDUIT_ALLOW_JAEGER: 'false' diff --git a/docker/docker-compose.traefik.yml b/docker/docker-compose.traefik.yml index ef14ca95..c5728a0c 100644 --- a/docker/docker-compose.traefik.yml +++ b/docker/docker-compose.traefik.yml @@ -26,6 +26,8 @@ services: - proxy environment: ROCKET_SERVER_NAME: localhost:8000 # replace with your own name + CONDUIT_TRUSTED_SERVERS: + - 'matrix.org' ### Uncomment and change values as desired # CONDUIT_ADDRESS: 127.0.0.1 # CONDUIT_PORT: 8000 From 634fe04c33d45f091856e64aaf51508b0e9730b0 Mon Sep 17 00:00:00 2001 From: Daniel Wiesenberg Date: Sat, 22 May 2021 20:49:07 +0200 Subject: [PATCH 5/5] Fix wrong env var name in traefik compose --- docker/docker-compose.traefik.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/docker-compose.traefik.yml b/docker/docker-compose.traefik.yml index c5728a0c..629e79b5 100644 --- a/docker/docker-compose.traefik.yml +++ b/docker/docker-compose.traefik.yml @@ -25,7 +25,7 @@ services: networks: - proxy environment: - ROCKET_SERVER_NAME: localhost:8000 # replace with your own name + CONDUIT_SERVER_NAME: localhost:8000 # replace with your own name CONDUIT_TRUSTED_SERVERS: - 'matrix.org' ### Uncomment and change values as desired