Add sourcemaps to entrypoint and normalise paths in the script (#1065)
Some checks failed
Docker Hub - Develop / docker-latest (push) Failing after 29s
GHCR - Development Branches / ghcr-publish (push) Failing after 30s
Tests / Build & Lint (push) Failing after 4m59s
Tests / Unit tests (push) Successful in 5m59s
Tests / Application Service Integration tests (push) Failing after 14m50s
Tests / Integration tests (push) Failing after 14m56s

* 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>
This commit is contained in:
Gnuxie
2026-03-31 15:24:42 +01:00
committed by GitHub
parent 082118bea0
commit 5e1563752b
2 changed files with 23 additions and 10 deletions

View File

@@ -0,0 +1,6 @@
---
"draupnir": major
---
All installations from source will need to change how they install, build, and
start Draupnir.

View File

@@ -3,17 +3,24 @@
# SPDX-FileCopyrightText: 2024 Gnuxie <Gnuxie@protonmail.com>
# 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 "$@";