Tiddlywiki5 run in container - can't set lazy loading

Hello there,

so I managed to deploy a working TW5 on a Qnap NAS in a container using deadlemon image from docker.hub. Unfortunately I am unable to figure out how I can make it lazy load. My TW is about 100MB (1400 tiddlers with images) and it takes approx. 4min. to load depending on a connection speed.

Where is a option to lazy load? How to make it lazy load on every restart?

Thank you, Matt

The pre-built image you are using is already compiled with the startup lines, so if you want to use the root-tiddler=$:/core/save/lazy-images startup config, you will most likely have to compile your own docker image. Does deadlemon offer the Dockerfile that was used to create the image? If so, you can build your own. I build my own from an init script I found somewhere a while back and customized it. I also use lazy-images, and just build a new image with each release of tiddlywiki.

Hi there, I never tried to compile docker images but if it is the only way to go I need to learn it.
Can you explan what are the steps to do it and maybe you could upload somewhere needed files? I will try to do it

1 Like

Well, I’m not familiar with the Qnap NAS as far as if you can bring up a terminal and install everything required to build images from the terminal of the NAS itself, or if you will have to have a separate machine with a terminal to build it. I built mine on a linux machine, compiling it for the arm64 processor on my raspberry pi machines. I am going to be building images for arm64 and amd64 and placing them online for all my machines, so perhaps you could simply try using my images when I upload them to the docker hub after each Tiddlywiki upgrade, similar to how you are currently using deadlemon’s image.

Do you know what architecture your NAS is using? Is it arm or amd/intel?

I’ll be posting arm64v8 and amd64 images that have lazy-loading enabled at the following docker repo:

https://hub.docker.com/r/jbardi/tiddlywiki5-lazy-images

Not sure what CPU your NAS is running, but if it is armv7 you’ll have to wait until I get around to pushing an image for that. If you are unsure, just try pulling the image and if your NAS is on arm64 or 64 bit intel/amd then it will pull the correct image.

1 Like

Thank you. Everything seems to be working fine with Your image.

Hi @CasperBooWisdom,
Thank you for posting the docker image.
Is there any chance you could share the dockerfiles necessary to build it from scratch?

Thanks

1 Like

It is absolutely great to have a docker image of a tiddlywiki-server. Can you tell more about what you did there? Is it a node.js mws instance? Does it already incorporate the bags and recepies concept?

Sure, it is a pretty straightforward and easy docker build. It uses the Dockerfile as well as a file called init-and-run-wiki, which is a shell script to setup the node v8 memory management and the initialization lines to run the server.

Dockerfile:

FROM node:alpine

RUN npm install -g tiddlywiki

WORKDIR /var/lib/tiddlywiki

# Add init-and-run script
ADD init-and-run-wiki /usr/local/bin/init-and-run-wiki

# Meta
CMD ["/usr/local/bin/init-and-run-wiki"]
EXPOSE 8080

init-and-run-wiki:

#!/bin/sh
set -e

tiddlywiki_script=$(readlink -f $(which tiddlywiki))

if [ -n "$NODE_MEM" ]; then
    # Based on rule of thumb:
    # This will determine the correct max_old_space_size depending on the memory of the system.
    # This is to ensure th V8 engine does not crash your tiddlywiki process and ensure you do
    # not run out of memory on the system.
    mem_node_old_space=$((($NODE_MEM*4)/5))
    NODEJS_V8_ARGS="--max_old_space_size=$mem_node_old_space $NODEJS_V8_ARGS"
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

# Start the tiddlywiki server
exec /usr/bin/env node $NODEJS_V8_ARGS $tiddlywiki_script mywiki --listen root-tiddler=$:/core/save/lazy-images host=0.0.0.0 port=8080 debug-level=${DEBUG_LEVEL-none}

Just put the Dockerfile in a directory with the init-and-run-wiki file and run:

docker build -t jbardi/tiddlywiki5-lazy-images:latest .

Or whatever name you want for your image :smiley:

docker-compose.yml:

version: "2.4"
services:
  tiddlywiki:
    container_name: tiddlywiki
    image: jbardi/tiddlywiki5-lazy-images:latest
    volumes:
      - [local folder path here]:/var/lib/tiddlywiki # i.e. /home/username/tiddlywiki:/var/lib/tiddlywiki   
    ports:
      - 8080:8080
    environment:
      - TZ=America/Denver
    restart: unless-stopped
1 Like

No, this is not an mws instance, just the standard node.js tiddlywiki

1 Like

But thank you a lot for this. It would be great to have a documentation and if the MWS is stable a version of that. My dream would be to be able to integrate tiddlywiki into a nextcloud that way … and to be able to use the NC user-managment. Dockerization is an important step for that.

That’s awesome,
Thanks heaps for that!