BookStack is a simple, self-hosted, easy-to-use platform for organising and storing information.
A friendly middle ground between heavyweights like MediaWiki or Confluence and Gollum, BookStack relies on a database backend (so searching and versioning is easy), but limits itself to a pre-defined, 3-tier structure (book, chapter, page). The result is a lightweight, approachable personal documentation stack, which includes search and Markdown editing.
I like to protect my public-facing web UIs with an oauth_proxy, ensuring that if an application bug (or a user misconfiguration) exposes the app to unplanned public scrutiny, I have a second layer of defense.
Create bookstack.env, and populate with the following variables. Set the oauth_proxy variables provided by your OAuth provider (if applicable.)
# For oauth-proxy (optional)OAUTH2_PROXY_CLIENT_ID=OAUTH2_PROXY_CLIENT_SECRET=OAUTH2_PROXY_COOKIE_SECRET=# For MariaDB/MySQL databaseMYSQL_RANDOM_ROOT_PASSWORD=trueMYSQL_DATABASE=bookstack
MYSQL_USER=bookstack
MYSQL_PASSWORD=secret
# Bookstack-specific variablesDB_HOST=bookstack_db:3306
DB_DATABASE=bookstack
DB_USERNAME=bookstack
DB_PASSWORD=secret
BookStack Docker Swarm config
Create a docker swarm config file in docker-compose syntax (v3), something like the example below:
Fast-track with premix! 🚀
"Premix" is a git repository which includes necessary docker-compose and env files for all published recipes. This means that you can launch any recipe with just a git pull and a docker stack deploy 👍.
🚀 Update: Premix now includes an ansible playbook, enabling you to deploy an entire stack + recipes, with a single ansible command! (more here)
version:'3'services:db:image:mariadb:10env_file:/var/data/config/bookstack/bookstack.envnetworks:-internalvolumes:-/var/data/runtime/bookstack/db:/var/lib/mysqlapp:image:solidnerd/bookstackenv_file:/var/data/config/bookstack/bookstack.envnetworks:-internal-traefik_publicdeploy:labels:# traefik common-traefik.enable=true-traefik.docker.network=traefik_public# traefikv1-traefik.frontend.rule=Host:bookstack.example.com-traefik.port=4180# traefikv2-"traefik.http.routers.bookstack.rule=Host(`bookstack.example.com`)"-"traefik.http.services.bookstack.loadbalancer.server.port=4180"-"traefik.enable=true"# Remove if you wish to access the URL directly-"traefik.http.routers.bookstack.middlewares=forward-auth@file"db-backup:image:mariadb:10env_file:/var/data/config/bookstack/bookstack.envvolumes:-/var/data/bookstack/database-dump:/dump-/etc/localtime:/etc/localtime:roentrypoint:|bash -c 'bash -s <<EOFtrap "break;exit" SIGHUP SIGINT SIGTERMsleep 2mwhile /bin/true; domysqldump -h db --all-databases | gzip -c > /dump/dump_\`date +%d-%m-%Y"_"%H_%M_%S\`.sql.gz(ls -t /dump/dump*.sql.gz|head -n $$BACKUP_NUM_KEEP;ls /dump/dump*.sql.gz)|sort|uniq -u|xargs rm -- {}sleep $$BACKUP_FREQUENCYdoneEOF'networks:-internalnetworks:traefik_public:external:trueinternal:driver:overlayipam:config:-subnet:172.16.33.0/24
Note
Setup unique static subnets for every stack you deploy. This avoids IP/gateway conflicts which can otherwise occur when you're creating/removing stacks a lot. See my list here.
Serving
Launch Bookstack stack
Launch the BookStack stack by running docker stack deploy bookstack -c <path -to-docker-compose.yml>
Log into your new instance at https://YOUR-FQDN, authenticate with oauth_proxy, and then login with username 'admin@admin.com' and password 'password'.
Chef's notes 📓
If you wanted to expose the Bookstack UI directly, you could remove the traefik-forward-auth from the design. ↩
Tip your waiter (sponsor) 👏
Did you receive excellent service? Want to compliment the chef? (..and support development of current and future recipes!) Sponsor me on Github / Ko-Fi / Patreon, or see the contribute page for more (free or paid) ways to say thank you! 👏
Employ your chef (engage) 🤝
Is this too much of a geeky PITA? Do you just want results, stat? I do this for a living - I'm a full-time Kubernetes contractor, providing consulting and engineering expertise to businesses needing short-term, short-notice support in the cloud-native space, including AWS/Azure/GKE, Kubernetes, CI/CD and automation.
Want to know now when this recipe gets updated, or when future recipes are added? Subscribe to the RSS feed, or leave your email address below, and we'll keep you updated.