Open ghost opened 3 years ago
First of all, sorry for the late reply. I didn't get any notifications since the repo is a fork and it was unwatched by default.
You can see the startup command (and modify it) in https://github.com/m0wer/tiddlywiki-docker/blob/a378b10a57a842fa8776099561c22c0fad8548ea/init-and-run-wiki#L24.
A good solution would be to allow users to customize that command when running the Docker image, using the arguments from the docker run command in the init-and-run script (maybe with "$@" or something similar). PRs are welcome.
I did it using docker compose
like this:
Download the Dockerfile
and init-and-run-wiki
from the repo.
Edit the init-and-run-wiki
to suit.
You may also need to chmod +x init-and-run-wiki
, or change Dockerfile
with this line:
ADD --chmod=755 init-and-run-wiki /usr/local/bin/init-and-run-wiki
Make a folder for the data with mkdir tiddlywiki
.
Next create docker-compose.yml
with the following:
version: '3'
services:
tiddlywiki:
build:
dockerfile: Dockerfile
context: .
volumes:
- ./tiddlywiki:/var/lib/tiddlywiki
restart: unless-stopped
ports:
- 8080:8080
Then run docker compose up -d
, and you have a server.
In addition, you can shell into the instance with docker compose exec tiddlywiki sh
, then you can run tiddlywiki
node commands, for example to export your wiki to a HTML file.
Followup, I was able to get Bob working like this:
Dockerfile
FROM node:alpine
RUN npm install -g tiddlywiki@5.2.0
# Setup wiki volume
VOLUME /var/lib/tiddlywiki
WORKDIR /var/lib/tiddlywiki
# Add init-and-run script
ADD --chmod=755 init-and-run-wiki /usr/local/bin/init-and-run-wiki
# Meta
CMD ["/usr/local/bin/init-and-run-wiki"]
init-and-run-wiki
#!/bin/sh
set -e
tiddlywiki_script=$(readlink -f $(which tiddlywiki))
if [ -n "$NODE_MEM" ]; then
# Based on rule of thumb from:
# http://fiznool.com/blog/2016/10/01/running-a-node-dot-js-app-in-a-low-memory-environment/
mem_node_old_space=$((($NODE_MEM*4)/5))
NODEJS_V8_ARGS="--max_old_space_size=$mem_node_old_space $NODEJS_V8_ARGS"
fi
# Setup initial wiki
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
# Define plugins
if [ -n "$PLUGINS" ]; then
plugins_params="$PLUGINS"
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}"
fi
# Start the tiddlywiki server
exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script $plugins_params mywiki --listen $listen_params $OPTIONS
docker-compose.yml
version: '3'
services:
tiddlywiki:
build:
dockerfile: Dockerfile
context: .
volumes:
- ./tiddlywiki:/var/lib/tiddlywiki
restart: unless-stopped
ports:
- 8080:8080
environment:
- PLUGINS=+plugins/tiddlywiki/markdown ++./plugins/OokTech/Bob
- OPTIONS=--wsserver
Hi, how is Tiddly Wiki started inside container? I'm trying to manually install TW5-Bob plugin, and it required to modify startup command: