Wiki.js for your documentation in docker

| |

What is wiki.js and why should you use it?

Wiki.js is an open-source wiki software that allows users to collaboratively create and edit content in a structured and organized way. It provides a modern and intuitive user interface, powerful search capabilities, and a range of features for managing and sharing knowledge.

as to the question of why you should use it?

  1. Easy to use: Wiki.js has a user-friendly interface that makes it easy for anyone to contribute content and collaborate with others.
  2. Customizable: Wiki.js can be customized to fit your specific needs, whether you’re using it for personal or professional use.
  3. Versatile: Wiki.js can be used for a variety of purposes, such as creating a knowledge base, managing documentation, or building an internal wiki for your organization.
  4. Powerful search: Wiki.js has a robust search engine that allows users to quickly find the information they need.
  5. Secure: Wiki.js offers a range of security features to keep your data safe, including two-factor authentication and SSL encryption.

Overall, Wiki.js is a great tool for teams and organizations looking to manage and share knowledge in an efficient and collaborative way.

Install docker

Install wiki.js via docker compose

Create a new directory on your system where you want to store your Wiki.js installation files. Create a new file called docker-compose.yml in the directory you just created, and add the following contents:

version: '3'

services:
  wiki:
    image: requarks/wiki:2
    restart: unless-stopped
    depends_on:
      - wiki-db
    environment:
      - DB_TYPE=postgres
      - DB_HOST=wiki-db
      - DB_PORT=5432
      - DB_USER=wikijs
      - DB_PASS=wikijs
      - DB_NAME=wikijs
    volumes:
      - ./data:/var/wiki/data
      - ./config:/var/wiki/config
    expose:
      - 3000

  wiki-db:
    image: postgres:15-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_PASSWORD=wikijs
      - POSTGRES_USER=wikijs
      - POSTGRES_DB=wikijs
    volumes:
      - ./postgres-data:/var/lib/postgresql/data

  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy-data:/data

the docker-compose file is defining three services: a wiki.js application, a PostgreSQL database, and a Caddy web server. The wiki application is dependent on the PostgreSQL database and is accessible through port 3000 via docker networking. The Caddy web server is used as a reverse proxy to serve incoming requests and is accessible through ports 80 and 443 on the host machine.

Create a new file called Caddyfile in the same directory, and add the following contents:

example.com {
  tls [email protected]
  reverse_proxy wiki:3000
}

Replace example.com with your own domain name and [email protected] with your own email address.

Start the Wiki.js installation by running the following command in your terminal:

docker compose up -d

This will start the Wiki.js, PostgreSQL, and Caddy containers in the background.

Wait a minute or two for the installation process to complete, then open your web browser and navigate to your domain name (e.g. http://example.com). You should see the Wiki.js login page. Create a new account and log in to start using Wiki.js.

That’s it! You now have a fully functional Wiki.js installation running on Docker with Caddy as the web server and PostgreSQL as the database. See this page for more info on the installation process.

Explanation of the docker-compose.yml file

version: '3'

services:

This specifies the Docker Compose version and creates a new section for services.

Service: wiki

  wiki:
    image: requarks/wiki:2
    restart: unless-stopped
    depends_on:
      - wiki-db
    environment:
      - DB_TYPE=postgres
      - DB_HOST=wiki-db
      - DB_PORT=5432
      - DB_USER=wikijs
      - DB_PASS=wikijs
      - DB_NAME=wikijs
    volumes:
      - ./data:/var/wiki/data
      - ./config:/var/wiki/config
    expose:
      - 3000

This service is running a wiki application, based on the “requarks/wiki:2” Docker image. It’s set to automatically restart unless stopped. It depends on another service called “wiki-db”.

The environment section is defining environment variables that are passed to the container. These variables include the database connection details for the wiki application.

The volumes section is used to mount directories on the host machine to directories within the container. This service is mounting the “data” and “config” directories on the host machine to the “/var/wiki/data” and “/var/wiki/config” directories in the container.

The ports section is used to expose ports from the container to the host machine. In this case, port 3000 in the container is only accessible to other docker containers via docker network..

Service: wiki-db

  wiki-db:
    image: postgres:15-alpine
    restart: unless-stopped
    environment:
      - POSTGRES_PASSWORD=wikijs
      - POSTGRES_USER=wikijs
      - POSTGRES_DB=wikijs
    volumes:
      - ./postgres-data:/var/lib/postgresql/data

This service is running a PostgreSQL database, based on the “postgres:15-alpine” Docker image. It’s also set to automatically restart unless stopped.

The environment section is defining environment variables for the PostgreSQL container. These variables include the username, password, and database name for the wiki application to connect to.

The volumes section is used to mount the “postgres-data” directory on the host machine to the “/var/lib/postgresql/data” directory in the container. This allows the database data to persist even if the container is restarted.

Service: caddy

  caddy:
    image: caddy:latest
    restart: unless-stopped
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./Caddyfile:/etc/caddy/Caddyfile
      - ./caddy-data:/data

This service is running a Caddy web server, based on the “caddy:latest” Docker image. It’s also set to automatically restart unless stopped.

The ports section is used to expose ports 80 and 443 in the container to ports 80 and 443 on the host machine.

The volumes section is used to mount the “Caddyfile” on the host machine to the “/etc/caddy/Caddyfile” directory in the container. This file defines how Caddy should serve incoming requests. It’s also mounting the “caddy-data” directory on the host machine to the “/data” directory in the container, which is used to store Caddy’s persistent data.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *