Table of Contents
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.
See also: The Runbook for a quick reference to processes needed to manage a production wiki.
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.
NOTE: See the #Production section for production deployment. DO NOT follow the development instructions in a production environment.
- Set up MetaPloy.
- Clone this repository.
- Copy the contents of the
.env.template
file into the.env
file. Create the file if it doesn't exist. - Set the necessary environment variables.
- Run
docker compose up
to start the wiki. The wiki will be accessible onlocalhost:8080
or whichever port MetaPloy is set to use.
- Set up MetaPloy for production.
- Clone this repository at a convenient location such as
/deployments
. - Set the appropriate production environment variables in the
.env
file. - Run
docker compose -f docker-compose.prod.yml up
to start the wiki. This enables thejobs
service which includes backups, log rotation, and other periodic jobs. - Optionally set up a Systemd service to start the wiki on startup.
Environment variables can be set using a .env
file(use .env.template
file for reference). The following variables are used:
DEV
: When set totrue
, 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).
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:
- Create an app on the Dropbox App Console.
- Copy the app key and app secret and set the corresponding environment variables.
- Run the script
/scripts/get_dropbox_tokens.py
and when prompted, enter the app key and app secret. - Set the generated API access token and refresh tokens in the environment variables.
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.
- Create a Slack app.
- Enable "Incoming Webhooks".
- Copy the webhook URL and set the appropriate environment variables.
Mailgun is used by the wiki as a mailing service for sending various emails to the users such as account verification and notifications.
- Add a new domain in the "Sending" section on Mailgun.
- Copy the SMTP password and set the appropriate environment variables.
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.
- Create a bot account on the Wiki.
- Add the bot's password to the
BATMAN_BOT_PASSWORD
variable in the environment variables.
The legacy google analytics features used here are now deprecated. This needs to be reworked.