diff --git a/matrix/docker-compose.yaml b/matrix/docker-compose.yaml index bee648c..ba42dfc 100644 --- a/matrix/docker-compose.yaml +++ b/matrix/docker-compose.yaml @@ -14,7 +14,7 @@ services: image: vectorim/element-web:latest restart: unless-stopped volumes: - - ./element-config.json:/app/config.json + - ../data/matrix/element-config.json:/app/config.json ports: - "5000:80" diff --git a/matrix/element-config.json b/matrix/element-config.json.template similarity index 95% rename from matrix/element-config.json rename to matrix/element-config.json.template index f1d9335..baef3cb 100644 --- a/matrix/element-config.json +++ b/matrix/element-config.json.template @@ -1,8 +1,8 @@ { "default_server_config": { "m.homeserver": { - "base_url": "https://matrix.hackerspace.zone", - "server_name": "hackerspace.zone" + "base_url": "https://${MATRIX_HOSTNAME}", + "server_name": "${DOMAIN_NAME}" }, "m.identity_server": { "base_url": "https://vector.im" diff --git a/matrix/setup b/matrix/setup index 9f262e1..5aee89c 100755 --- a/matrix/setup +++ b/matrix/setup @@ -6,7 +6,8 @@ cd "$DIRNAME" source ../env.production || die "no top levle 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" if [ -r "$HOMESERVER_YAML" ]; then docker-compose up -d || die "matrix: unable to restart" @@ -14,17 +15,24 @@ if [ -r "$HOMESERVER_YAML" ]; then fi 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, # where the "servername" is just the top level domain, # but it is hosted on "matrix.DOMAIN_NAME". # the syntax here is confusing and it is not clear in # the docs *which* have to be updated. -docker run -it --rm \ - -v "`pwd`/$SYNAPSE_DIR:/data" \ - -e "SYNAPSE_SERVER_NAME=$DOMAIN_NAME" \ - -e SYNAPSE_REPORT_STATS=yes \ - matrixdotorg/synapse:latest generate \ +docker-compose run \ + --rm \ + -e SYNAPSE_SERVER_NAME="$DOMAIN_NAME" \ + -e SYNAPSE_REPORT_STATS="no" \ + synapse generate \ || die "unable to generate synapse config" MATRIX_CLIENT_SECRET="$(openssl rand -hex 20)"