From 5687667a918424d4897317e5854286c7c8eb3911 Mon Sep 17 00:00:00 2001 From: jyusang Date: Sat, 16 Jul 2022 14:32:51 +0800 Subject: [PATCH 1/3] refactor(init-and-run-wiki): Extract listen command configuration --- init-and-run-wiki | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/init-and-run-wiki b/init-and-run-wiki index 4231b02..7492a9b 100755 --- a/init-and-run-wiki +++ b/init-and-run-wiki @@ -16,10 +16,13 @@ if [ ! -d /var/lib/tiddlywiki/mywiki ]; then mkdir /var/lib/tiddlywiki/mywiki/tiddlers fi +# Configure listen command, see https://tiddlywiki.com/static/ListenCommand.html +listen_params="host=0.0.0.0 port=8080" +listen_params="$listen_params debug-level=${DEBUG_LEVEL-none}" +if [ -n "$USERNAME" ]; then + listen_params="$listen_params username=$USERNAME" + listen_params="$listen_params password=${PASSWORD-wiki}" +fi # Start the tiddlywiki server -if [ -z "$USERNAME" ]; then - exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --listen host=0.0.0.0 port=8080 debug-level=${DEBUG_LEVEL-none}; -else - exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --listen host=0.0.0.0 port=8080 username="$USERNAME" password="${PASSWORD-wiki}" debug-level=${DEBUG_LEVEL-none}; -fi +exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --listen $listen_params From fbfdfdbd3db2f067a07d142ce40ef7f787a8f609 Mon Sep 17 00:00:00 2001 From: jyusang Date: Sat, 16 Jul 2022 15:16:16 +0800 Subject: [PATCH 2/3] chore(Dockerfile): Remove unnecessary expose This `EXPOSE` is probably not needed and it's more flexible to use the `-p` flag in `docker run`. --- Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 50d9ad4..8a4c8f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,4 +11,3 @@ ADD init-and-run-wiki /usr/local/bin/init-and-run-wiki # Meta CMD ["/usr/local/bin/init-and-run-wiki"] -EXPOSE 8080 From 2a342a1cfbe9bc6d5d44fc4dc615c76ddb149902 Mon Sep 17 00:00:00 2001 From: jyusang Date: Sat, 16 Jul 2022 16:15:03 +0800 Subject: [PATCH 3/3] feat(init-and-run-wiki): Support `path-prefix` listen parameter --- README.md | 9 +++++++++ init-and-run-wiki | 3 +++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 846ca3b..6df44c8 100644 --- a/README.md +++ b/README.md @@ -56,3 +56,12 @@ If you are in a memory-constrained environment, you can provide the Set the `DEBUG_LEVEL` environment variable to `debug`. For example by passing `-e DEBUG_LEVEL=debug` option in `docker run`. + +### Path prefix + +Set the `PATH_PREFIX` environment variable to customize the path prefix for +serving TiddlyWiki. For example by passing `-e PATH_PREFIX=\wiki` option in +`docker run`. According to this [note][path-prefix-note], please remember to +configure the client as well. + +[path-prefix-note]: https://tiddlywiki.com/static/Using%2520a%2520custom%2520path%2520prefix%2520with%2520the%2520client-server%2520edition.html diff --git a/init-and-run-wiki b/init-and-run-wiki index 7492a9b..6c873fd 100755 --- a/init-and-run-wiki +++ b/init-and-run-wiki @@ -19,6 +19,9 @@ fi # Configure listen command, see https://tiddlywiki.com/static/ListenCommand.html listen_params="host=0.0.0.0 port=8080" listen_params="$listen_params debug-level=${DEBUG_LEVEL-none}" +if [ -n "$PATH_PREFIX" ]; then + listen_params="$listen_params path-prefix=$PATH_PREFIX" +fi if [ -n "$USERNAME" ]; then listen_params="$listen_params username=$USERNAME" listen_params="$listen_params password=${PASSWORD-wiki}"