Jump to content

Moderator Tools/Development/MediaWiki-Docker Setup

From mediawiki.org

Summary

[edit]

This is a simple variation of DEVELOPERS.md#quickstart that the Moderator Tools team found helpful to quickly get MediaWiki-Docker up and running with enough software and configuration to do our work. The existing guides provide useful information, but we repeatedly found that new developers didn't know which parts of the guide they needed to follow to get a useful local environment.

Specifically, Moderator Tools found it very helpful to always have:

  • mobileFrontend skin switching with vector and minerva
  • Event Logging

Install Requirements

[edit]

DEVELOPERS.md#1_requirements

Download Core

[edit]
git clone --depth=1 https://gerrit.wikimedia.org/r/mediawiki/core.git mediawiki

Download Extensions

[edit]
cd mediawiki/extensions
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventBus
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventLogging
git clone https://gerrit.wikimedia.org/r/mediawiki/extensions/EventStreamConfig
git clone ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikimediaEvents
git clone ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend

Download Skins

[edit]
cd ../skins
git clone ssh://gerrit.wikimedia.org:29418/mediawiki/skins/MinervaNeue
git clone ssh://gerrit.wikimedia.org:29418/mediawiki/skins/Vector

Run the following command from the mediawiki directory to bookmark core, extensions, and skins:

gitup -a . extensions skins

Prepare .env file

[edit]

See DEVELOPERS.md#2_prepare-file


Create or append docker-compose.override.yml

[edit]

Event Logging needs an additional service to run See https://www.mediawiki.org/wiki/MediaWiki-Docker/Configuration_recipes/EventLogging For more info if needed

---
# If you already have docker-compose.override.yml, just add the eventlogging service if it's missing
services:
  eventlogging:
    build: "./extensions/EventLogging/devserver"
    ports:
      - "8192:8192"

Create the environment

[edit]

See DEVELOPERS.md#3_create-the-environment


Modify the environment

[edit]

This is a step that varies from DEVELOPERS.md#modify-the-development-environment

Append LocalSettings.php with the configuration below:

wfLoadExtensions( [
  'EventBus',
  'EventStreamConfig',
  'EventLogging',
  'WikimediaEvents',
  'MobileFrontend',
] );

// Enable Minerva skin
wfLoadSkin( 'MinervaNeue' );

// MobileFrontend Configuration
$wgDefaultMobileSkin = 'minerva';

// WikimediaEvents Configuration
$wgWMEMobileWebUIActionsTracking = 1;
$wgWMEReadingDepthSamplingRate = 1;

// EventBus Configuration
// ======================

// Send all events produced on the server to the event intake service, including
// events produced by \EventLogging::submit().
$wgEventServices = [
  '*' => [ 'url' => 'http://eventlogging:8192/v1/events' ],
];
$wgEventServiceDefault = '*';
$wgEnableEventBus = 'TYPE_EVENT';

// EventStreamConfig Configuration
// ===============================

// When $wgEventLoggingStreamNames is false (not falsy), the EventLogging
// JavaScript client will treat all streams as if they are configured and
// registered.
$wgEventLoggingStreamNames = false;

// EventLogging Configuration
// ==========================

$wgEventLoggingServiceUri = "http://localhost:8192/v1/events";

// The EventLogging JavaScript client maintains an queue of events to send to
// the event intake service (see $wgEventLoggingServiceUri above). The queue is
// flushed every $wgEventLoggingQueueLingerSeconds seconds.
//
// 1 second is just long enough for you to begin to doubt that your code is
// working...
$wgEventLoggingQueueLingerSeconds = 1;


Tips for Updating

[edit]

gitup is a useful tool for keeping multiple git repositories up to date. You may install as directed here: https://pypi.org/project/gitup/

Now, you can update all of the repositories by running

gitup

from any working directory. Remember to update composer dependencies and the database by running

docker-compose exec mediawiki bash -c "composer install && php maintenance/update.php --quick"