matrix: remove hard coded hostname from element config by envsubst

single-dockerfile
Trammell Hudson 2 years ago
parent 1976e0f55f
commit da380d6847
  1. 2
      matrix/docker-compose.yaml
  2. 4
      matrix/element-config.json.template
  3. 20
      matrix/setup

@ -14,7 +14,7 @@ services:
image: vectorim/element-web:latest image: vectorim/element-web:latest
restart: unless-stopped restart: unless-stopped
volumes: volumes:
- ./element-config.json:/app/config.json - ../data/matrix/element-config.json:/app/config.json
ports: ports:
- "5000:80" - "5000:80"

@ -1,8 +1,8 @@
{ {
"default_server_config": { "default_server_config": {
"m.homeserver": { "m.homeserver": {
"base_url": "https://matrix.hackerspace.zone", "base_url": "https://${MATRIX_HOSTNAME}",
"server_name": "hackerspace.zone" "server_name": "${DOMAIN_NAME}"
}, },
"m.identity_server": { "m.identity_server": {
"base_url": "https://vector.im" "base_url": "https://vector.im"

@ -6,7 +6,8 @@ cd "$DIRNAME"
source ../env.production || die "no top levle env?" source ../env.production || die "no top levle env?"
source env.production || die "no local env?" source env.production || die "no local env?"
SYNAPSE_DIR="../data/matrix/synapse" DATA="../data/matrix"
SYNAPSE_DIR="$DATA/synapse"
HOMESERVER_YAML="$SYNAPSE_DIR/homeserver.yaml" HOMESERVER_YAML="$SYNAPSE_DIR/homeserver.yaml"
if [ -r "$HOMESERVER_YAML" ]; then if [ -r "$HOMESERVER_YAML" ]; then
docker-compose up -d || die "matrix: unable to restart" docker-compose up -d || die "matrix: unable to restart"
@ -14,17 +15,24 @@ if [ -r "$HOMESERVER_YAML" ]; then
fi fi
docker-compose down 2>/dev/null docker-compose down 2>/dev/null
mkdir -p "$DATA"
# fix up the Element client config to have the correct hostname
# based on the environment variables
export DOMAIN_NAME MATRIX_HOSTNAME
envsubst < "element-config.json.template" > "$DATA/element-config.json"
# This will create a *delegated* matrix server, # This will create a *delegated* matrix server,
# where the "servername" is just the top level domain, # where the "servername" is just the top level domain,
# but it is hosted on "matrix.DOMAIN_NAME". # but it is hosted on "matrix.DOMAIN_NAME".
# the syntax here is confusing and it is not clear in # the syntax here is confusing and it is not clear in
# the docs *which* have to be updated. # the docs *which* have to be updated.
docker run -it --rm \ docker-compose run \
-v "`pwd`/$SYNAPSE_DIR:/data" \ --rm \
-e "SYNAPSE_SERVER_NAME=$DOMAIN_NAME" \ -e SYNAPSE_SERVER_NAME="$DOMAIN_NAME" \
-e SYNAPSE_REPORT_STATS=yes \ -e SYNAPSE_REPORT_STATS="no" \
matrixdotorg/synapse:latest generate \ synapse generate \
|| die "unable to generate synapse config" || die "unable to generate synapse config"
MATRIX_CLIENT_SECRET="$(openssl rand -hex 20)" MATRIX_CLIENT_SECRET="$(openssl rand -hex 20)"

Loading…
Cancel
Save