From 5e1563752b2d8e1d142edef6ebd4beb392a7fbf4 Mon Sep 17 00:00:00 2001 From: Gnuxie <50846879+Gnuxie@users.noreply.github.com> Date: Tue, 31 Mar 2026 15:24:42 +0100 Subject: [PATCH] Add sourcemaps to entrypoint and normalise paths in the script (#1065) * Add sourcemaps to entrypoint * Make entrypoint run Draupnir relative to the script. This is important for running draupnir from source either directly in the directory, from ExecStart in systemd, or from inside the docker image. And we're making this change so that we can have better control over the arguments we start Draupnir with in the different environments without having to make disruptive changes. Co-authored-by: Bea <20361868+enbea@users.noreply.github.com> * Add changeset for source installs. We're gonna write up a proper change log but this is just so we don't forger. Co-authored-by: Bea <20361868+enbea@users.noreply.github.com> --- .changeset/perky-buckets-work.md | 6 ++++++ draupnir-entrypoint.sh | 27 +++++++++++++++++---------- 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 .changeset/perky-buckets-work.md diff --git a/.changeset/perky-buckets-work.md b/.changeset/perky-buckets-work.md new file mode 100644 index 0000000..e253871 --- /dev/null +++ b/.changeset/perky-buckets-work.md @@ -0,0 +1,6 @@ +--- +"draupnir": major +--- + +All installations from source will need to change how they install, build, and +start Draupnir. diff --git a/draupnir-entrypoint.sh b/draupnir-entrypoint.sh index 4ae9c6b..af63275 100755 --- a/draupnir-entrypoint.sh +++ b/draupnir-entrypoint.sh @@ -3,17 +3,24 @@ # SPDX-FileCopyrightText: 2024 Gnuxie # SPDX-FileCopyrightText: 2022 The Matrix.org Foundation C.I.C. # -# SPDX-License-Identifier: Apache-2.0 AND AFL-3.0 +# SPDX-License-Identifier: Apache-2.0 -# This is used as the entrypoint in the draupnir Dockerfile. -# We want to transition away form people running the image without specifying `bot` or `appservice`. -# So if eventually cli arguments are provided for the bot version, we want this to be the opportunity to move to `bot`. -# Therefore using arguments without specifying `bot` (or appservice) is unsupported. -# We maintain the behaviour where if it looks like someone is providing an executable to `docker run`, then we will execute that instead. -# This aids configuration and debugging of the image if for example node needed to be started via another method. -case "$1" in - bot) shift; set -- node /apps/draupnir/dist/index.js "$@";; - appservice) shift; set -- node /apps/draupnir/dist/appservice/cli.js "$@";; +# This is used as the entrypoint in the draupnir Dockerfile and convenience for from-source installations. +# This allows us to set default options for node and to switch between the appservice and bot. + +# Help us normalise paths to make sure they are relative to where the script is. +draupnir_path="${0%/*}"; +test x"$draupnir_path" = x"$0" && draupnir_path='.'; +case "$draupnir_path" in + [!/.]*) draupnir_path="./$draupnir_path";; esac +case "$1" in + bot) shift; set -- node --enable-source-maps "${draupnir_path}/apps/draupnir/dist/index.js" "$@";; + appservice) shift; set -- node --enable-source-maps "${draupnir_path}/apps/draupnir/dist/appservice/cli.js" "$@";; +esac + +# If it looks like someone is providing an executable to `docker run`, then we will execute that instead. +# This aids configuration and debugging of the image if for example node needed to be started via another method, +# Or with different options for node. exec "$@";