This Gist is a simple working example of how to use Docker containers to set up a MediaWiki development environment.
The following containers are included:
- MariaDB image (stock) as the app database. The DB name is
dev_wiki
and there is no root password (use in dev only!) - Custom PHP/Apache image based on the mediawiki-docker image; this image sets up some appropriate PHP and Apache config options and installs PECL extensions. Custom
.ini
files can be provided as well, seeuploads.ini
as an example. - ElasticSearch image (stock) to power the search extensions.
Create a top-level src
and web
directory inside of wherever you download these files. The src
folder will be mounted as a volume inside the Mediawiki container, so Download/clone Mediawiki and any necessary extensions there. web
is used to build the MW web application image.
Your file structure should look like this:
.
├── docker-compose.yml
├── src/
└── web/
├── Dockerfile
├── uploads.ini
└── xdebug.ini
Once your files are in place, run docker-compose up
to create and spin up containers.
Navigate to localhost:8080
in your browser and follow the steps in the web installer. Make sure that your DB name and credentials match what has been specified in the docker-compose.yml
file. The DB host can just be listed as database
thanks to the links
property specified in the mediawiki
container.
Save the LocalSettings.php
file in src/
alongside the other MW code, and you should have a working version of Mediawiki now running inside your containers.
Manual steps to configure extensions will still be required. Running maintenance scripts can be done with the docker exec
command. For example, to run the setup script for Cirrus Search, you can do the following:
# in your shell, execute the bash command inside your Mediawiki container:
docker exec -it <container id> /bin/bash
#now you are running bash inside the container
php extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php
An ElasticSearch image is provided ready-to-go in the docker-compose.yml
file. To use the CirrusSearch extension, follow these steps:
- Download/clone and enable the Elastica extension (
wfLoadExtension( "Elastica" );
) inLocalSettings.php
if you have not done so already - Download/clone the CirrusSearch extension
- Add the following to the end of
LocalSettings.php
:
require_once( "$IP/extensions/CirrusSearch/CirrusSearch.php" );
$wgDisableSearchUpdate = true;
$wgCirrusSearchServers = [ "elasticsearch.svc" ];
- Find the ID of the running Mediawiki container using
docker ps
- Shell into this container so you can run the configuration scripts:
docker exec -it <container_id> /bin/bash
- At the new bash prompt, run:
php extensions/CirrusSearch/maintenance/updateSearchIndexConfig.php
- Now remove the
$wgDisableSearchUpdate
line from LocalSettings - Inside the Mediawiki container's bash prompt, run:
php extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipLinks --indexOnSkip
and then:
php extensions/CirrusSearch/maintenance/forceSearchIndex.php --skipParse
. These scripts can take some time to run if there is a lot of content in the wiki. - Finally, add this line to LocalSettings:
$wgSearchType = "CirrusSearch";
- Download/clone Wikibase and its submodules into
extensions/Wikibase
- Install
composer
inside your Mediawiki container. The easiest way to do that is probably to shell in to the Mediawiki container and run these php commands. This will build a copy ofcomposer.phar
that you can run with PHP. Any subsequent steps that saycomposer install
can be replaced withphp composer.phar install
, etc. - Install the composer merge plugin by running:
php composer.phar https://github.com/wikimedia/composer-merge-plugin
in the Mediawiki container bash prompt. - Add a
composer.local.json
file to the top-level Mediawiki folder with these contents:
{
"extra": {
"merge-plugin": {
"include": [
"extensions/Wikibase/composer.json"
]
}
}
}
- Run
composer install
(orphp composer.phar install
) - Add the following to the end of LocalSettings:
$wgEnableWikibaseRepo = true;
$wgEnableWikibaseClient = true;
require_once "$IP/extensions/Wikibase/repo/Wikibase.php";
require_once "$IP/extensions/Wikibase/repo/ExampleSettings.php";
require_once "$IP/extensions/Wikibase/client/WikibaseClient.php";
require_once "$IP/extensions/Wikibase/client/ExampleSettings.php";
- Shell into the Mediawiki container and run the setup scripts:
php maintenance/update.php
in the top level;
php extensions/Wikibase/lib/maintenance/populateSitesTable.php
php extensions/Wikibase/repo/maintenance/rebuildItemsPerSite.php
php extensions/Wikibase/client/maintenance/populateInterwiki.php
Installation of this extension is pretty straitforward; follow these instructions.
To enable the "depicts" feature-flag, add this to LocalSettings:
$wgMediaInfoEnableFilePageDepicts = true;
This gist will be revised as more improvements are added to this process.