Saturday, August 21, 2021

Experimenting with Wikis on the Raspberry PI

Why would I want to run my own wiki?


Why not? Searchable linked notes are awesome!


For work, I use tiddlywiki. It's just an html file with embedded javascript that handles tagging, searching and saving a new copy of itself when changes are made. It's by far the single simplest to run wiki since, it's just a local html file, without the need for a webserver.


It's really useful for storing links, bits of code, bits if information that may be useful etc. Once written and tagged, it's a quick search from getting that bit of information you just can't remember. You can link the page to other relevant pages you wouldn't think of at the time, that may prove invaluable.


But what if you want something you can access from multiple devices? Perhaps tiddlywiki on dropbox? A enticing as it sounds to take something I know and hack a solution around it, I decided to look at a couple other options.


I really didn't want a large setup. I wanted something easy to manage - backup, restore, setup from scratch via script. Something light for the PI since it's pulling double duty as a NAS. 

The first option I looked at was wiki.js. https://js.wiki/
What made this enticing was that it can use several different databases - sqlite included. Sqlite isn't as powerful as other database packages, but it's light. It's simple. Backup and restore is just copying the single file the DB is contained in.


I decided to try setting up a docker image pointing to the rather bare DB I setup.

#install docker
installdocker() {
  curl -fsSL https://get.docker.com -o get-docker.sh
  sudo sh get-docker.sh
  #add pi user to docker group
  sudo usermod -aG docker pi
}
type docker || installdocker

#make folder
mkdir /home/pi/wikidocker
cd /home/pi/wikidocker

config='port: 3000
db:
  type: sqlite
  ssl: false
  storage: /wiki/ggnotes.sqlite 
bindIP: 0.0.0.0
logLevel: info
offline: false
ha: false
dataPath: ./data'
echo "$config" > wikidocker.conf

docker run -d -p 8080:3000 --name GiaWiki \
           --restart unless-stopped -e "DB_TYPE=sqlite" \
	   -e "DB_FILEPATH=/home/pi/wikidocker/ggnotes.sqlite" \
           -v /home/pi/wikidocker/wikidocker.conf:/wiki/config.yml \
	   -v /home/pi/wikidocker/ggnotes.sqlite:/wiki/ggnotes.sqlite \
           requarks/wiki:2

So this little script starts by installing docker on the PI. It makes a folder, sets up a config, and kicks off a docker. 



It's not bad. But minutes after setting this up I found out they will no longer support sqlite on subsequent major releases.

I wanted a light system that would be relatively future proof. I'm not opposed to PostgreSQL, but I'd rather something easier to manage and lighter on resources for the PI. Maybe I'll try setting up PostgreSQL in a docker too. 

Ah! Dokuwiki! It's small, light, quick to setup. https://www.dokuwiki.org
This wiki doesn't use a DB, it's just files under a folder. I can grep out strings if I needed to, and backup is nothing more than tar - so, yay! Easy!

The install is scripted for us too - Thanks Dokuwiki :D

Install apache, and move or symlink the dokuwiki folder to /var/www/html/dokuwiki.

The wiki isn't as full featured as wiki.js but it's still decent.


Going to stick with this one. Backup can be done in the /var/www/html/dokuwiki/data/ folder as described on their site. https://www.dokuwiki.org/faq:backup


My daughter has been liking this. It's simple for her to use. Unlike wiki.js, there's no authentication needed.  There's good and bad for that. It's nice for us since we're just using it on the local network. Bad if we wanted top open this up with read-only permission. This can be put behind another service that handles the authentication though.


My future "todo" items:
  • Use docker more. It's relatively quick to setup and a app container should have all it's prerequisites (in general).
  • Revisit the wiki.js setup as 2 docker scripts. One for postgres, another for wiki.js. Include scripts for backup and restore too.

Cheers.