waldronlab / BugSigDB

A microbial signatures database
https://bugsigdb.org
7 stars 6 forks source link

Containerized MediaWiki for bugsigdb.org

Briefly

This repo contains Docker Compose containers to run the MediaWiki software.

Clone the repo. Then create and start the containers:

cd docker-bugsigdb.org
copy a database dump to the __initdb directory
copy images to the `bugsigdb.org/_data/mediawiki/images` directory
copy .env_example to .env and modify as needed (see the Settings section)
docker-compose up

Wait for the completion of the build and initialization process and access it via http://localhost:8081 in a browser.

Architecture of mediawiki containers

Running sudo docker-compose up will start the containers:

Settings

Settings are in the docker-compose.yml file, in the environment sections.

Also, _resources contains the favicon, logo and styles for the chameleon skin. CustomSettings.php contains settings for MediaWiki core and extensions. If customization is required, change the settings there.

db

Was cloned from the official mysql container and has the same environment variables. The reason that it is better than the official is the ability to automatically update the database when upgrading the version of mysql. The only one important environment variable for us is MYSQL_ROOT_PASSWORD; it specifies the password that will be set for the MySQL root superuser account. If changed, make sure that MW_DB_INSTALLDB_PASS in the web section was changed too.

web

environment variables

LocalSettings.php

The LocalSettings.php is divided into three parts:

Data (images, database)

Data, like uploaded images and the database files are stored in the _data directory. Docker containers write files to these directories using internal users; most likely you cannot change/remove these directories until you change the permissions.

Log files

Log files arestored in the _logs directory.

Keeping up to date

Make a full backup of the wiki, including both the database and the files. While the upgrade scripts are well-maintained and robust, things could still go awry.

cd compose-mediawiki-ubuntu
docker-compose exec db /bin/bash -c 'mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD" 2>/dev/null | gzip | base64 -w 0' | base64 -d > backup_$(date +"%Y%m%d_%H%M%S").sql.gz
docker-compose exec web /bin/bash -c 'tar -c $MW_VOLUME $MW_HOME/images 2>/dev/null | base64 -w 0' | base64 -d > backup_$(date +"%Y%m%d_%H%M%S").tar

For picking up the latest changes, stop, rebuild and start containers:

cd compose-mediawiki-ubuntu
git pull
docker-compose build
docker-compose stop
docker-compose up

The upgrade process is fully automated and includes the launch of all necessary maintenance scripts.

Matomo

By default, Matomo runs on port 8182 (to be shadowed with Nginx) and requires initial setup on the first run. Once installed, modify the .env file by adding MATOMO_USER and MATOMO_PASSWORD variables matching the user & password that were used during installation.

Make the import_logs_matomo.sh run on Cron @daily close to midnight to keep the Matomo fed with visit information.

Nginx configuration

   # matomo
   location /matomo/ {
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Uri /matomo;
        proxy_read_timeout 300;
        proxy_pass http://127.0.0.1:8182/;
        proxy_set_header X-Forwarded-For $remote_addr;
   }

Also, once the containers are started, modify the Matomo config as below (the settings are intended to be generated automatically, but it's better to verify):

[General]
trusted_hosts[] = "127.0.0.1:8182"
assume_secure_protocol = 1
force_ssl=0
proxy_uri_header = 1

Purging homepage SMW caches

The image is configured to automatically purge the homepage once per hour. You can configure this using the following environment variables:

MW_CACHE_PURGE_PAUSE=3600
MW_CACHE_PURGE_PAGE=Main_Page

Updating EFO links

The repo contains a Python script that is capable to walk the wiki Glossary terms pages and update outdated EFO links by replacing them with actual ones. Follow the steps below to set it up:

Note: the script may produce extra load to the wiki so it's recommended to schedule it for nigh time, also worth to consider that it takes time to process all the pages so average script cycle is ~4-8 hours. You can change sleep timeouts via -z parameter.

Updating Active user count

To work around T333776 we run maintenance/updateSpecialPages.php once a day. This ensures the count of active users on Special:CreateAccount stays up to date.

bugsigdb-related links