Compare commits
20
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
04fcac20b3 | ||
|
|
25065a58e8 | ||
|
|
526b5b4d7f | ||
|
|
8eb5843f61 | ||
|
|
afa5d449c6 | ||
|
|
2fff720df3 | ||
|
|
da00f611e9 | ||
|
|
9fccbb014a | ||
|
|
109892b4b7 | ||
|
|
24a835647c | ||
|
|
c4bce1d0c7 | ||
|
|
9b63708685 | ||
|
|
86177faae7 | ||
|
|
2a749c1e99 | ||
|
|
d5d25fb064 | ||
|
|
8087a26a35 | ||
|
|
bbe16f8467 | ||
|
|
50f931a2fd | ||
|
|
1541b93f45 | ||
|
|
ccf501a420 |
@@ -14,6 +14,8 @@ docker-compose*
|
||||
# Git folder
|
||||
.git
|
||||
.gitea
|
||||
.gitlab
|
||||
.github
|
||||
|
||||
# Dot files
|
||||
.env
|
||||
|
||||
+141
-226
@@ -9,7 +9,6 @@ variables:
|
||||
FF_USE_FASTZIP: 1
|
||||
CACHE_COMPRESSION_LEVEL: fastest
|
||||
|
||||
|
||||
# --------------------------------------------------------------------- #
|
||||
# Cargo: Compiling for different architectures #
|
||||
# --------------------------------------------------------------------- #
|
||||
@@ -20,48 +19,46 @@ variables:
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
- if: '$CI_COMMIT_BRANCH == "next"'
|
||||
# TODO: Remove this after debugging
|
||||
- if: '$CI_COMMIT_BRANCH == "multiarch-docker-support"'
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
- if: "$CI_COMMIT_TAG"
|
||||
interruptible: true
|
||||
image: "rust:1.56.0"
|
||||
image: "rust:latest"
|
||||
tags: ["docker"]
|
||||
cache:
|
||||
paths:
|
||||
- cargohome
|
||||
- target/
|
||||
key: "build_cache-$TARGET-release"
|
||||
key: "build_cache--$TARGET--$CI_COMMIT_BRANCH--release"
|
||||
variables:
|
||||
CARGO_PROFILE_RELEASE_LTO: "off" # TODO: change to true again
|
||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "256" # TODO: Change to 1 again
|
||||
RUSTUP_HOME: "/root/.rustup"
|
||||
CARGO_PROFILE_RELEASE_LTO: "true"
|
||||
CARGO_PROFILE_RELEASE_CODEGEN_UNITS: "1"
|
||||
before_script:
|
||||
- echo $USER
|
||||
- export PATH="root/.cargo/bin:$PATH"
|
||||
- 'echo "Building for target $TARGET"'
|
||||
- 'mkdir -p cargohome && CARGOHOME="cargohome"'
|
||||
- "cat /etc/*-release && rustc --version && cargo --version" # Print version info for debugging
|
||||
- 'time rustup target add "$TARGET"'
|
||||
- "rustc --version && cargo --version && rustup show" # Print version info for debugging
|
||||
- "rustup target add $TARGET"
|
||||
script:
|
||||
- time cargo build --target $TARGET --release
|
||||
- 'mv "target/$TARGET/release/conduit" "conduit-$TARGET"'
|
||||
- 'cp "target/$TARGET/release/conduit" "conduit-$TARGET"'
|
||||
artifacts:
|
||||
expire_in: never
|
||||
|
||||
|
||||
build:release:cargo:x86_64-unknown-linux-gnu:
|
||||
build:release:cargo:x86_64-unknown-linux-musl-with-debug:
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:x86_64-musl
|
||||
variables:
|
||||
TARGET: "x86_64-unknown-linux-gnu"
|
||||
CARGO_PROFILE_RELEASE_DEBUG: 2 # Enable debug info for flamegraph profiling
|
||||
TARGET: "x86_64-unknown-linux-musl"
|
||||
after_script:
|
||||
- "mv ./conduit-x86_64-unknown-linux-musl ./conduit-x86_64-unknown-linux-musl-with-debug"
|
||||
artifacts:
|
||||
name: "conduit-x86_64-unknown-linux-gnu"
|
||||
name: "conduit-x86_64-unknown-linux-musl-with-debug"
|
||||
paths:
|
||||
- "conduit-x86_64-unknown-linux-gnu"
|
||||
expose_as: "Conduit for x86_64-unknown-linux-gnu"
|
||||
- "conduit-x86_64-unknown-linux-musl-with-debug"
|
||||
expose_as: "Conduit for x86_64-unknown-linux-musl-with-debug"
|
||||
|
||||
build:release:cargo:x86_64-unknown-linux-musl:
|
||||
image: registry.gitlab.fachschaften.org/jfowl/cargo-cross-for-ci/cargo-cross-builder:rust1.56.0-x86_64-unknown-linux-musl
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:x86_64-musl
|
||||
variables:
|
||||
TARGET: "x86_64-unknown-linux-musl"
|
||||
artifacts:
|
||||
@@ -70,23 +67,20 @@ build:release:cargo:x86_64-unknown-linux-musl:
|
||||
- "conduit-x86_64-unknown-linux-musl"
|
||||
expose_as: "Conduit for x86_64-unknown-linux-musl"
|
||||
|
||||
|
||||
build:release:cargo:armv7-unknown-linux-gnueabihf:
|
||||
build:release:cargo:arm-unknown-linux-musleabihf:
|
||||
extends: .build-cargo-shared-settings
|
||||
image:
|
||||
name: registry.gitlab.fachschaften.org/jfowl/cargo-cross-for-ci/cargo-cross-builder:rust1.56.0-armv7-unknown-linux-gnueabihf
|
||||
image: messense/rust-musl-cross:arm-musleabihf
|
||||
variables:
|
||||
TARGET: "armv7-unknown-linux-gnueabihf"
|
||||
TARGET: "arm-unknown-linux-musleabihf"
|
||||
artifacts:
|
||||
name: "conduit-armv7-unknown-linux-gnueabihf"
|
||||
name: "conduit-arm-unknown-linux-musleabihf"
|
||||
paths:
|
||||
- "conduit-armv7-unknown-linux-gnueabihf"
|
||||
expose_as: "Conduit for armv7-unknown-linux-gnueabihf"
|
||||
- "conduit-arm-unknown-linux-musleabihf"
|
||||
expose_as: "Conduit for arm-unknown-linux-musleabihf"
|
||||
|
||||
build:release:cargo:armv7-unknown-linux-musleabihf:
|
||||
extends: .build-cargo-shared-settings
|
||||
image:
|
||||
name: registry.gitlab.fachschaften.org/jfowl/cargo-cross-for-ci/cargo-cross-builder:rust1.56.0-armv7-unknown-linux-musleabihf
|
||||
image: messense/rust-musl-cross:armv7-musleabihf
|
||||
variables:
|
||||
TARGET: "armv7-unknown-linux-musleabihf"
|
||||
artifacts:
|
||||
@@ -95,21 +89,9 @@ build:release:cargo:armv7-unknown-linux-musleabihf:
|
||||
- "conduit-armv7-unknown-linux-musleabihf"
|
||||
expose_as: "Conduit for armv7-unknown-linux-musleabihf"
|
||||
|
||||
|
||||
build:release:cargo:aarch64-unknown-linux-gnu:
|
||||
image: registry.gitlab.fachschaften.org/jfowl/cargo-cross-for-ci/cargo-cross-builder:rust1.56.0-aarch64-unknown-linux-gnu
|
||||
extends: .build-cargo-shared-settings
|
||||
variables:
|
||||
TARGET: "aarch64-unknown-linux-gnu"
|
||||
artifacts:
|
||||
name: "conduit-aarch64-unknown-linux-gnu"
|
||||
paths:
|
||||
- "conduit-aarch64-unknown-linux-gnu"
|
||||
expose_as: "Conduit for aarch64-unknown-linux-gnu"
|
||||
|
||||
build:release:cargo:aarch64-unknown-linux-musl:
|
||||
image: registry.gitlab.fachschaften.org/jfowl/cargo-cross-for-ci/cargo-cross-builder:rust1.56.0-aarch64-unknown-linux-musl
|
||||
extends: .build-cargo-shared-settings
|
||||
image: messense/rust-musl-cross:aarch64-musl
|
||||
variables:
|
||||
TARGET: "aarch64-unknown-linux-musl"
|
||||
artifacts:
|
||||
@@ -118,215 +100,136 @@ build:release:cargo:aarch64-unknown-linux-musl:
|
||||
- "conduit-aarch64-unknown-linux-musl"
|
||||
expose_as: "Conduit for aarch64-unknown-linux-musl"
|
||||
|
||||
|
||||
|
||||
.cargo-debug-shared-settings:
|
||||
extends: ".build-cargo-shared-settings"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH'
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
- if: '$CI_COMMIT_BRANCH != "master"'
|
||||
cache:
|
||||
key: "build_cache-$TARGET-debug"
|
||||
key: "build_cache--$TARGET--$CI_COMMIT_BRANCH--debug"
|
||||
script:
|
||||
- "time cargo build --target $TARGET"
|
||||
- 'mv "target/$TARGET/debug/conduit" "conduit-debug-$TARGET"'
|
||||
artifacts:
|
||||
expire_in: 4 weeks
|
||||
|
||||
build:debug:cargo:x86_64-unknown-linux-gnu:
|
||||
extends: ".cargo-debug-shared-settings"
|
||||
variables:
|
||||
TARGET: "x86_64-unknown-linux-gnu"
|
||||
artifacts:
|
||||
name: "conduit-debug-x86_64-unknown-linux-gnu"
|
||||
paths:
|
||||
- "conduit-debug-x86_64-unknown-linux-gnu"
|
||||
expose_as: "Conduit DEBUG for x86_64-unknown-linux-gnu"
|
||||
|
||||
build:debug:cargo:x86_64-unknown-linux-musl:
|
||||
extends: ".cargo-debug-shared-settings"
|
||||
image: "rust:alpine"
|
||||
image: messense/rust-musl-cross:x86_64-musl
|
||||
variables:
|
||||
TARGET: "x86_64-unknown-linux-musl"
|
||||
before_script:
|
||||
- 'echo "Building for target $TARGET"'
|
||||
- 'mkdir -p cargohome && CARGOHOME="cargohome"'
|
||||
- "cat /etc/*-release && rustc --version && cargo --version" # Print version info for debugging
|
||||
- "rustup target add $TARGET"
|
||||
- "apk add libc-dev"
|
||||
artifacts:
|
||||
name: "conduit-debug-x86_64-unknown-linux-musl"
|
||||
paths:
|
||||
- "conduit-debug-x86_64-unknown-linux-musl"
|
||||
expose_as: "Conduit DEBUG for x86_64-unknown-linux-musl"
|
||||
|
||||
|
||||
|
||||
# --------------------------------------------------------------------- #
|
||||
# Cargo: Compiling deb packages for different architectures #
|
||||
# --------------------------------------------------------------------- #
|
||||
|
||||
|
||||
.build-cargo-deb-shared-settings:
|
||||
stage: "build"
|
||||
needs: [ ]
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
- if: '$CI_COMMIT_BRANCH == "next"'
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
interruptible: true
|
||||
image: "rust:latest"
|
||||
tags: ["docker"]
|
||||
cache:
|
||||
paths:
|
||||
- cargohome
|
||||
- target/
|
||||
key: "build_cache-deb-$TARGET"
|
||||
before_script:
|
||||
- 'echo "Building debian package for target $TARGET"'
|
||||
- 'mkdir -p cargohome && CARGOHOME="cargohome"'
|
||||
- "cat /etc/*-release && rustc --version && cargo --version" # Print version info for debugging
|
||||
- 'apt-get update -yqq'
|
||||
- 'echo "Installing packages: $NEEDED_PACKAGES"'
|
||||
- "apt-get install -yqq --no-install-recommends $NEEDED_PACKAGES"
|
||||
- "rustup target add $TARGET"
|
||||
- "cargo install cargo-deb"
|
||||
script:
|
||||
- time cargo deb --target $TARGET
|
||||
- 'mv target/$TARGET/debian/*.deb "conduit-$TARGET.deb"'
|
||||
|
||||
build:cargo-deb:x86_64-unknown-linux-gnu:
|
||||
extends: .build-cargo-deb-shared-settings
|
||||
variables:
|
||||
TARGET: "x86_64-unknown-linux-gnu"
|
||||
NEEDED_PACKAGES: ""
|
||||
artifacts:
|
||||
name: "conduit-x86_64-unknown-linux-gnu.deb"
|
||||
paths:
|
||||
- "conduit-x86_64-unknown-linux-gnu.deb"
|
||||
expose_as: "Debian Package x86_64"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------- #
|
||||
# Create and publish docker image #
|
||||
# --------------------------------------------------------------------- #
|
||||
|
||||
# Build a docker image by packaging up the x86_64-unknown-linux-musl binary into an alpine image
|
||||
.docker-shared-settings:
|
||||
stage: "build docker image"
|
||||
needs: []
|
||||
interruptible: true
|
||||
image:
|
||||
name: "gcr.io/kaniko-project/executor:debug"
|
||||
entrypoint: [""]
|
||||
tags: ["docker"]
|
||||
variables:
|
||||
# Configure Kaniko Caching: https://cloud.google.com/build/docs/kaniko-cache
|
||||
KANIKO_CACHE_ARGS: "--cache=true --cache-copy-layers=true --cache-ttl=120h --cache-repo $CI_REGISTRY_IMAGE/kaniko-ci-cache"
|
||||
before_script:
|
||||
- "mkdir -p /kaniko/.docker"
|
||||
- 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"},\"$DOCKER_HUB\":{\"username\":\"$DOCKER_HUB_USER\",\"password\":\"$DOCKER_HUB_PASSWORD\"}}}" > /kaniko/.docker/config.json'
|
||||
|
||||
build:docker:next:
|
||||
extends: .docker-shared-settings
|
||||
needs:
|
||||
- "build:release:cargo:x86_64-unknown-linux-musl"
|
||||
script:
|
||||
- >
|
||||
/kaniko/executor
|
||||
$KANIKO_CACHE_ARGS
|
||||
--force
|
||||
--context $CI_PROJECT_DIR
|
||||
--build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
--build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)
|
||||
--build-arg "GIT_REF=$CI_COMMIT_SHORT_SHA"
|
||||
--dockerfile "$CI_PROJECT_DIR/docker/ci-binaries-packaging.Dockerfile"
|
||||
--destination "$CI_REGISTRY_IMAGE/conduit:next"
|
||||
--destination "$CI_REGISTRY_IMAGE/conduit:next-alpine"
|
||||
--destination "$CI_REGISTRY_IMAGE/conduit:commit-$CI_COMMIT_SHORT_SHA"
|
||||
--destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:next"
|
||||
--destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:next-alpine"
|
||||
--destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:commit-$CI_COMMIT_SHORT_SHA"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "next"'
|
||||
|
||||
|
||||
build:docker:master:
|
||||
extends: .docker-shared-settings
|
||||
needs:
|
||||
- "build:release:cargo:x86_64-unknown-linux-musl"
|
||||
script:
|
||||
- >
|
||||
/kaniko/executor
|
||||
$KANIKO_CACHE_ARGS
|
||||
--context $CI_PROJECT_DIR
|
||||
--build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
--build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)
|
||||
--build-arg "GIT_REF=$CI_COMMIT_SHORT_SHA"
|
||||
--dockerfile "$CI_PROJECT_DIR/docker/ci-binaries-packaging.Dockerfile"
|
||||
--destination "$CI_REGISTRY_IMAGE/conduit:latest"
|
||||
--destination "$CI_REGISTRY_IMAGE/conduit:latest-alpine"
|
||||
--destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:latest"
|
||||
--destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:latest-alpine"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
|
||||
|
||||
build:docker:tags:
|
||||
extends: .docker-shared-settings
|
||||
needs:
|
||||
- "build:release:cargo:x86_64-unknown-linux-musl"
|
||||
script:
|
||||
- >
|
||||
/kaniko/executor
|
||||
$KANIKO_CACHE_ARGS
|
||||
--context $CI_PROJECT_DIR
|
||||
--build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
--build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)
|
||||
--build-arg "GIT_REF=$CI_COMMIT_SHORT_SHA"
|
||||
--dockerfile "$CI_PROJECT_DIR/docker/ci-binaries-packaging.Dockerfile"
|
||||
--destination "$CI_REGISTRY_IMAGE/conduit:$CI_COMMIT_TAG"
|
||||
--destination "$CI_REGISTRY_IMAGE/conduit:$CI_COMMIT_TAG-alpine"
|
||||
--destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:$CI_COMMIT_TAG"
|
||||
--destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:$CI_COMMIT_TAG-alpine"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
|
||||
|
||||
build:docker:new-way-of-building:
|
||||
stage: "build docker image"
|
||||
image: jdrouet/docker-with-buildx:stable
|
||||
tags: ["docker"]
|
||||
services:
|
||||
- docker:dind
|
||||
- docker:dind
|
||||
needs:
|
||||
- "build:release:cargo:x86_64-unknown-linux-musl"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
- if: '$CI_COMMIT_BRANCH == "next"'
|
||||
# TODO: Remove this after debugging
|
||||
- if: '$CI_COMMIT_BRANCH == "multiarch-docker-support"'
|
||||
- "build:release:cargo:arm-unknown-linux-musleabihf"
|
||||
- "build:release:cargo:armv7-unknown-linux-musleabihf"
|
||||
- "build:release:cargo:aarch64-unknown-linux-musl"
|
||||
variables:
|
||||
DOCKER_HOST: tcp://docker:2375/
|
||||
DOCKER_TLS_CERTDIR: ""
|
||||
DOCKER_DRIVER: overlay2
|
||||
# PLATFORMS: "linux/arm/v7,linux/arm64/v8,linux/amd64"
|
||||
PLATFORMS: "linux/amd64"
|
||||
IMAGE_TAG: "$CI_REGISTRY_IMAGE/debug-conduit:multiarch-test-dont-use-yet"
|
||||
PLATFORMS: "linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64"
|
||||
DOCKER_FILE: "docker/ci-binaries-packaging.Dockerfile"
|
||||
before_script:
|
||||
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
|
||||
# Only log in to Dockerhub if the credentials are given:
|
||||
- if [ -n "${DOCKER_HUB}" ]; then docker login -u "$DOCKER_HUB_USER" -p "$DOCKER_HUB_PASSWORD" "$DOCKER_HUB"; fi
|
||||
script:
|
||||
# Prepare buildx to build multiarch stuff:
|
||||
- docker context create 'ci-context'
|
||||
- docker buildx create --name 'multiarch-builder' --use 'ci-context'
|
||||
# Copy binaries to their docker arch path
|
||||
- mkdir -p linux/ && mv ./conduit-x86_64-unknown-linux-musl linux/amd64
|
||||
# Actually build multiarch image:
|
||||
- docker buildx build --push --platform $PLATFORMS --tag $IMAGE_TAG --file $DOCKER_FILE .
|
||||
- mkdir -p linux/arm/ && mv ./conduit-arm-unknown-linux-musleabihf linux/arm/v6
|
||||
- mkdir -p linux/arm/ && mv ./conduit-armv7-unknown-linux-musleabihf linux/arm/v7
|
||||
- mkdir -p linux/arm64/ && mv ./conduit-aarch64-unknown-linux-musl linux/arm64/v8
|
||||
# Actually create multiarch image:
|
||||
- >
|
||||
docker buildx build
|
||||
--pull
|
||||
--push
|
||||
--build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
--build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)
|
||||
--build-arg "GIT_REF=$CI_COMMIT_SHORT_SHA"
|
||||
--platform "$PLATFORMS"
|
||||
--tag "$GL_IMAGE_TAG"
|
||||
--tag "$GL_IMAGE_TAG-commit-$CI_COMMIT_SHORT_SHA"
|
||||
--file "$DOCKER_FILE" .
|
||||
# Only try to push to docker hub, if auth data for dockerhub exists:
|
||||
- if [ -n "${DOCKER_HUB}" ]; then docker push "$DH_IMAGE_TAG"; fi
|
||||
- if [ -n "${DOCKER_HUB}" ]; then docker push "$DH_IMAGE_TAG-commit-$CI_COMMIT_SHORT_SHA"; fi
|
||||
|
||||
build:docker:next:
|
||||
extends: .docker-shared-settings
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "next"'
|
||||
variables:
|
||||
GL_IMAGE_TAG: "$CI_REGISTRY_IMAGE/matrix-conduit:next"
|
||||
DH_IMAGE_TAG: "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:next"
|
||||
|
||||
build:docker:master:
|
||||
extends: .docker-shared-settings
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
variables:
|
||||
GL_IMAGE_TAG: "$CI_REGISTRY_IMAGE/matrix-conduit:latest"
|
||||
DH_IMAGE_TAG: "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:latest"
|
||||
|
||||
## Build a docker image by packaging up the x86_64-unknown-linux-musl binary into an alpine image
|
||||
#.docker-shared-settings:
|
||||
# stage: "build docker image"
|
||||
# needs: []
|
||||
# interruptible: true
|
||||
# image:
|
||||
# name: "gcr.io/kaniko-project/executor:debug"
|
||||
# entrypoint: [""]
|
||||
# tags: ["docker"]
|
||||
# variables:
|
||||
# # Configure Kaniko Caching: https://cloud.google.com/build/docs/kaniko-cache
|
||||
# KANIKO_CACHE_ARGS: "--cache=true --cache-copy-layers=true --cache-ttl=120h --cache-repo $CI_REGISTRY_IMAGE/kaniko-ci-cache"
|
||||
# before_script:
|
||||
# - "mkdir -p /kaniko/.docker"
|
||||
# - 'echo "{\"auths\":{\"$CI_REGISTRY\":{\"username\":\"$CI_REGISTRY_USER\",\"password\":\"$CI_REGISTRY_PASSWORD\"},\"$DOCKER_HUB\":{\"username\":\"$DOCKER_HUB_USER\",\"password\":\"$DOCKER_HUB_PASSWORD\"}}}" > /kaniko/.docker/config.json'
|
||||
#
|
||||
#
|
||||
#build:docker:next:
|
||||
# extends: .docker-shared-settings
|
||||
# needs:
|
||||
# - "build:release:cargo:x86_64-unknown-linux-musl"
|
||||
# script:
|
||||
# - >
|
||||
# /kaniko/executor
|
||||
# $KANIKO_CACHE_ARGS
|
||||
# --force
|
||||
# --context $CI_PROJECT_DIR
|
||||
# --build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
# --build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)
|
||||
# --build-arg "GIT_REF=$CI_COMMIT_SHORT_SHA"
|
||||
# --dockerfile "$CI_PROJECT_DIR/docker/ci-binaries-packaging.Dockerfile"
|
||||
# --destination "$CI_REGISTRY_IMAGE/conduit:next"
|
||||
# --destination "$CI_REGISTRY_IMAGE/conduit:next-alpine"
|
||||
# --destination "$CI_REGISTRY_IMAGE/conduit:commit-$CI_COMMIT_SHORT_SHA"
|
||||
# --destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:next"
|
||||
# --destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:next-alpine"
|
||||
# --destination "$DOCKER_HUB_IMAGE/matrixconduit/matrix-conduit:commit-$CI_COMMIT_SHORT_SHA"
|
||||
# rules:
|
||||
# - if: '$CI_COMMIT_BRANCH == "next"'
|
||||
#
|
||||
#
|
||||
|
||||
# --------------------------------------------------------------------- #
|
||||
# Run tests #
|
||||
@@ -334,9 +237,9 @@ build:docker:new-way-of-building:
|
||||
|
||||
test:cargo:
|
||||
stage: "test"
|
||||
needs: [ ]
|
||||
needs: []
|
||||
image: "rust:latest"
|
||||
tags: [ "docker" ]
|
||||
tags: ["docker"]
|
||||
variables:
|
||||
CARGO_HOME: "cargohome"
|
||||
cache:
|
||||
@@ -348,13 +251,20 @@ test:cargo:
|
||||
before_script:
|
||||
- mkdir -p $CARGO_HOME && echo "using $CARGO_HOME to cache cargo deps"
|
||||
- apt-get update -yqq
|
||||
- apt-get install -yqq --no-install-recommends build-essential libssl-dev pkg-config
|
||||
- apt-get install -yqq --no-install-recommends build-essential libssl-dev pkg-config wget
|
||||
- rustup component add clippy rustfmt
|
||||
- wget "https://faulty-storage.de/gitlab-report"
|
||||
- chmod +x ./gitlab-report
|
||||
script:
|
||||
- rustc --version && cargo --version # Print version info for debugging
|
||||
- rustc --version && cargo --version # Print version info for debugging
|
||||
- cargo fmt --all -- --check
|
||||
- cargo test --workspace --verbose --locked
|
||||
- cargo clippy
|
||||
- "cargo test --color always --workspace --verbose --locked --no-fail-fast -- -Z unstable-options --format json | ./gitlab-report -p test > $CI_PROJECT_DIR/report.xml"
|
||||
- "cargo clippy --color always --verbose --message-format=json | ./gitlab-report -p clippy > $CI_PROJECT_DIR/gl-code-quality-report.json"
|
||||
artifacts:
|
||||
when: always
|
||||
reports:
|
||||
junit: report.xml
|
||||
codequality: gl-code-quality-report.json
|
||||
|
||||
test:sytest:
|
||||
stage: "test"
|
||||
@@ -363,8 +273,8 @@ test:sytest:
|
||||
- "build:debug:cargo:x86_64-unknown-linux-musl"
|
||||
image:
|
||||
name: "valkum/sytest-conduit:latest"
|
||||
entrypoint: [ "" ]
|
||||
tags: [ "docker" ]
|
||||
entrypoint: [""]
|
||||
tags: ["docker"]
|
||||
variables:
|
||||
PLUGINS: "https://github.com/valkum/sytest_conduit/archive/master.tar.gz"
|
||||
before_script:
|
||||
@@ -377,7 +287,7 @@ test:sytest:
|
||||
script:
|
||||
- "SYTEST_EXIT_CODE=0"
|
||||
- "/bootstrap.sh conduit || SYTEST_EXIT_CODE=1"
|
||||
- "perl /sytest/tap-to-junit-xml.pl --puretap --input /logs/results.tap --output $CI_PROJECT_DIR/sytest.xml \"Sytest\" && cp /logs/results.tap $CI_PROJECT_DIR/results.tap"
|
||||
- 'perl /sytest/tap-to-junit-xml.pl --puretap --input /logs/results.tap --output $CI_PROJECT_DIR/sytest.xml "Sytest" && cp /logs/results.tap $CI_PROJECT_DIR/results.tap'
|
||||
- "exit $SYTEST_EXIT_CODE"
|
||||
artifacts:
|
||||
when: always
|
||||
@@ -387,7 +297,6 @@ test:sytest:
|
||||
reports:
|
||||
junit: "$CI_PROJECT_DIR/sytest.xml"
|
||||
|
||||
|
||||
# --------------------------------------------------------------------- #
|
||||
# Store binaries as package so they have download urls #
|
||||
# --------------------------------------------------------------------- #
|
||||
@@ -395,25 +304,31 @@ test:sytest:
|
||||
publish:package:
|
||||
stage: "upload artifacts"
|
||||
needs:
|
||||
- "build:release:cargo:x86_64-unknown-linux-gnu"
|
||||
- "build:release:cargo:armv7-unknown-linux-gnueabihf"
|
||||
- "build:release:cargo:aarch64-unknown-linux-gnu"
|
||||
- "build:release:cargo:x86_64-unknown-linux-musl"
|
||||
- "build:cargo-deb:x86_64-unknown-linux-gnu"
|
||||
- "build:release:cargo:arm-unknown-linux-musleabihf"
|
||||
- "build:release:cargo:armv7-unknown-linux-musleabihf"
|
||||
- "build:release:cargo:aarch64-unknown-linux-musl"
|
||||
# - "build:cargo-deb:x86_64-unknown-linux-gnu"
|
||||
rules:
|
||||
- if: '$CI_COMMIT_BRANCH == "master"'
|
||||
- if: '$CI_COMMIT_BRANCH == "next"'
|
||||
- if: '$CI_COMMIT_TAG'
|
||||
- if: "$CI_COMMIT_TAG"
|
||||
image: curlimages/curl:latest
|
||||
tags: ["docker"]
|
||||
variables:
|
||||
GIT_STRATEGY: "none" # Don't need a clean copy of the code, we just operate on artifacts
|
||||
script:
|
||||
- 'BASE_URL="${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/conduit-${CI_COMMIT_REF_SLUG}/build-${CI_PIPELINE_ID}"'
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-x86_64-unknown-linux-gnu "${BASE_URL}/conduit-x86_64-unknown-linux-gnu"'
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-armv7-unknown-linux-gnueabihf "${BASE_URL}/conduit-armv7-unknown-linux-gnueabihf"'
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-aarch64-unknown-linux-gnu "${BASE_URL}/conduit-aarch64-unknown-linux-gnu"'
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-x86_64-unknown-linux-musl "${BASE_URL}/conduit-x86_64-unknown-linux-musl"'
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-x86_64-unknown-linux-gnu.deb "${BASE_URL}/conduit-x86_64-unknown-linux-gnu.deb"'
|
||||
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-arm-unknown-linux-musleabihf "${BASE_URL}/conduit-arm-unknown-linux-musleabihf"'
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-armv7-unknown-linux-musleabihf "${BASE_URL}/conduit-armv7-unknown-linux-musleabihf"'
|
||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file conduit-aarch64-unknown-linux-musl "${BASE_URL}/conduit-aarch64-unknown-linux-musl"'
|
||||
|
||||
# Avoid duplicate pipelines
|
||||
# See: https://docs.gitlab.com/ee/ci/yaml/workflow.html#switch-between-branch-pipelines-and-merge-request-pipelines
|
||||
workflow:
|
||||
rules:
|
||||
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
|
||||
- if: "$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS"
|
||||
when: never
|
||||
- if: "$CI_COMMIT_BRANCH"
|
||||
|
||||
Generated
+53
-18
@@ -245,6 +245,7 @@ dependencies = [
|
||||
"crossbeam",
|
||||
"directories",
|
||||
"heed",
|
||||
"hmac",
|
||||
"http",
|
||||
"image",
|
||||
"jsonwebtoken",
|
||||
@@ -266,6 +267,7 @@ dependencies = [
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_yaml",
|
||||
"sha-1",
|
||||
"sled",
|
||||
"thiserror",
|
||||
"thread_local",
|
||||
@@ -428,6 +430,16 @@ dependencies = [
|
||||
"lazy_static",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crypto-mac"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1d1a86f49236c215f271d40892d5fc950490551400b02ef360692c29815c714"
|
||||
dependencies = [
|
||||
"generic-array",
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "curve25519-dalek"
|
||||
version = "3.2.0"
|
||||
@@ -897,6 +909,16 @@ dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hmac"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a2a2320eb7ec0ebe8da8f744d7812d9fc4cb4d09344ac01898dbcb6a20ae69b"
|
||||
dependencies = [
|
||||
"crypto-mac",
|
||||
"digest",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hostname"
|
||||
version = "0.3.1"
|
||||
@@ -1968,7 +1990,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"js_int",
|
||||
@@ -1989,7 +2011,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-api"
|
||||
version = "0.18.5"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
@@ -2005,7 +2027,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-api-macros"
|
||||
version = "0.18.5"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2016,7 +2038,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-appservice-api"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"ruma-api",
|
||||
"ruma-common",
|
||||
@@ -2030,7 +2052,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-client-api"
|
||||
version = "0.12.3"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"assign",
|
||||
"bytes",
|
||||
@@ -2050,7 +2072,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-common"
|
||||
version = "0.6.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"js_int",
|
||||
@@ -2065,7 +2087,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-events"
|
||||
version = "0.24.6"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"indoc",
|
||||
"js_int",
|
||||
@@ -2081,7 +2103,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-events-macros"
|
||||
version = "0.24.6"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2092,7 +2114,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-federation-api"
|
||||
version = "0.3.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-api",
|
||||
@@ -2107,7 +2129,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identifiers"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"paste",
|
||||
"percent-encoding",
|
||||
@@ -2122,7 +2144,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identifiers-macros"
|
||||
version = "0.20.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"ruma-identifiers-validation",
|
||||
@@ -2132,7 +2154,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identifiers-validation"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
@@ -2140,7 +2162,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-identity-service-api"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-api",
|
||||
@@ -2153,7 +2175,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-push-gateway-api"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"js_int",
|
||||
"ruma-api",
|
||||
@@ -2168,7 +2190,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-serde"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"form_urlencoded",
|
||||
@@ -2182,7 +2204,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-serde-macros"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
@@ -2193,7 +2215,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-signatures"
|
||||
version = "0.9.0"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"base64 0.13.0",
|
||||
"ed25519-dalek",
|
||||
@@ -2210,7 +2232,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "ruma-state-res"
|
||||
version = "0.4.1"
|
||||
source = "git+https://github.com/ruma/ruma?rev=44cfd0adbc83303c19aef590ad0d71647e19f197#44cfd0adbc83303c19aef590ad0d71647e19f197"
|
||||
source = "git+https://github.com/ruma/ruma?rev=e7f01ca55a1eff437bad754bf0554cc09f44ec2a#e7f01ca55a1eff437bad754bf0554cc09f44ec2a"
|
||||
dependencies = [
|
||||
"itertools 0.10.1",
|
||||
"js_int",
|
||||
@@ -2422,6 +2444,19 @@ dependencies = [
|
||||
"yaml-rust",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha-1"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6"
|
||||
dependencies = [
|
||||
"block-buffer",
|
||||
"cfg-if 1.0.0",
|
||||
"cpufeatures",
|
||||
"digest",
|
||||
"opaque-debug",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "sha1"
|
||||
version = "0.6.0"
|
||||
|
||||
+5
-3
@@ -19,7 +19,7 @@ rocket = { version = "0.5.0-rc.1", features = ["tls"] } # Used to handle request
|
||||
|
||||
# Used for matrix spec type definitions and helpers
|
||||
#ruma = { version = "0.4.0", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||
ruma = { git = "https://github.com/ruma/ruma", rev = "58cdcae1f9a8f4824bcbec1de1bb13e659c66804", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||
ruma = { git = "https://github.com/ruma/ruma", rev = "e7f01ca55a1eff437bad754bf0554cc09f44ec2a", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||
#ruma = { git = "https://github.com/timokoesters/ruma", rev = "50c1db7e0a3a21fc794b0cce3b64285a4c750c71", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||
#ruma = { path = "../ruma/crates/ruma", features = ["compat", "rand", "appservice-api-c", "client-api", "federation-api", "push-gateway-api-c", "state-res", "unstable-pre-spec", "unstable-exhaustive-types"] }
|
||||
|
||||
@@ -79,6 +79,9 @@ num_cpus = "1.13.0"
|
||||
threadpool = "1.8.1"
|
||||
heed = { git = "https://github.com/timokoesters/heed.git", rev = "f6f825da7fb2c758867e05ad973ef800a6fe1d5d", optional = true }
|
||||
thread_local = "1.1.3"
|
||||
# used for TURN server authentication
|
||||
hmac = "0.11.0"
|
||||
sha-1 = "0.9.8"
|
||||
|
||||
[features]
|
||||
default = ["conduit_bin", "backend_sqlite"]
|
||||
@@ -120,13 +123,12 @@ maintainer-scripts = "debian/"
|
||||
systemd-units = { unit-name = "matrix-conduit" }
|
||||
|
||||
[profile.dev]
|
||||
lto = 'thin'
|
||||
lto = 'off'
|
||||
incremental = true
|
||||
|
||||
[profile.release]
|
||||
lto = 'thin'
|
||||
incremental = true
|
||||
|
||||
codegen-units=32
|
||||
# If you want to make flamegraphs, enable debug info:
|
||||
# debug = true
|
||||
|
||||
@@ -2,25 +2,30 @@
|
||||
|
||||
## Getting help
|
||||
|
||||
If you run into any problems while setting up Conduit, write an email to `timo@koesters.xyz`, ask us in `#conduit:matrix.org` or [open an issue on GitLab](https://gitlab.com/famedly/conduit/-/issues/new).
|
||||
If you run into any problems while setting up Conduit, write an email to `timo@koesters.xyz`, ask us
|
||||
in `#conduit:matrix.org` or [open an issue on GitLab](https://gitlab.com/famedly/conduit/-/issues/new).
|
||||
|
||||
## Installing Conduit
|
||||
|
||||
Although you might be able to compile Conduit for Windows, we do recommend running it on a linux server. We therefore
|
||||
only offer Linux binaries.
|
||||
|
||||
You may simply download the binary that fits your machine. Run `uname -m` to see what you need. Now copy the right url:
|
||||
|
||||
| CPU Architecture | GNU (Ubuntu, Debian, ArchLinux, ...) | MUSL (Alpine, ... ) |
|
||||
| -------------------- | ------------------------------------- | ----------------------- |
|
||||
| x84_64 / amd64 | [Download][x84_64-gnu] | [Download][x84_64-musl] |
|
||||
| armv7 (Raspberry Pi) | [Download][armv7-gnu] | - |
|
||||
| armv8 / aarch64 | [Download][armv8-gnu] | - |
|
||||
|
||||
[x84_64-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-gnu?job=build:release:cargo:x86_64-unknown-linux-gnu
|
||||
| CPU Architecture | Download link |
|
||||
| ------------------------------------------- | ----------------------- |
|
||||
| x84_64 / amd64 (Most servers and computers) | [Download][x84_64-musl] |
|
||||
| armv6 | [Download][armv6-musl] |
|
||||
| armv7 (e.g. Raspberry Pi by default) | [Download][armv7-musl] |
|
||||
| armv8 / aarch64 | [Download][armv8-musl] |
|
||||
|
||||
[x84_64-musl]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-x86_64-unknown-linux-musl?job=build:release:cargo:x86_64-unknown-linux-musl
|
||||
|
||||
[armv7-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-armv7-unknown-linux-gnueabihf?job=build:release:cargo:armv7-unknown-linux-gnueabihf
|
||||
[armv6-musl]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-arm-unknown-linux-musleabihf?job=build:release:cargo:arm-unknown-linux-musleabihf
|
||||
|
||||
[armv8-gnu]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-aarch64-unknown-linux-gnu?job=build:release:cargo:aarch64-unknown-linux-gnu
|
||||
[armv7-musl]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-armv7-unknown-linux-musleabihf?job=build:release:cargo:armv7-unknown-linux-musleabihf
|
||||
|
||||
[armv8-musl]: https://gitlab.com/famedly/conduit/-/jobs/artifacts/master/raw/conduit-aarch64-unknown-linux-musl?job=build:release:cargo:aarch64-unknown-linux-musl
|
||||
|
||||
```bash
|
||||
$ sudo wget -O /usr/local/bin/matrix-conduit <url>
|
||||
@@ -32,15 +37,15 @@ Alternatively, you may compile the binary yourself using
|
||||
```bash
|
||||
$ cargo build --release
|
||||
```
|
||||
|
||||
Note that this currently requires Rust 1.50.
|
||||
|
||||
If you want to cross compile Conduit to another architecture, read the [Cross-Compile Guide](CROSS_COMPILE.md).
|
||||
|
||||
|
||||
## Adding a Conduit user
|
||||
|
||||
While Conduit can run as any user it is usually better to use dedicated users for different services.
|
||||
This also allows you to make sure that the file permissions are correctly set up.
|
||||
While Conduit can run as any user it is usually better to use dedicated users for different services. This also allows
|
||||
you to make sure that the file permissions are correctly set up.
|
||||
|
||||
In Debian you can use this command to create a Conduit user:
|
||||
|
||||
@@ -50,9 +55,8 @@ sudo adduser --system conduit --no-create-home
|
||||
|
||||
## Setting up a systemd service
|
||||
|
||||
Now we'll set up a systemd service for Conduit, so it's easy to start/stop
|
||||
Conduit and set it to autostart when your server reboots. Simply paste the
|
||||
default systemd service you can find below into
|
||||
Now we'll set up a systemd service for Conduit, so it's easy to start/stop Conduit and set it to autostart when your
|
||||
server reboots. Simply paste the default systemd service you can find below into
|
||||
`/etc/systemd/system/conduit.service`.
|
||||
|
||||
```systemd
|
||||
@@ -77,10 +81,10 @@ Finally, run
|
||||
$ sudo systemctl daemon-reload
|
||||
```
|
||||
|
||||
|
||||
## Creating the Conduit configuration file
|
||||
|
||||
Now we need to create the Conduit's config file in `/etc/matrix-conduit/conduit.toml`. Paste this in **and take a moment to read it. You need to change at least the server name.**
|
||||
Now we need to create the Conduit's config file in `/etc/matrix-conduit/conduit.toml`. Paste this in **and take a moment
|
||||
to read it. You need to change at least the server name.**
|
||||
|
||||
```toml
|
||||
[global]
|
||||
@@ -128,8 +132,8 @@ address = "127.0.0.1" # This makes sure Conduit can only be reached using the re
|
||||
|
||||
## Setting the correct file permissions
|
||||
|
||||
As we are using a Conduit specific user we need to allow it to read the config.
|
||||
To do that you can run this command on Debian:
|
||||
As we are using a Conduit specific user we need to allow it to read the config. To do that you can run this command on
|
||||
Debian:
|
||||
|
||||
```bash
|
||||
sudo chown -R conduit:nogroup /etc/matrix-conduit
|
||||
@@ -142,7 +146,6 @@ sudo mkdir -p /var/lib/matrix-conduit/conduit_db
|
||||
sudo chown -R conduit:nogroup /var/lib/matrix-conduit/conduit_db
|
||||
```
|
||||
|
||||
|
||||
## Setting up the Reverse Proxy
|
||||
|
||||
This depends on whether you use Apache, Nginx or another web server.
|
||||
@@ -171,11 +174,9 @@ ProxyPassReverse /_matrix/ http://127.0.0.1:6167/_matrix/
|
||||
$ sudo systemctl reload apache2
|
||||
```
|
||||
|
||||
|
||||
### Nginx
|
||||
|
||||
If you use Nginx and not Apache, add the following server section inside the
|
||||
http section of `/etc/nginx/nginx.conf`
|
||||
If you use Nginx and not Apache, add the following server section inside the http section of `/etc/nginx/nginx.conf`
|
||||
|
||||
```nginx
|
||||
server {
|
||||
@@ -198,13 +199,13 @@ server {
|
||||
include /etc/letsencrypt/options-ssl-nginx.conf;
|
||||
}
|
||||
```
|
||||
|
||||
**You need to make some edits again.** When you are done, run
|
||||
|
||||
```bash
|
||||
$ sudo systemctl reload nginx
|
||||
```
|
||||
|
||||
|
||||
## SSL Certificate
|
||||
|
||||
The easiest way to get an SSL certificate, if you don't have one already, is to install `certbot` and run this:
|
||||
@@ -213,7 +214,6 @@ The easiest way to get an SSL certificate, if you don't have one already, is to
|
||||
$ sudo certbot -d your.server.name
|
||||
```
|
||||
|
||||
|
||||
## You're done!
|
||||
|
||||
Now you can start Conduit with:
|
||||
|
||||
+52
-22
@@ -1,7 +1,10 @@
|
||||
# syntax=docker/dockerfile:1
|
||||
FROM rust:1.53-alpine as builder
|
||||
FROM docker.io/rust:1.53-alpine AS builder
|
||||
WORKDIR /usr/src/conduit
|
||||
|
||||
# Install required packages to build Conduit and it's dependencies
|
||||
RUN apk add musl-dev
|
||||
|
||||
# == Build dependencies without our own code separately for caching ==
|
||||
#
|
||||
# Need a fake main.rs since Cargo refuses to build anything otherwise.
|
||||
@@ -9,44 +12,71 @@ WORKDIR /usr/src/conduit
|
||||
# See https://github.com/rust-lang/cargo/issues/2644 for a Cargo feature
|
||||
# request that would allow just dependencies to be compiled, presumably
|
||||
# regardless of whether source files are available.
|
||||
RUN mkdir src && echo 'fn main() {}' > src/main.rs
|
||||
RUN mkdir src && touch src/lib.rs && echo 'fn main() {}' > src/main.rs
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
RUN cargo build
|
||||
# TODO: RUN cargo build --release
|
||||
RUN cargo build --release && rm -r src
|
||||
|
||||
# == Actual build ==
|
||||
RUN rm -r src
|
||||
# Copy over actual Conduit sources
|
||||
COPY src src
|
||||
# main.rs has to have its timestamp updated for this to work correctly since
|
||||
|
||||
# main.rs and lib.rs need their timestamp updated for this to work correctly since
|
||||
# otherwise the build with the fake main.rs from above is newer than the
|
||||
# source files (COPY preserves timestamps).
|
||||
RUN touch src/main.rs
|
||||
|
||||
RUN cargo install --path .
|
||||
# TODO: RUN cargo install --release --path .
|
||||
#
|
||||
# Builds conduit and places the binary at /usr/src/conduit/target/release/conduit
|
||||
RUN touch src/main.rs && touch src/lib.rs && cargo build --release
|
||||
|
||||
|
||||
# This build stage is going to be run later
|
||||
FROM alpine:3.14
|
||||
|
||||
# Install packages needed to run Conduit
|
||||
|
||||
# ---------------------------------------------------------------------------------------------------------------
|
||||
# Stuff below this line actually ends up in the resulting docker image
|
||||
# ---------------------------------------------------------------------------------------------------------------
|
||||
FROM docker.io/alpine:3.14 AS runner
|
||||
|
||||
# Standard port on which Conduit launches.
|
||||
# You still need to map the port when using the docker command or docker-compose.
|
||||
EXPOSE 6167
|
||||
|
||||
# Note from @jfowl: I would like to remove this in the future and just have the Docker version be configured with envs.
|
||||
ENV CONDUIT_CONFIG="/srv/conduit/conduit.toml"
|
||||
|
||||
# Conduit needs:
|
||||
# ca-certificates: for https
|
||||
# libgcc: Apparently this is needed, even if I (@jfowl) don't know exactly why. But whatever, it's not that big.
|
||||
RUN apk add --no-cache \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libgcc
|
||||
|
||||
# Prepare path for database and media files
|
||||
|
||||
# Created directory for the database and media files
|
||||
RUN mkdir -p /srv/conduit/.local/share/conduit
|
||||
|
||||
# TODO: Change ? or maybe leave it like that
|
||||
RUN mkdir -p /srv/conduit/.local/share/conduit
|
||||
COPY --from=builder /usr/local/cargo/bin/conduit /srv/conduit/
|
||||
# Test if Conduit is still alive, uses the same endpoint as Element
|
||||
COPY ./docker/healthcheck.sh /srv/conduit/
|
||||
HEALTHCHECK --start-period=5s --interval=5s CMD ./healthcheck.sh
|
||||
|
||||
# TODO: Check if we don't want to just use ENVs for running condit in docker
|
||||
ENV CONDUIT_CONFIG="/srv/conduit/conduit.toml"
|
||||
# Copy over the actual Conduit binary from the builder stage
|
||||
COPY --from=builder /usr/src/conduit/target/release/conduit /srv/conduit/
|
||||
|
||||
# TODO: not needed, but documents it?
|
||||
EXPOSE 6167
|
||||
# Improve security: Don't run stuff as root, that does not need to run as root:
|
||||
# Add www-data user and group with UID 82, as used by alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install
|
||||
RUN set -x ; \
|
||||
addgroup -Sg 82 www-data 2>/dev/null ; \
|
||||
adduser -S -D -H -h /srv/conduit -G www-data -g www-data www-data 2>/dev/null ; \
|
||||
addgroup www-data www-data 2>/dev/null && exit 0 ; exit 1
|
||||
|
||||
# Change ownership of Conduit files to www-data user and group
|
||||
RUN chown -cR www-data:www-data /srv/conduit
|
||||
RUN chmod +x /srv/conduit/healthcheck.sh
|
||||
|
||||
# Change user to www-data
|
||||
USER www-data
|
||||
# Set container home directory
|
||||
WORKDIR /srv/conduit
|
||||
|
||||
# Run Conduit and print backtraces on panics
|
||||
ENV RUST_BACKTRACE=1
|
||||
ENTRYPOINT [ "/srv/conduit/conduit" ]
|
||||
+47
-58
@@ -2,53 +2,41 @@
|
||||
|
||||
> **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.
|
||||
|
||||
|
||||
## Docker
|
||||
|
||||
### Build & Dockerfile
|
||||
|
||||
The Dockerfile provided by Conduit has two stages, each of which creates an image.
|
||||
|
||||
1. **Builder:** Builds the binary from local context or by cloning a git revision from the official repository.
|
||||
2. **Runtime:** 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.
|
||||
|
||||
The Dockerfile includes a few build arguments that should be supplied when building it.
|
||||
|
||||
``` Dockerfile
|
||||
ARG LOCAL=false
|
||||
ARG CREATED
|
||||
ARG VERSION
|
||||
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 `origin/master`.
|
||||
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.
|
||||
|
||||
To build the image you can use the following command
|
||||
|
||||
``` bash
|
||||
docker build . -t matrixconduit/matrix-conduit:latest --build-arg CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml)
|
||||
```bash
|
||||
docker build --tag matrixconduit/matrix-conduit:latest .
|
||||
```
|
||||
|
||||
which also will tag the resulting image as `matrixconduit/matrix-conduit:latest`.
|
||||
**Note:** it ommits the two optional `build-arg`s.
|
||||
|
||||
|
||||
### Run
|
||||
|
||||
After building the image you can simply run it with
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
docker run -d -p 8448:6167 -v ~/conduit.toml:/srv/conduit/conduit.toml -v db:/srv/conduit/.local/share/conduit matrixconduit/matrix-conduit:latest
|
||||
```
|
||||
|
||||
or you can skip the build step and pull the image from one of the following registries:
|
||||
|
||||
| Registry | Image | Size |
|
||||
| --------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------- |
|
||||
| Docker Hub | [matrixconduit/matrix-conduit:latest](https://hub.docker.com/r/matrixconduit/matrix-conduit) |  |
|
||||
| GitLab Registry | [registry.gitlab.com/famedly/conduit/conduit:latest](https://gitlab.com/famedly/conduit/container_registry/2134341) |  |
|
||||
| Registry | Image | Size |
|
||||
| --------------- | --------------------------------------------------------------- | --------------------- |
|
||||
| Docker Hub | [matrixconduit/matrix-conduit:latest][dh] | ![Image Size][shield] |
|
||||
| GitLab Registry | [registry.gitlab.com/famedly/conduit/matrix-conduit:latest][gl] | ![Image Size][shield] |
|
||||
|
||||
[dh]: https://hub.docker.com/r/matrixconduit/matrix-conduit
|
||||
[gl]: https://gitlab.com/famedly/conduit/container_registry/
|
||||
[shield]: https://img.shields.io/docker/image-size/matrixconduit/matrix-conduit/latest
|
||||
|
||||
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).
|
||||
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
|
||||
@@ -56,29 +44,26 @@ to pass `-e CONDUIT_CONFIG=""` into your container. For an overview of possible
|
||||
|
||||
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.
|
||||
|
||||
|
||||
## Docker-compose
|
||||
|
||||
If the docker command is not for you or your setup, you can also use one of the provided `docker-compose` files. Depending on your proxy setup, use the [`docker-compose.traefik.yml`](docker-compose.traefik.yml) and [`docker-compose.override.traefik.yml`](docker-compose.override.traefik.yml) for Traefik (don't forget to remove `.traefik` from the filenames) or the normal [`docker-compose.yml`](../docker-compose.yml) for every other reverse proxy. Additional info about deploying
|
||||
Conduit can be found [here](../DEPLOY.md).
|
||||
|
||||
|
||||
### Build
|
||||
|
||||
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:
|
||||
|
||||
``` bash
|
||||
CREATED=$(date -u +'%Y-%m-%dT%H:%M:%SZ') VERSION=$(grep -m1 -o '[0-9].[0-9].[0-9]' Cargo.toml) docker-compose up
|
||||
```bash
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
This will also start the container right afterwards, so if want it to run in detached mode, you also should use the `-d` flag. For possible `build-args`, please take a look at the above `Build & Dockerfile` section.
|
||||
|
||||
This will also start the container right afterwards, so if want it to run in detached mode, you also should use the `-d` flag.
|
||||
|
||||
### Run
|
||||
|
||||
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:
|
||||
|
||||
``` bash
|
||||
```bash
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
@@ -101,32 +86,36 @@ So...step by step:
|
||||
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.
|
||||
- `./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;
|
||||
|
||||
location /.well-known/matrix/ {
|
||||
root /var/www;
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
}
|
||||
```
|
||||
- `./nginx/www/.well-known/matrix/client` (relative to the compose file, you can change this, but then also need to change the volume mapping)
|
||||
```json
|
||||
{
|
||||
"m.homeserver": {
|
||||
"base_url": "https://<SUBDOMAIN>.<DOMAIN>"
|
||||
}
|
||||
}
|
||||
```
|
||||
- `./nginx/www/.well-known/matrix/server` (relative to the compose file, you can change this, but then also need to change the volume mapping)
|
||||
```json
|
||||
{
|
||||
"m.server": "<SUBDOMAIN>.<DOMAIN>:443"
|
||||
}
|
||||
```
|
||||
- `./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;
|
||||
|
||||
location /.well-known/matrix/ {
|
||||
root /var/www;
|
||||
default_type application/json;
|
||||
add_header Access-Control-Allow-Origin *;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
- `./nginx/www/.well-known/matrix/client` (relative to the compose file, you can change this, but then also need to change the volume mapping)
|
||||
```json
|
||||
{
|
||||
"m.homeserver": {
|
||||
"base_url": "https://<SUBDOMAIN>.<DOMAIN>"
|
||||
}
|
||||
}
|
||||
```
|
||||
- `./nginx/www/.well-known/matrix/server` (relative to the compose file, you can change this, but then also need to change the volume mapping)
|
||||
```json
|
||||
{
|
||||
"m.server": "<SUBDOMAIN>.<DOMAIN>:443"
|
||||
}
|
||||
```
|
||||
|
||||
6. Run `docker-compose up -d`
|
||||
7. Connect to your homeserver with your preferred client and create a user. You should do this immediatly after starting Conduit, because the first created user is the admin.
|
||||
|
||||
@@ -8,20 +8,26 @@
|
||||
# Credit's for the original Dockerfile: Weasy666.
|
||||
# ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
FROM alpine:3.14
|
||||
FROM docker.io/alpine:3.14 AS runner
|
||||
|
||||
# Install packages needed to run Conduit
|
||||
# Standard port on which Conduit launches.
|
||||
# You still need to map the port when using the docker command or docker-compose.
|
||||
EXPOSE 6167
|
||||
|
||||
# Note from @jfowl: I would like to remove this in the future and just have the Docker version be configured with envs.
|
||||
ENV CONDUIT_CONFIG="/srv/conduit/conduit.toml"
|
||||
|
||||
# Conduit needs:
|
||||
# ca-certificates: for https
|
||||
# libgcc: Apparently this is needed, even if I (@jfowl) don't know exactly why. But whatever, it's not that big.
|
||||
RUN apk add --no-cache \
|
||||
ca-certificates \
|
||||
curl \
|
||||
libgcc
|
||||
|
||||
|
||||
ARG CREATED
|
||||
ARG VERSION
|
||||
ARG GIT_REF
|
||||
|
||||
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} \
|
||||
@@ -37,23 +43,21 @@ LABEL org.opencontainers.image.created=${CREATED} \
|
||||
org.opencontainers.image.documentation="https://gitlab.com/famedly/conduit" \
|
||||
org.opencontainers.image.ref.name=""
|
||||
|
||||
# Standard port on which Conduit launches. You still need to map the port when using the docker command or docker-compose.
|
||||
EXPOSE 6167
|
||||
|
||||
# create data folder for database
|
||||
# Created directory for the database and media files
|
||||
RUN mkdir -p /srv/conduit/.local/share/conduit
|
||||
|
||||
# Test if Conduit is still alive, uses the same endpoint as Element
|
||||
COPY ./docker/healthcheck.sh /srv/conduit/
|
||||
HEALTHCHECK --start-period=5s --interval=60s CMD ./healthcheck.sh
|
||||
HEALTHCHECK --start-period=5s --interval=5s CMD ./healthcheck.sh
|
||||
|
||||
# Copy the Conduit binary into the image at the latest possible moment to maximise caching:
|
||||
|
||||
# depending on the target platform (e.g. "linux/arm/v7", "linux/arm64/v8", or "linux/amd64")
|
||||
# Depending on the target platform (e.g. "linux/arm/v7", "linux/arm64/v8", or "linux/amd64")
|
||||
# copy the matching binary into this docker image
|
||||
ARG TARGETPLATFORM
|
||||
COPY ./$TARGETPLATFORM /srv/conduit/conduit
|
||||
|
||||
|
||||
# Improve security: Don't run stuff as root, that does not need to run as root:
|
||||
# Add www-data user and group with UID 82, as used by alpine
|
||||
# https://git.alpinelinux.org/aports/tree/main/nginx/nginx.pre-install
|
||||
RUN set -x ; \
|
||||
@@ -65,9 +69,11 @@ RUN set -x ; \
|
||||
RUN chown -cR www-data:www-data /srv/conduit
|
||||
RUN chmod +x /srv/conduit/healthcheck.sh
|
||||
|
||||
# Set user to www-data
|
||||
# Change user to www-data
|
||||
USER www-data
|
||||
# Set container home directory
|
||||
WORKDIR /srv/conduit
|
||||
# Run Conduit
|
||||
|
||||
# Run Conduit and print backtraces on panics
|
||||
ENV RUST_BACKTRACE=1
|
||||
ENTRYPOINT [ "/srv/conduit/conduit" ]
|
||||
|
||||
@@ -7,7 +7,7 @@ fi
|
||||
|
||||
# The actual health check.
|
||||
# We try to first get a response on HTTP and when that fails on HTTPS and when that fails, we exit with code 1.
|
||||
# TODO: Change this to a single curl call. Do we have a config value that we can check for that?
|
||||
curl --fail -s "http://localhost:${CONDUIT_PORT}/_matrix/client/versions" || \
|
||||
curl -k --fail -s "https://localhost:${CONDUIT_PORT}/_matrix/client/versions" || \
|
||||
# TODO: Change this to a single wget call. Do we have a config value that we can check for that?
|
||||
wget --no-verbose --tries=1 --spider "http://localhost:${CONDUIT_PORT}/_matrix/client/versions" || \
|
||||
wget --no-verbose --tries=1 --spider "https://localhost:${CONDUIT_PORT}/_matrix/client/versions" || \
|
||||
exit 1
|
||||
|
||||
@@ -34,7 +34,7 @@ use ruma::{
|
||||
EventType,
|
||||
},
|
||||
identifiers::RoomName,
|
||||
push, RoomAliasId, RoomId, RoomVersionId, UserId,
|
||||
push, RoomAliasId, RoomId, UserId,
|
||||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
use tracing::info;
|
||||
@@ -282,7 +282,7 @@ pub async fn register_route(
|
||||
let mut content = RoomCreateEventContent::new(conduit_user.clone());
|
||||
content.federate = true;
|
||||
content.predecessor = None;
|
||||
content.room_version = RoomVersionId::Version6;
|
||||
content.room_version = db.globals.default_room_version();
|
||||
|
||||
// 1. The room create event
|
||||
db.rooms.build_and_append_pdu(
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
use crate::{ConduitResult, Ruma};
|
||||
use ruma::{
|
||||
api::client::r0::capabilities::{
|
||||
get_capabilities, Capabilities, RoomVersionStability, RoomVersionsCapability,
|
||||
},
|
||||
RoomVersionId,
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Ruma};
|
||||
use ruma::api::client::r0::capabilities::{
|
||||
get_capabilities, Capabilities, RoomVersionStability, RoomVersionsCapability,
|
||||
};
|
||||
use std::collections::BTreeMap;
|
||||
|
||||
@@ -17,17 +14,28 @@ use rocket::get;
|
||||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/capabilities", data = "<_body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(_body))]
|
||||
#[tracing::instrument(skip(_body, db))]
|
||||
pub async fn get_capabilities_route(
|
||||
_body: Ruma<get_capabilities::Request>,
|
||||
db: DatabaseGuard,
|
||||
) -> ConduitResult<get_capabilities::Response> {
|
||||
let mut available = BTreeMap::new();
|
||||
available.insert(RoomVersionId::Version5, RoomVersionStability::Stable);
|
||||
available.insert(RoomVersionId::Version6, RoomVersionStability::Stable);
|
||||
if db.globals.allow_unstable_room_versions() {
|
||||
for room_version in &db.globals.unstable_room_versions {
|
||||
available.insert(room_version.clone(), RoomVersionStability::Stable);
|
||||
}
|
||||
} else {
|
||||
for room_version in &db.globals.unstable_room_versions {
|
||||
available.insert(room_version.clone(), RoomVersionStability::Unstable);
|
||||
}
|
||||
}
|
||||
for room_version in &db.globals.stable_room_versions {
|
||||
available.insert(room_version.clone(), RoomVersionStability::Stable);
|
||||
}
|
||||
|
||||
let mut capabilities = Capabilities::new();
|
||||
capabilities.room_versions = RoomVersionsCapability {
|
||||
default: RoomVersionId::Version6,
|
||||
default: db.globals.default_room_version(),
|
||||
available,
|
||||
};
|
||||
|
||||
|
||||
@@ -551,7 +551,7 @@ async fn join_room_by_id_helper(
|
||||
federation::membership::create_join_event_template::v1::Request {
|
||||
room_id,
|
||||
user_id: sender_user,
|
||||
ver: &[RoomVersionId::Version5, RoomVersionId::Version6],
|
||||
ver: &db.globals.supported_room_versions(),
|
||||
},
|
||||
)
|
||||
.await;
|
||||
@@ -566,12 +566,7 @@ async fn join_room_by_id_helper(
|
||||
let (make_join_response, remote_server) = make_join_response_and_server?;
|
||||
|
||||
let room_version = match make_join_response.room_version {
|
||||
Some(room_version)
|
||||
if room_version == RoomVersionId::Version5
|
||||
|| room_version == RoomVersionId::Version6 =>
|
||||
{
|
||||
room_version
|
||||
}
|
||||
Some(room_version) if db.rooms.is_supported_version(&db, &room_version) => room_version,
|
||||
_ => return Err(Error::BadServerResponse("Room version is not supported")),
|
||||
};
|
||||
|
||||
@@ -890,9 +885,10 @@ pub(crate) async fn invite_helper<'a>(
|
||||
None
|
||||
};
|
||||
|
||||
// If there was no create event yet, assume we are creating a version 6 room right now
|
||||
// If there was no create event yet, assume we are creating a room with the default
|
||||
// version right now
|
||||
let room_version_id = create_event_content
|
||||
.map_or(RoomVersionId::Version6, |create_event| {
|
||||
.map_or(db.globals.default_room_version(), |create_event| {
|
||||
create_event.room_version
|
||||
});
|
||||
let room_version =
|
||||
@@ -934,7 +930,7 @@ pub(crate) async fn invite_helper<'a>(
|
||||
unsigned.insert("prev_content".to_owned(), prev_pdu.content.clone());
|
||||
unsigned.insert(
|
||||
"prev_sender".to_owned(),
|
||||
serde_json::from_str(prev_pdu.sender.as_str()).expect("UserId is valid string"),
|
||||
to_raw_value(&prev_pdu.sender).expect("UserId is valid"),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1039,7 +1035,8 @@ pub(crate) async fn invite_helper<'a>(
|
||||
let pub_key_map = RwLock::new(BTreeMap::new());
|
||||
|
||||
// We do not add the event_id field to the pdu here because of signature and hashes checks
|
||||
let (event_id, value) = match crate::pdu::gen_event_id_canonical_json(&response.event) {
|
||||
let (event_id, value) = match crate::pdu::gen_event_id_canonical_json(&response.event, &db)
|
||||
{
|
||||
Ok(t) => t,
|
||||
Err(_) => {
|
||||
// Event could not be converted to canonical json
|
||||
|
||||
@@ -16,6 +16,7 @@ mod profile;
|
||||
mod push;
|
||||
mod read_marker;
|
||||
mod redact;
|
||||
mod report;
|
||||
mod room;
|
||||
mod search;
|
||||
mod session;
|
||||
@@ -47,6 +48,7 @@ pub use profile::*;
|
||||
pub use push::*;
|
||||
pub use read_marker::*;
|
||||
pub use redact::*;
|
||||
pub use report::*;
|
||||
pub use room::*;
|
||||
pub use search::*;
|
||||
pub use session::*;
|
||||
|
||||
@@ -0,0 +1,83 @@
|
||||
use crate::{database::admin::AdminCommand, database::DatabaseGuard, ConduitResult, Error, Ruma};
|
||||
use ruma::{
|
||||
api::client::{error::ErrorKind, r0::room::report_content},
|
||||
events::room::message,
|
||||
Int,
|
||||
};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
use rocket::{http::RawStr, post};
|
||||
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/report/{eventId}`
|
||||
///
|
||||
/// Reports an inappropriate event to homeserver admins
|
||||
///
|
||||
#[cfg_attr(
|
||||
feature = "conduit_bin",
|
||||
post("/_matrix/client/r0/rooms/<_>/report/<_>", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(db, body))]
|
||||
pub async fn report_event_route(
|
||||
db: DatabaseGuard,
|
||||
body: Ruma<report_content::Request<'_>>,
|
||||
) -> ConduitResult<report_content::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let pdu = match db.rooms.get_pdu(&body.event_id)? {
|
||||
Some(pdu) => pdu,
|
||||
_ => {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
"Invalid Event ID",
|
||||
))
|
||||
}
|
||||
};
|
||||
|
||||
if body.score > Int::from(0) || body.score < Int::from(-100) {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
"Invalid score, must be within 0 to -100",
|
||||
));
|
||||
};
|
||||
|
||||
if body.reason.chars().count() > 250 {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::InvalidParam,
|
||||
"Reason too long, should be 250 characters or fewer",
|
||||
));
|
||||
};
|
||||
|
||||
db.admin.send(AdminCommand::SendMessage(
|
||||
message::RoomMessageEventContent::text_html(
|
||||
format!(
|
||||
"Report received from: {}\n\n\
|
||||
Event ID: {}\n\
|
||||
Room ID: {}\n\
|
||||
Sent By: {}\n\n\
|
||||
Report Score: {}\n\
|
||||
Report Reason: {}",
|
||||
sender_user, pdu.event_id, pdu.room_id, pdu.sender, body.score, body.reason
|
||||
)
|
||||
.to_owned(),
|
||||
format!(
|
||||
"<details><summary>Report received from: <a href=\"https://matrix.to/#/{0}\">{0}\
|
||||
</a></summary><ul><li>Event Info<ul><li>Event ID: <code>{1}</code>\
|
||||
<a href=\"https://matrix.to/#/{2}/{1}\">🔗</a></li><li>Room ID: <code>{2}</code>\
|
||||
</li><li>Sent By: <a href=\"https://matrix.to/#/{3}\">{3}</a></li></ul></li><li>\
|
||||
Report Info<ul><li>Report Score: {4}</li><li>Report Reason: {5}</li></ul></li>\
|
||||
</ul></details>",
|
||||
sender_user,
|
||||
pdu.event_id,
|
||||
pdu.room_id,
|
||||
pdu.sender,
|
||||
body.score,
|
||||
RawStr::new(&body.reason).html_escape()
|
||||
)
|
||||
.to_owned(),
|
||||
),
|
||||
));
|
||||
|
||||
db.flush()?;
|
||||
|
||||
Ok(report_content::Response {}.into())
|
||||
}
|
||||
+99
-23
@@ -22,11 +22,16 @@ use ruma::{
|
||||
},
|
||||
EventType,
|
||||
},
|
||||
serde::JsonObject,
|
||||
RoomAliasId, RoomId, RoomVersionId,
|
||||
serde::{CanonicalJsonObject, JsonObject},
|
||||
RoomAliasId, RoomId,
|
||||
};
|
||||
use serde_json::{json, value::to_raw_value};
|
||||
use std::{
|
||||
cmp::max,
|
||||
collections::BTreeMap,
|
||||
convert::{TryFrom, TryInto},
|
||||
sync::Arc,
|
||||
};
|
||||
use serde_json::value::to_raw_value;
|
||||
use std::{cmp::max, collections::BTreeMap, convert::TryFrom, sync::Arc};
|
||||
use tracing::{info, warn};
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
@@ -102,12 +107,9 @@ pub async fn create_room_route(
|
||||
}
|
||||
})?;
|
||||
|
||||
let mut content = RoomCreateEventContent::new(sender_user.clone());
|
||||
content.federate = body.creation_content.federate;
|
||||
content.predecessor = body.creation_content.predecessor.clone();
|
||||
content.room_version = match body.room_version.clone() {
|
||||
let room_version = match body.room_version.clone() {
|
||||
Some(room_version) => {
|
||||
if room_version == RoomVersionId::Version5 || room_version == RoomVersionId::Version6 {
|
||||
if db.rooms.is_supported_version(&db, &room_version) {
|
||||
room_version
|
||||
} else {
|
||||
return Err(Error::BadRequest(
|
||||
@@ -116,9 +118,59 @@ pub async fn create_room_route(
|
||||
));
|
||||
}
|
||||
}
|
||||
None => RoomVersionId::Version6,
|
||||
None => db.globals.default_room_version(),
|
||||
};
|
||||
|
||||
let content = match &body.creation_content {
|
||||
Some(content) => {
|
||||
let mut content = content
|
||||
.deserialize_as::<CanonicalJsonObject>()
|
||||
.expect("Invalid creation content");
|
||||
content.insert(
|
||||
"creator".into(),
|
||||
json!(&sender_user).try_into().map_err(|_| {
|
||||
Error::BadRequest(ErrorKind::BadJson, "Invalid creation content")
|
||||
})?,
|
||||
);
|
||||
content.insert(
|
||||
"room_version".into(),
|
||||
json!(room_version.as_str()).try_into().map_err(|_| {
|
||||
Error::BadRequest(ErrorKind::BadJson, "Invalid creation content")
|
||||
})?,
|
||||
);
|
||||
content
|
||||
}
|
||||
None => {
|
||||
let mut content = serde_json::from_str::<CanonicalJsonObject>(
|
||||
to_raw_value(&RoomCreateEventContent::new(sender_user.clone()))
|
||||
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Invalid creation content"))?
|
||||
.get(),
|
||||
)
|
||||
.unwrap();
|
||||
content.insert(
|
||||
"room_version".into(),
|
||||
json!(room_version.as_str()).try_into().map_err(|_| {
|
||||
Error::BadRequest(ErrorKind::BadJson, "Invalid creation content")
|
||||
})?,
|
||||
);
|
||||
content
|
||||
}
|
||||
};
|
||||
|
||||
// Validate creation content
|
||||
let de_result = serde_json::from_str::<CanonicalJsonObject>(
|
||||
to_raw_value(&content)
|
||||
.expect("Invalid creation content")
|
||||
.get(),
|
||||
);
|
||||
|
||||
if let Err(_) = de_result {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Invalid creation content",
|
||||
));
|
||||
}
|
||||
|
||||
// 1. The room create event
|
||||
db.rooms.build_and_append_pdu(
|
||||
PduBuilder {
|
||||
@@ -432,7 +484,7 @@ pub async fn get_room_aliases_route(
|
||||
.into())
|
||||
}
|
||||
|
||||
/// # `GET /_matrix/client/r0/rooms/{roomId}/upgrade`
|
||||
/// # `POST /_matrix/client/r0/rooms/{roomId}/upgrade`
|
||||
///
|
||||
/// Upgrades the room.
|
||||
///
|
||||
@@ -453,10 +505,7 @@ pub async fn upgrade_room_route(
|
||||
) -> ConduitResult<upgrade_room::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
if !matches!(
|
||||
body.new_version,
|
||||
RoomVersionId::Version5 | RoomVersionId::Version6
|
||||
) {
|
||||
if !db.rooms.is_supported_version(&db, &body.new_version) {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::UnsupportedRoomVersion,
|
||||
"This server does not support that room version.",
|
||||
@@ -510,16 +559,15 @@ pub async fn upgrade_room_route(
|
||||
);
|
||||
let state_lock = mutex_state.lock().await;
|
||||
|
||||
// Get the old room federations status
|
||||
let federate = serde_json::from_str::<RoomCreateEventContent>(
|
||||
// Get the old room creation event
|
||||
let mut create_event_content = serde_json::from_str::<CanonicalJsonObject>(
|
||||
db.rooms
|
||||
.room_state_get(&body.room_id, &EventType::RoomCreate, "")?
|
||||
.ok_or_else(|| Error::bad_database("Found room without m.room.create event."))?
|
||||
.content
|
||||
.get(),
|
||||
)
|
||||
.map_err(|_| Error::bad_database("Invalid room event in database."))?
|
||||
.federate;
|
||||
.map_err(|_| Error::bad_database("Invalid room event in database."))?;
|
||||
|
||||
// Use the m.room.tombstone event as the predecessor
|
||||
let predecessor = Some(ruma::events::room::create::PreviousRoom::new(
|
||||
@@ -528,10 +576,38 @@ pub async fn upgrade_room_route(
|
||||
));
|
||||
|
||||
// Send a m.room.create event containing a predecessor field and the applicable room_version
|
||||
let mut create_event_content = RoomCreateEventContent::new(sender_user.clone());
|
||||
create_event_content.federate = federate;
|
||||
create_event_content.room_version = body.new_version.clone();
|
||||
create_event_content.predecessor = predecessor;
|
||||
create_event_content.insert(
|
||||
"creator".into(),
|
||||
json!(&sender_user)
|
||||
.try_into()
|
||||
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"))?,
|
||||
);
|
||||
create_event_content.insert(
|
||||
"room_version".into(),
|
||||
json!(&body.new_version)
|
||||
.try_into()
|
||||
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"))?,
|
||||
);
|
||||
create_event_content.insert(
|
||||
"predecessor".into(),
|
||||
json!(predecessor)
|
||||
.try_into()
|
||||
.map_err(|_| Error::BadRequest(ErrorKind::BadJson, "Error forming creation event"))?,
|
||||
);
|
||||
|
||||
// Validate creation event content
|
||||
let de_result = serde_json::from_str::<CanonicalJsonObject>(
|
||||
to_raw_value(&create_event_content)
|
||||
.expect("Error forming creation event")
|
||||
.get(),
|
||||
);
|
||||
|
||||
if let Err(_) = de_result {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::BadJson,
|
||||
"Error forming creation event",
|
||||
));
|
||||
}
|
||||
|
||||
db.rooms.build_and_append_pdu(
|
||||
PduBuilder {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
use crate::ConduitResult;
|
||||
use crate::{database::DatabaseGuard, ConduitResult, Ruma};
|
||||
use hmac::{Hmac, Mac, NewMac};
|
||||
use ruma::api::client::r0::voip::get_turn_server_info;
|
||||
use std::time::Duration;
|
||||
use ruma::SecondsSinceUnixEpoch;
|
||||
use sha1::Sha1;
|
||||
use std::time::{Duration, SystemTime};
|
||||
|
||||
type HmacSha1 = Hmac<Sha1>;
|
||||
|
||||
#[cfg(feature = "conduit_bin")]
|
||||
use rocket::get;
|
||||
@@ -8,14 +13,46 @@ use rocket::get;
|
||||
/// # `GET /_matrix/client/r0/voip/turnServer`
|
||||
///
|
||||
/// TODO: Returns information about the recommended turn server.
|
||||
#[cfg_attr(feature = "conduit_bin", get("/_matrix/client/r0/voip/turnServer"))]
|
||||
#[tracing::instrument]
|
||||
pub async fn turn_server_route() -> ConduitResult<get_turn_server_info::Response> {
|
||||
#[cfg_attr(
|
||||
feature = "conduit_bin",
|
||||
get("/_matrix/client/r0/voip/turnServer", data = "<body>")
|
||||
)]
|
||||
#[tracing::instrument(skip(body, db))]
|
||||
pub async fn turn_server_route(
|
||||
body: Ruma<get_turn_server_info::Request>,
|
||||
db: DatabaseGuard,
|
||||
) -> ConduitResult<get_turn_server_info::Response> {
|
||||
let sender_user = body.sender_user.as_ref().expect("user is authenticated");
|
||||
|
||||
let turn_secret = db.globals.turn_secret();
|
||||
|
||||
let (username, password) = if turn_secret != "" {
|
||||
let expiry = SecondsSinceUnixEpoch::from_system_time(
|
||||
SystemTime::now() + Duration::from_secs(db.globals.turn_ttl()),
|
||||
)
|
||||
.expect("time is valid");
|
||||
|
||||
let username: String = format!("{}:{}", expiry.get(), sender_user);
|
||||
|
||||
let mut mac = HmacSha1::new_from_slice(turn_secret.as_bytes())
|
||||
.expect("HMAC can take key of any size");
|
||||
mac.update(username.as_bytes());
|
||||
|
||||
let password: String = base64::encode_config(mac.finalize().into_bytes(), base64::STANDARD);
|
||||
|
||||
(username, password)
|
||||
} else {
|
||||
(
|
||||
db.globals.turn_username().clone(),
|
||||
db.globals.turn_password().clone(),
|
||||
)
|
||||
};
|
||||
|
||||
Ok(get_turn_server_info::Response {
|
||||
username: "".to_owned(),
|
||||
password: "".to_owned(),
|
||||
uris: Vec::new(),
|
||||
ttl: Duration::from_secs(60 * 60 * 24),
|
||||
username: username,
|
||||
password: password,
|
||||
uris: db.globals.turn_uris().to_vec(),
|
||||
ttl: Duration::from_secs(db.globals.turn_ttl()),
|
||||
}
|
||||
.into())
|
||||
}
|
||||
|
||||
+23
-1
@@ -24,7 +24,7 @@ use rocket::{
|
||||
request::{FromRequest, Request},
|
||||
Shutdown, State,
|
||||
};
|
||||
use ruma::{DeviceId, EventId, RoomId, ServerName, UserId};
|
||||
use ruma::{DeviceId, EventId, RoomId, RoomVersionId, ServerName, UserId};
|
||||
use serde::{de::IgnoredAny, Deserialize};
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap, HashSet},
|
||||
@@ -63,8 +63,12 @@ pub struct Config {
|
||||
allow_federation: bool,
|
||||
#[serde(default = "true_fn")]
|
||||
allow_room_creation: bool,
|
||||
#[serde(default = "true_fn")]
|
||||
allow_unstable_room_versions: bool,
|
||||
#[serde(default = "false_fn")]
|
||||
pub allow_jaeger: bool,
|
||||
#[serde(default = "default_room_version")]
|
||||
default_room_version: RoomVersionId,
|
||||
#[serde(default = "false_fn")]
|
||||
pub tracing_flame: bool,
|
||||
#[serde(default)]
|
||||
@@ -74,6 +78,16 @@ pub struct Config {
|
||||
trusted_servers: Vec<Box<ServerName>>,
|
||||
#[serde(default = "default_log")]
|
||||
pub log: String,
|
||||
#[serde(default)]
|
||||
turn_username: String,
|
||||
#[serde(default)]
|
||||
turn_password: String,
|
||||
#[serde(default = "Vec::new")]
|
||||
turn_uris: Vec<String>,
|
||||
#[serde(default)]
|
||||
turn_secret: String,
|
||||
#[serde(default = "default_turn_ttl")]
|
||||
turn_ttl: u64,
|
||||
|
||||
#[serde(flatten)]
|
||||
catchall: BTreeMap<String, IgnoredAny>,
|
||||
@@ -127,10 +141,18 @@ fn default_max_concurrent_requests() -> u16 {
|
||||
100
|
||||
}
|
||||
|
||||
fn default_room_version() -> RoomVersionId {
|
||||
RoomVersionId::Version6
|
||||
}
|
||||
|
||||
fn default_log() -> String {
|
||||
"info,state_res=warn,rocket=off,_=off,sled=off".to_owned()
|
||||
}
|
||||
|
||||
fn default_turn_ttl() -> u64 {
|
||||
60 * 60 * 24
|
||||
}
|
||||
|
||||
#[cfg(feature = "sled")]
|
||||
pub type Engine = abstraction::sled::Engine;
|
||||
|
||||
|
||||
+61
-2
@@ -4,7 +4,8 @@ use ruma::{
|
||||
client::r0::sync::sync_events,
|
||||
federation::discovery::{ServerSigningKeys, VerifyKey},
|
||||
},
|
||||
DeviceId, EventId, MilliSecondsSinceUnixEpoch, RoomId, ServerName, ServerSigningKeyId, UserId,
|
||||
DeviceId, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, ServerName,
|
||||
ServerSigningKeyId, UserId,
|
||||
};
|
||||
use std::{
|
||||
collections::{BTreeMap, HashMap},
|
||||
@@ -39,6 +40,8 @@ pub struct Globals {
|
||||
keypair: Arc<ruma::signatures::Ed25519KeyPair>,
|
||||
dns_resolver: TokioAsyncResolver,
|
||||
jwt_decoding_key: Option<jsonwebtoken::DecodingKey<'static>>,
|
||||
pub stable_room_versions: Vec<RoomVersionId>,
|
||||
pub unstable_room_versions: Vec<RoomVersionId>,
|
||||
pub(super) server_signingkeys: Arc<dyn Tree>,
|
||||
pub bad_event_ratelimiter: Arc<RwLock<HashMap<EventId, RateLimitState>>>,
|
||||
pub bad_signature_ratelimiter: Arc<RwLock<HashMap<Vec<String>, RateLimitState>>>,
|
||||
@@ -132,7 +135,16 @@ impl Globals {
|
||||
.as_ref()
|
||||
.map(|secret| jsonwebtoken::DecodingKey::from_secret(secret.as_bytes()).into_static());
|
||||
|
||||
let s = Self {
|
||||
// Supported and stable room versions
|
||||
let stable_room_versions = vec![RoomVersionId::Version6];
|
||||
// Experimental, partially supported room versions
|
||||
let unstable_room_versions = vec![
|
||||
RoomVersionId::Version3,
|
||||
RoomVersionId::Version4,
|
||||
RoomVersionId::Version5,
|
||||
];
|
||||
|
||||
let mut s = Self {
|
||||
globals,
|
||||
config,
|
||||
keypair: Arc::new(keypair),
|
||||
@@ -143,6 +155,8 @@ impl Globals {
|
||||
tls_name_override,
|
||||
server_signingkeys,
|
||||
jwt_decoding_key,
|
||||
stable_room_versions,
|
||||
unstable_room_versions,
|
||||
bad_event_ratelimiter: Arc::new(RwLock::new(HashMap::new())),
|
||||
bad_signature_ratelimiter: Arc::new(RwLock::new(HashMap::new())),
|
||||
servername_ratelimiter: Arc::new(RwLock::new(HashMap::new())),
|
||||
@@ -155,6 +169,14 @@ impl Globals {
|
||||
|
||||
fs::create_dir_all(s.get_media_folder())?;
|
||||
|
||||
if !s
|
||||
.supported_room_versions()
|
||||
.contains(&s.config.default_room_version)
|
||||
{
|
||||
error!("Room version in config isn't supported, falling back to Version 6");
|
||||
s.config.default_room_version = RoomVersionId::Version6;
|
||||
};
|
||||
|
||||
Ok(s)
|
||||
}
|
||||
|
||||
@@ -214,6 +236,14 @@ impl Globals {
|
||||
self.config.allow_room_creation
|
||||
}
|
||||
|
||||
pub fn allow_unstable_room_versions(&self) -> bool {
|
||||
self.config.allow_unstable_room_versions
|
||||
}
|
||||
|
||||
pub fn default_room_version(&self) -> RoomVersionId {
|
||||
self.config.default_room_version.clone()
|
||||
}
|
||||
|
||||
pub fn trusted_servers(&self) -> &[Box<ServerName>] {
|
||||
&self.config.trusted_servers
|
||||
}
|
||||
@@ -226,6 +256,35 @@ impl Globals {
|
||||
self.jwt_decoding_key.as_ref()
|
||||
}
|
||||
|
||||
pub fn turn_password(&self) -> &String {
|
||||
&self.config.turn_password
|
||||
}
|
||||
|
||||
pub fn turn_ttl(&self) -> u64 {
|
||||
self.config.turn_ttl
|
||||
}
|
||||
|
||||
pub fn turn_uris(&self) -> &[String] {
|
||||
&self.config.turn_uris
|
||||
}
|
||||
|
||||
pub fn turn_username(&self) -> &String {
|
||||
&self.config.turn_username
|
||||
}
|
||||
|
||||
pub fn turn_secret(&self) -> &String {
|
||||
&self.config.turn_secret
|
||||
}
|
||||
|
||||
pub fn supported_room_versions(&self) -> Vec<RoomVersionId> {
|
||||
let mut room_versions: Vec<RoomVersionId> = vec![];
|
||||
room_versions.extend(self.stable_room_versions.clone());
|
||||
if self.allow_unstable_room_versions() {
|
||||
room_versions.extend(self.unstable_room_versions.clone());
|
||||
};
|
||||
room_versions
|
||||
}
|
||||
|
||||
/// TODO: the key valid until timestamp is only honored in room version > 4
|
||||
/// Remove the outdated keys and insert the new ones.
|
||||
///
|
||||
|
||||
+30
-7
@@ -129,6 +129,12 @@ pub struct Rooms {
|
||||
}
|
||||
|
||||
impl Rooms {
|
||||
/// Returns true if a given room version is supported
|
||||
#[tracing::instrument(skip(self, db))]
|
||||
pub fn is_supported_version(&self, db: &Database, room_version: &RoomVersionId) -> bool {
|
||||
db.globals.supported_room_versions().contains(room_version)
|
||||
}
|
||||
|
||||
/// Builds a StateMap by iterating over all keys that start
|
||||
/// with state_hash, this gives the full state for the given state_hash.
|
||||
#[tracing::instrument(skip(self))]
|
||||
@@ -1983,9 +1989,10 @@ impl Rooms {
|
||||
None
|
||||
};
|
||||
|
||||
// If there was no create event yet, assume we are creating a version 6 room right now
|
||||
// If there was no create event yet, assume we are creating a room with the default
|
||||
// version right now
|
||||
let room_version_id = create_event_content
|
||||
.map_or(RoomVersionId::Version6, |create_event| {
|
||||
.map_or(db.globals.default_room_version(), |create_event| {
|
||||
create_event.room_version
|
||||
});
|
||||
let room_version = RoomVersion::new(&room_version_id).expect("room version is supported");
|
||||
@@ -2778,11 +2785,7 @@ impl Rooms {
|
||||
let (make_leave_response, remote_server) = make_leave_response_and_server?;
|
||||
|
||||
let room_version_id = match make_leave_response.room_version {
|
||||
Some(version)
|
||||
if version == RoomVersionId::Version5 || version == RoomVersionId::Version6 =>
|
||||
{
|
||||
version
|
||||
}
|
||||
Some(version) if self.is_supported_version(&db, &version) => version,
|
||||
_ => return Err(Error::BadServerResponse("Room version is not supported")),
|
||||
};
|
||||
|
||||
@@ -3448,4 +3451,24 @@ impl Rooms {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Returns the room's version.
|
||||
#[tracing::instrument(skip(self))]
|
||||
pub fn get_room_version(&self, room_id: &RoomId) -> Result<RoomVersionId> {
|
||||
let create_event = self.room_state_get(room_id, &EventType::RoomCreate, "")?;
|
||||
|
||||
let create_event_content: Option<RoomCreateEventContent> = create_event
|
||||
.as_ref()
|
||||
.map(|create_event| {
|
||||
serde_json::from_str(create_event.content.get()).map_err(|e| {
|
||||
warn!("Invalid create event: {}", e);
|
||||
Error::bad_database("Invalid create event in db.")
|
||||
})
|
||||
})
|
||||
.transpose()?;
|
||||
let room_version = create_event_content
|
||||
.map(|create_event| create_event.room_version)
|
||||
.ok_or_else(|| Error::BadDatabase("Invalid room version"))?;
|
||||
Ok(room_version)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,7 @@ fn setup_rocket(config: Figment, data: Arc<RwLock<Database>>) -> rocket::Rocket<
|
||||
client_server::create_typing_event_route,
|
||||
client_server::create_room_route,
|
||||
client_server::redact_event_route,
|
||||
client_server::report_event_route,
|
||||
client_server::create_alias_route,
|
||||
client_server::delete_alias_route,
|
||||
client_server::get_alias_route,
|
||||
|
||||
+12
-4
@@ -1,4 +1,4 @@
|
||||
use crate::Error;
|
||||
use crate::{Database, Error};
|
||||
use ruma::{
|
||||
events::{
|
||||
room::member::RoomMemberEventContent, AnyEphemeralRoomEvent, AnyInitialStateEvent,
|
||||
@@ -6,7 +6,7 @@ use ruma::{
|
||||
EventType, StateEvent,
|
||||
},
|
||||
serde::{CanonicalJsonObject, CanonicalJsonValue, Raw},
|
||||
state_res, EventId, MilliSecondsSinceUnixEpoch, RoomId, RoomVersionId, UInt, UserId,
|
||||
state_res, EventId, MilliSecondsSinceUnixEpoch, RoomId, UInt, UserId,
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::{
|
||||
@@ -331,16 +331,24 @@ impl Ord for PduEvent {
|
||||
/// Returns a tuple of the new `EventId` and the PDU as a `BTreeMap<String, CanonicalJsonValue>`.
|
||||
pub(crate) fn gen_event_id_canonical_json(
|
||||
pdu: &RawJsonValue,
|
||||
db: &Database,
|
||||
) -> crate::Result<(EventId, CanonicalJsonObject)> {
|
||||
let value = serde_json::from_str(pdu.get()).map_err(|e| {
|
||||
let value: CanonicalJsonObject = serde_json::from_str(pdu.get()).map_err(|e| {
|
||||
warn!("Error parsing incoming event {:?}: {:?}", pdu, e);
|
||||
Error::BadServerResponse("Invalid PDU in server response")
|
||||
})?;
|
||||
|
||||
let room_id = value
|
||||
.get("room_id")
|
||||
.and_then(|id| RoomId::try_from(id.as_str()?).ok())
|
||||
.expect("Invalid room id in event");
|
||||
|
||||
let room_version_id = db.rooms.get_room_version(&room_id);
|
||||
|
||||
let event_id = EventId::try_from(&*format!(
|
||||
"${}",
|
||||
// Anything higher than version3 behaves the same
|
||||
ruma::signatures::reference_hash(&value, &RoomVersionId::Version6)
|
||||
ruma::signatures::reference_hash(&value, &room_version_id?)
|
||||
.expect("ruma can calculate reference hashes")
|
||||
))
|
||||
.expect("ruma's reference hashes are valid event ids");
|
||||
|
||||
+11
-10
@@ -725,7 +725,7 @@ pub async fn send_transaction_message_route(
|
||||
|
||||
for pdu in &body.pdus {
|
||||
// We do not add the event_id field to the pdu here because of signature and hashes checks
|
||||
let (event_id, value) = match crate::pdu::gen_event_id_canonical_json(pdu) {
|
||||
let (event_id, value) = match crate::pdu::gen_event_id_canonical_json(pdu, &db) {
|
||||
Ok(t) => t,
|
||||
Err(_) => {
|
||||
// Event could not be converted to canonical json
|
||||
@@ -1911,7 +1911,7 @@ pub(crate) fn fetch_and_handle_outliers<'a>(
|
||||
Ok(res) => {
|
||||
warn!("Got {} over federation", id);
|
||||
let (calculated_event_id, value) =
|
||||
match crate::pdu::gen_event_id_canonical_json(&res.pdu) {
|
||||
match crate::pdu::gen_event_id_canonical_json(&res.pdu, &db) {
|
||||
Ok(t) => t,
|
||||
Err(_) => {
|
||||
back_off((**id).clone());
|
||||
@@ -2670,10 +2670,12 @@ pub fn create_join_event_template_route(
|
||||
None
|
||||
};
|
||||
|
||||
// If there was no create event yet, assume we are creating a version 6 room right now
|
||||
let room_version_id = create_event_content.map_or(RoomVersionId::Version6, |create_event| {
|
||||
create_event.room_version
|
||||
});
|
||||
// If there was no create event yet, assume we are creating a room with the default version
|
||||
// right now
|
||||
let room_version_id = create_event_content
|
||||
.map_or(db.globals.default_room_version(), |create_event| {
|
||||
create_event.room_version
|
||||
});
|
||||
let room_version = RoomVersion::new(&room_version_id).expect("room version is supported");
|
||||
|
||||
if !body.ver.contains(&room_version_id) {
|
||||
@@ -2721,7 +2723,7 @@ pub fn create_join_event_template_route(
|
||||
unsigned.insert("prev_content".to_owned(), prev_pdu.content.clone());
|
||||
unsigned.insert(
|
||||
"prev_sender".to_owned(),
|
||||
serde_json::from_str(prev_pdu.sender.as_str()).expect("UserId is valid string"),
|
||||
to_raw_value(&prev_pdu.sender).expect("UserId is valid"),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2813,7 +2815,7 @@ async fn create_join_event(
|
||||
// let mut auth_cache = EventMap::new();
|
||||
|
||||
// We do not add the event_id field to the pdu here because of signature and hashes checks
|
||||
let (event_id, value) = match crate::pdu::gen_event_id_canonical_json(pdu) {
|
||||
let (event_id, value) = match crate::pdu::gen_event_id_canonical_json(pdu, &db) {
|
||||
Ok(t) => t,
|
||||
Err(_) => {
|
||||
// Event could not be converted to canonical json
|
||||
@@ -2937,8 +2939,7 @@ pub async fn create_invite_route(
|
||||
return Err(Error::bad_config("Federation is disabled."));
|
||||
}
|
||||
|
||||
if body.room_version != RoomVersionId::Version5 && body.room_version != RoomVersionId::Version6
|
||||
{
|
||||
if !db.rooms.is_supported_version(&db, &body.room_version) {
|
||||
return Err(Error::BadRequest(
|
||||
ErrorKind::IncompatibleRoomVersion {
|
||||
room_version: body.room_version.clone(),
|
||||
|
||||
Reference in New Issue
Block a user