This repo contains Docker Compose containers to run the MediaWiki software.
Clone the repo, create and start containers:
git clone https://github.com/pastakhov/compose-mediawiki-ubuntu.git
cd compose-mediawiki-ubuntu
docker-compose up
Wait for the completion of the build and initialization process and access it via http://localhost:8080
in a browser.
Enjoy with MediaWiki + VisualEditor + Elasticsearch + most popular extensions
Running sudo docker-compose up
in a checkout of this repository will start containers:
db
- A MySQL container, used as the database backend for MediaWiki.elasticsearch
- An Elasticsearch container, used as the full-text search engine for MediaWikimemcached
- A memory object caching system container, used as the cache system for MediaWikiparsoid
- A bidirectional runtime wikitext parser container, used by VisualEditor, Flow and other MediaWiki extensionsproxy
- Varnish reverse proxy server container which reduces the time taken to serve often-requested pagesrestbase
- A REST storage and service dispatcher containerweb
- An Apache/MediaWiki container with PHP 7.0 and MediaWiki 1.29
The elasticsearch, parsoid, restbase, proxy, web containers are based on Ubuntu 16.04
Settings are in the docker-compose.yml
file, the environment sections
Was cloned from official mysql container and has the same environment variables.
The reason why 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 web section was changed too.
PROXY_BACKEND_{name}
defines backend using format 'host:port'. Generally backend name should be the same as container name. Example:PROXY_BACKEND_web=web:80
.
More details on Varnish service page.
The proxy container are listening for connections on private port 80. By default the public port for connections is 8080:
ports:
- "8080:80"
You are welcome to change it to any you would like, just note: make sure that MW_SITE_SERVER
has correct value
PARSOID_DOMAIN_{domain}
defines uri and domain for the Parsoid service. The '{domain}' word should be the same as theMW_REST_DOMAIN
parameter in the web container. You can specify any number of such variables (by the number of domains used for the service).
More details on Parsoid service page.
RB_CONF_DOMAIN_{domain}
defines uri and domain for the RESTBase service. The '{domain}' word should be the same as theMW_REST_DOMAIN
parameter in the web container. You can specify any number of such variables (by the number of domains used for the service). Example:RB_CONF_DOMAIN_web=http://web/w/api.php
.RB_CONF_PARSOID_HOST
defines uri to Parsoid service. Example:http://parsoid:8000
.RB_CONF_API_URI_TEMPLATE
defines uri to the MediaWiki API. Example :http://{domain}/w/api.php
RB_CONF_BASE_URI_TEMPLATE
defines base uri for the links to RESTBase service. Example:http://{domain}/api/rest_v1
.
More details on RESTbase service page.
MW_SITE_SERVER
configures $wgServer, set this to the server host and include the protocol likehttp://my-wiki:8080
MW_SITE_NAME
configures $wgSitenameMW_SITE_LANG
configures $wgLanguageCodeMW_DEFAULT_SKIN
configures $wgDefaultSkinMW_ENABLE_UPLOADS
configures $wgEnableUploadsMW_USE_INSTANT_COMMONS
configures $wgUseInstantCommonsMW_ADMIN_USER
configures default administrator usernameMW_ADMIN_PASS
configures default administrator passwordMW_DB_NAME
specifies database name that will be created automatically upon container startupMW_DB_USER
specifies database user for access to database specified inMW_DB_NAME
MW_DB_PASS
specifies database user passwordMW_DB_INSTALLDB_USER
specifies database superuser name for create database and user specified aboveMW_DB_INSTALLDB_PASS
specifies database superuser password, should be the same asMYSQL_ROOT_PASSWORD
in db section.MW_PROXY_SERVERS
(comma separated values) configures $wgSquidServers. Leave empty if no reverse proxy server used.MW_MAIN_CACHE_TYPE
configures $wgMainCacheType.MW_MEMCACHED_SERVERS
should be provided forCACHE_MEMCACHED
.MW_MEMCACHED_SERVERS
(comma separated values) configures $wgMemCachedServers.MW_SEARCH_TYPE
configures $wgSearchType. Leave empty or setCirrusSearch
for MediaWiki using Elasticsearch.MW_CIRRUS_SEARCH_SERVERS
should be provided forCirrusSearch
.MW_FLOW_NAMESPACES
(comma separated values) specifies namespaces where the Flow extension should be enabled.MW_REST_DOMAIN
specifies the domain parameter used for the REST services such as Parsoid and RESTBase, generally should be the same as the name of the container.MW_REST_RESTBASE_PROXY_PATH
if reverse proxy are used defines path for the $wgVisualEditorFullRestbaseURL and $wgVisualEditorRestbaseURL variables. Example:/api/rest_
.MW_AUTOUPDATE
iftrue
(by default) run needed maintenance scripts automatically before web server start.MW_SHOW_EXCEPTION_DETAILS
iftrue
(by default) configures $wgShowExceptionDetails as true.PHP_LOG_ERRORS
specifieslog_errors
parameter inphp.ini
file.PHP_ERROR_REPORTING
specifieserror_reporting
parameter inphp.ini
file.E_ALL
by default, on production should be changed toE_ALL & ~E_DEPRECATED & ~E_STRICT
.
The LocalSettings.php devided to three parts:
- LocalSettings.php will be created automatically upon container startup, contains settings specific to the MediaWiki installed instance such as database connection, $wgSecretKey and etc. Should not be changed
- DockerSettings.php сontains settings specific to the released containers such as database server name, path to programs, installed extensions, etc. Should be changed if you make changes to the containers only
- CustomSettings.php - contains user defined settings such as user rights, extensions settings and etc. You should make changes there.
CustomSettings.php
placed in folderweb
And will be copied to the container during build
The $wgLogo variable is set to $wgScriptPath/logo.png
value.
The web/logo.png
file will be copied to $wgScriptPath/logo.png path during build.
For change the logo just replace the web/logo.png
file by your logo file and rebuild container
The $wgFavicon variable is set to $wgScriptPath/favicon.ico
value.
The web/favicon.ico
file will be copied to $wgScriptPath/favicon.ico path during build.
For change the favicon just replace the web/favicon.ico
file by your favicon file and rebuild container
How do I rebuild the containers to accept changes to the settings? Just use the command:
docker-compose up --build
It picks up the changes by stopping and recreating the containers.
Why should I rebuild the container every time I change the settings? In this case you are able to check on changes locally before deploy ones to your server. This solution significantly reduces the likelihood that something will be broken on your server when you change the settings.
During the first start, the MediaWiki will be fully initialized according to the settings specified in the docker-compose.yml
file.
This process includes:
- initialize database, create
root
user - initialize elasticsearch storage
- initialize MediaWiki:
- run
install.php
maintenance script that creates MediaWiki database, user and write settings to LocalSettings.php file. - include
web\DockerSettings.php
file to LocalSettings.php that contains minimal needed settings for installed MediaWiki extensions - run
update.php
maintenance script that updated MediaWiki database schema for MediaWiki extensions - generate elasticsearch index and bootstrap the search index
- get the latest data for CLDR and UniversalLanguageSelector extensions
- run
populateContentModel.php
maintenance script that populates the fields nedeed for use the Flow extension on all namespaces
- run
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
picking up the latest changes, stop, rebuld 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 (only when it is really required)
web
/var/www/html/w/images
- files uploaded by users/mediawiki
- contains info about the MediaWiki instance