Skip to content

Wikijs Docker Installation & Update

Introduction

Wiki.js is an open-source, modern, and feature-rich wiki software. It allows users to create and collaborate on knowledge bases, documentation, and other types of content in a wiki-style format. Wiki.js is designed to be user-friendly and flexible, offering a range of customization options and powerful features for managing and organizing information.

Installation

Create a directory structure to store the configuration file and database like this.

wikijs
├── config
│   ├── config.yml
│   └── db.sqlite
├── data
│   └── repo
└── run.sh

Create the config.yml like this for sqlite operation.
(see this for more information)

# ---------------------------------------------------------------------
# Port the server should listen to
# ---------------------------------------------------------------------
port: 3000

# ---------------------------------------------------------------------
# Database
# ---------------------------------------------------------------------
db:
  type: sqlite

  # PostgreSQL / MySQL / MariaDB / MS SQL Server only:
  host: mariadb
  port: 3306
  user: root
  pass: root
  db: wikijs
  ssl: false

  # Optional - PostgreSQL / MySQL / MariaDB only:
  # -> Uncomment lines you need below and set `auto` to false
  # -> Full list of accepted options: https://nodejs.org/api/tls.html#tls_tls_createsecurecontext_options
  sslOptions:
    auto: true
    # rejectUnauthorized: false
    # ca: path/to/ca.crt
    # cert: path/to/cert.crt
    # key: path/to/key.pem
    # pfx: path/to/cert.pfx
    # passphrase: xyz123

  # SQLite only:
  storage: /config/db.sqlite

# ---------------------------------------------------------------------
# SSL/TLS Settings
# ---------------------------------------------------------------------
# Consider using a reverse proxy (e.g. nginx) if you require more
# advanced options than those provided below.
ssl:
  enabled: false
  port: 3443

  # Provider to use, possible values: custom, letsencrypt
  provider: custom

  # ++++++ For custom only ++++++
  # Certificate format, either 'pem' or 'pfx':
  format: pem
  # Using PEM format:
  key: path/to/key.pem
  cert: path/to/cert.pem
  # Using PFX format:
  pfx: path/to/cert.pfx
  # Passphrase when using encrypted PEM / PFX keys (default: null):
  passphrase: null
  # Diffie Hellman parameters, with key length being greater or equal
  # to 1024 bits (default: null):
  dhparam: null

  # ++++++ For letsencrypt only ++++++
  domain: wiki.yourdomain.com
  subscriberEmail: admin@example.com

# ---------------------------------------------------------------------
# Database Pool Options
# ---------------------------------------------------------------------
# Refer to https://github.com/vincit/tarn.js for all possible options
pool:
# min: 2
# max: 10

# ---------------------------------------------------------------------
# IP address the server should listen to
# ---------------------------------------------------------------------
# Leave 0.0.0.0 for all interfaces
bindIP: 0.0.0.0

# ---------------------------------------------------------------------
# Log Level
# ---------------------------------------------------------------------
# Possible values: error, warn, info (default), verbose, debug, silly
logLevel: info

# ---------------------------------------------------------------------
# Upload Limits
# ---------------------------------------------------------------------
# If you're using a reverse-proxy in front of Wiki.js, you must also
# change your proxy upload limits!
uploads:
  # Maximum upload size in bytes per file (default: 5242880 (5 MB))
  maxFileSize: 5242880
  # Maximum file uploads per request (default: 10)
  maxFiles: 10

# ---------------------------------------------------------------------
# Offline Mode
# ---------------------------------------------------------------------
# If your server cannot access the internet. Set to true and manually
# download the offline files for sideloading.
offline: false

# ---------------------------------------------------------------------
# High-Availability
# ---------------------------------------------------------------------
# Set to true if you have multiple concurrent instances running off the
# same DB (e.g. Kubernetes pods / load balanced instances). Leave false
# otherwise. You MUST be using PostgreSQL to use this feature.
ha: false

# ---------------------------------------------------------------------
# Data Path
# ---------------------------------------------------------------------
# Writeable data path used for cache and temporary user uploads.
dataPath: /data

Create a wikijs.sh file for running (run), stopping (stop) and inspecting (shell).

#!/bin/bash

# Get this script working directory.
SCRIPT_DIR="$(realpath "$(dirname "${BASH_SOURCE[0]}")")"
# Name of the container.
NAME="wikijs"

# Show help when first argument is empty.
if [ -z "$1" ]; then
    echo "Usage: ${0} {run | shell | stop}"
    exit 1
fi

# Check to check if a shell is to be created for inspecting the container content.
if [[ "${1}" == "shell" ]]; then
    # Remove the named container.
    docker rm -f "${NAME}"
    # Run a self named container mounting setting the config file location and mounting out structure.
    docker run \
    --name "${NAME}" \
    --publish 3000:3000 \
    --env "CONFIG_FILE=/config/config.yml" \
    --volume "${SCRIPT_DIR}/config:/config" \
    --volume "${SCRIPT_DIR}/data:/data" \
    --interactive \
    --tty \
    requarks/wiki:2 \
    sh
fi 

# Check to check if a shell is to be created to run as daemon.
if [[ "${1}" == "run" ]]; then
    # Remove the named container.
    docker rm -f "${NAME}"
    # Run a self named container mounting setting the config file location and mounting out structure.
    docker run \
    --name "${NAME}" \
    --publish 3000:3000 \
    --env "CONFIG_FILE=/config/config.yml" \
    --volume "${SCRIPT_DIR}/config:/config" \
    --volume "${SCRIPT_DIR}/data:/data" \
    --detach \
    --restart unless-stopped \
    requarks/wiki:2
fi

# Check to check the container has to stop.
if [[ "${1}" == "stop" ]]; then
    docker stop --name "${NAME}"
fi 

Run the script ./wikijs.sh run and open the browser at http://localhost:3000 and create an admin account. In the administration enable the Git storage with:

Field Value
Authentication Type basic
Repository URI https://git.my-server.com/my-repo/wiki.git
Branch master or main
Username token (Just any name when using a token.)
Password Token created for repository in GitLab.
SYNC DIRECTION Depending on the token being a writable one or not.

To speed up things at the bottom of the Git configuration use Force Sync to perform a Git pull.

Deploy on OpenShift

TODO: Deploy Wikijs on OpenShift using a Git storage solution.