Skip to content

metakgp/metakgp-wiki

Repository files navigation

Contributors Forks Stargazers Issues MIT License Wiki


image

MetaKGP Wiki

Dockerized for fun and profit.
Wiki · Report Bug / Request Feature

Table of Contents

About

This is the dockerized source for the MetaKGP Wiki deployed at https://wiki.metakgp.org. The wiki is a Mediawiki instance with some extensions and services that take backups and update certain pages.

It is hosted on a DigitalOcean droplet with 2GB RAM and a single CPU. See MetaPloy for the deployment architecture.

Architecture

(back to top)

Getting Started

See also: The Runbook for a quick reference to processes needed to manage a production wiki.

Prerequisites

Docker and docker compose are the only required dependencies. You can either install Docker Desktop or the Docker Engine. For minimal installations and production use cases, Docker Engine is recommended.

(back to top)

Deployment

NOTE: See the #Production section for production deployment. DO NOT follow the development instructions in a production environment.

Development

  1. Set up MetaPloy.
  2. Clone this repository.
  3. Copy the contents of the .env.template file into the .env file. Create the file if it doesn't exist.
  4. Set the necessary environment variables.
  5. Run docker compose up to start the wiki. The wiki will be accessible on localhost:8080 or whichever port MetaPloy is set to use.

(back to top)

Production

  1. Set up MetaPloy for production.
  2. Clone this repository at a convenient location such as /deployments.
  3. Set the appropriate production environment variables in the .env file.
  4. Run docker compose -f docker-compose.prod.yml up to start the wiki. This enables the jobs service which includes backups, log rotation, and other periodic jobs.
  5. Optionally set up a Systemd service to start the wiki on startup.

(back to top)

Environment Variables

Environment variables can be set using a .env file(use .env.template file for reference). The following variables are used:

  • DEV: When set to true, Mediawiki PHP stack-trace is shown with error messages. (Default: false)
  • MYSQL_PASSWORD: A secret password for the MySQL database.
  • SERVER_PORT: Port on which the wiki server is exposed to the host. (Default: 8080)
  • SERVER_NAME: Base URL of the wiki (eg: https://wiki.metakgp.org).
  • MAILGUN_EMAIL: The email ID used for sending emails via Mailgun. (eg: admin@wiki.metakgp.org)
  • MAILGUN_PASSWORD: Mailgun SMTP password for sending official mails from the wiki.
  • WG_SECRET_KEY: Secret key used for encryption by mediawiki. Make it a long, random, secret string (Reference).
  • Dropbox related variables (used for storing backups) (See this section for details):
    • DROPBOX_APP_KEY: Dropbox app key (can be found at Dropbox App Console).
    • DROPBOX_APP_SECRET: Dropbox app secret (can be found at Dropbox App Console).
    • DROPBOX_ACCESS_TOKEN: Dropbox API access token (generated using /scripts/get_dropbox_tokens.py)
    • DROPBOX_REFRESH_TOKEN: Dropbox API refresh token (generated using /scripts/get_dropbox_tokens.py) used to refresh the access token.
  • SLACK_CHANGES_WH_URL: URL to the Slack webhook used to send updates about wiki changes. (See this section for more details)
  • SLACK_INCIDENTS_WH_URL: URL to the Slack webhook used to send incidents reports and errors(like Dropbox backup failure). (See this section for more details)
  • BATMAN_BOT_PASSWORD: A generated password of the Batman bot user account on the wiki(Mediawiki documentation to generate bot passwords can be found here).

Setting Up Secondary Services

Dropbox Backups

The jobs service runs periodic local backups (see /jobs/backups) and stores the last 30 days of backups on Dropbox. To set this up, a Dropbox app has to be created, and access tokens need to be generated:

  1. Create an app on the Dropbox App Console.
  2. Copy the app key and app secret and set the corresponding environment variables.
  3. Run the script /scripts/get_dropbox_tokens.py and when prompted, enter the app key and app secret.
  4. Set the generated API access token and refresh tokens in the environment variables.
Slack Notifications

The Slack notifications are sent via webhooks. Two webhooks are used by the wiki: Recent Changes webhook and Incidents webhook (See environment variables). The recent changes webhook logs recent changes to the wiki (page edits, user creation, etc.) and the incidents webhook notifies about server incidents such as backup failures.

  1. Create a Slack app.
  2. Enable "Incoming Webhooks".
  3. Copy the webhook URL and set the appropriate environment variables.
Mailgun

Mailgun is used by the wiki as a mailing service for sending various emails to the users such as account verification and notifications.

  1. Add a new domain in the "Sending" section on Mailgun.
  2. Copy the SMTP password and set the appropriate environment variables.
PyWikiBot (Batman)

PyWikiBot is a Python library that interfaces with the wiki as a bot (called "Batman") and is used to run various jobs such as updating the trending pages list. See /jobs/pywikibot for a list of scripts.

  1. Create a bot account on the Wiki.
  2. Add the bot's password to the BATMAN_BOT_PASSWORD variable in the environment variables.
Google Analytics

The legacy google analytics features used here are now deprecated. This needs to be reworked.

Maintainer(s)

(back to top)

Contact

📫 Metakgp - Metakgp's slack invite Metakgp's email metakgp's Facebook metakgp's LinkedIn metakgp's Twitter metakgp's Instagram

(back to top)

Additional documentation

(back to top)