Merge pull request #11 from Whatang/serve_at_uri

Serve at uri
This commit is contained in:
Martin Honermeyer 2019-01-02 09:29:25 +01:00 committed by GitHub
commit dc545b4f52
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 1 deletions

View file

@ -7,6 +7,7 @@ VOLUME /var/lib/tiddlywiki
WORKDIR /var/lib/tiddlywiki
# Add init-and-run script
ADD tiddlyweb_host /tiddlyweb_host_template
ADD init-and-run-wiki /usr/local/bin/init-and-run-wiki
# Meta

View file

@ -29,3 +29,5 @@ Simply provide the USERNAME and PASSWORD env variables to customise.
If you are in a memory-constrained environment, you can provide the
`NODE_MEM` environment variable to specify the memory ceiling (in MB)
To serve the tiddlywiki at a [non-root prefix path](https://tiddlywiki.com/static/Using%2520a%2520custom%2520path%2520prefix%2520with%2520the%2520client-server%2520edition.html) set the `SERVE_URI` environment variable: this variable ''must'' start with a forward slash character. The tiddlywiki will be served by the container at http://<IP>/${SERVE_URI} - the container initialization script takes care of setting the required host configuration tiddler.

View file

@ -12,7 +12,24 @@ fi
if [ ! -d /var/lib/tiddlywiki/mywiki ]; then
/usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --init server
mkdir /var/lib/tiddlywiki/mywiki/tiddlers
fi
exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --server 8080 $:/core/save/all text/plain text/html ${USERNAME:-user} ${PASSWORD:-'wiki'} 0.0.0.0
# Configure the tiddlywiki to be served on a path if it is given
WEBHOST_TID=/var/lib/tiddlywiki/mywiki/tiddlers/\$__config_tiddlyweb_host.tid
if [ -n "${SERVE_URI}" ]; then
cp /tiddlyweb_host_template ${WEBHOST_TID}
echo '$protocol$//$host$'${SERVE_URI}"/" >> ${WEBHOST_TID}
echo "tiddlywiki will be served at ${SERVE_URI}"
else
if [ -e ${WEBHOST_TID} ]; then
rm ${WEBHOST_TID}
fi
fi
# Start the tiddlywiki server
exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --server 8080 $:/core/save/all text/plain text/html ${USERNAME:-user} ${PASSWORD:-'wiki'} 0.0.0.0 ${SERVE_URI}

4
tiddlyweb_host Normal file
View file

@ -0,0 +1,4 @@
title: $:/config/tiddlyweb/host
type: text/vnd.tiddlywiki