MediaWiki-Docker/Extension/ContentTranslation
Installing the dependencies and setting up the environment should take about 15 minutes
Note that this instructions are slightly different from general mediawiki docker installation instructions since the default sqlite
database is not enough for ContentTranslation.
- Clone all the required repositories.
git clone --depth=1 https://gerrit.wikimedia.org/r/mediawiki/core.git mediawiki git clone "https://gerrit.wikimedia.org/r/mediawiki/services/cxserver" cxserver cd mediawiki git clone "https://gerrit.wikimedia.org/r/mediawiki/skins/Vector" skins/Vector git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/Cite" extensions/Cite git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/ContentTranslation" extensions/ContentTranslation git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/UniversalLanguageSelector" extensions/UniversalLanguageSelector git clone --recursive "https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor" extensions/VisualEditor git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/BetaFeatures" extensions/BetaFeatures git clone "https://gerrit.wikimedia.org/r/mediawiki/extensions/GlobalPreferences" extensions/GlobalPreferences
ConfigurationsEdit
Prepare cxserverEdit
In the cxserver
directory a default configuration file is given as config.dev.yaml
.
Copy it to config.yaml
to customize. For detailed setup, refer Content translation/cxserver/Setup
In the mediawiki
directory, using a text editor, create a .env
file in the root of the MediaWiki core repository, and copy these contents into that file:
MW_DOCKER_PORT=8080
MW_SCRIPT_PATH=/w
MW_SERVER=http://localhost:8080
MEDIAWIKI_USER=Admin
MEDIAWIKI_PASSWORD=dockerpass
XDEBUG_CONFIG=''
CXSERVER_PORT=8090
Create a docker-compose.override.yml
containing the following:
version: '3.7'
services:
mediawiki:
# On Linux, these lines ensure file ownership is set to your host user/group
user: "${MW_DOCKER_UID}:${MW_DOCKER_GID}"
mariadb-main:
image: 'bitnami/mariadb:latest'
volumes:
- mariadbdata:/bitnami/mariadb
environment:
- MARIADB_REPLICATION_MODE=master
- MARIADB_REPLICATION_USER=repl_user
- MARIADB_REPLICATION_PASSWORD=repl_password
- MARIADB_ROOT_PASSWORD=main_root_password
- MARIADB_USER=my_user
- MARIADB_PASSWORD=my_password
- MARIADB_DATABASE=my_database
mariadb-replica:
image: 'bitnami/mariadb:latest'
depends_on:
- mariadb-main
environment:
- MARIADB_REPLICATION_MODE=slave
- MARIADB_REPLICATION_USER=repl_user
- MARIADB_REPLICATION_PASSWORD=repl_password
- MARIADB_MASTER_HOST=mariadb-main
- MARIADB_MASTER_PORT_NUMBER=3306
- MARIADB_MASTER_ROOT_PASSWORD=main_root_password
cxserver:
build:
context: ../cxserver
volumes:
# map local to remote folder, exclude node_modules
- ../cxserver:/opt/cxserver
- /opt/cxserver/node_modules
ports:
- "${CXSERVER_PORT:-8090}:8080"
command: npm start
volumes:
mariadbdata:
driver: local
Run the following command to add your user ID and group ID to your .env
file:
echo "MW_DOCKER_UID=$(id -u)" >> .env
echo "MW_DOCKER_GID=$(id -g)" >> .env
InstallationEdit
Start the environment:
docker-compose up -d
Install Composer dependencies:
docker-compose exec mediawiki composer update
Install mediawiki and database
docker-compose exec mediawiki php maintenance/install.php --dbuser root --dbserver mariadb-main --dbname=my_database --dbpass=main_root_password --scriptpath=/w --server="http://localhost:8080/" --lang en --pass dockerpass mediawiki admin
At this point, a file named LocalSettings.php
will be created in the mediawiki
folder. You will be able to access your wiki at http://localhost:8080. You should also see the cxserver API endpoint running at http://localhost:8090
Prepare ExtensionsEdit
To enable the cloned extensions, Add the following code at the bottom of your LocalSettings.php
:
wfLoadSkin( 'Vector' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'ContentTranslation' );
# For CX3 Vue based application
$wgContentTranslationVueDashboard=true;
$wgContentTranslationSiteTemplates = [
"view" => "//$1.wikipedia.org/wiki/$2",
"action"=> "//$1.wikipedia.org/w/index.php?title=$2",
"api"=> "https://$1.wikipedia.org/w/api.php",
// Use the CXSERVER_PORT here
"cx"=> "http://localhost:8090/v1",
"restbase"=> "https://$1.wikipedia.org/api/rest_v1"
];
wfLoadExtension( 'UniversalLanguageSelector' );
wfLoadExtension( 'BetaFeatures' );
wfLoadExtension( 'Cite' );
wfLoadExtension( 'VisualEditor' );
$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgEnableRestAPI = true;
wfLoadExtension( 'Parsoid', 'vendor/wikimedia/parsoid/extension.json' );
$wgVirtualRestConfig['modules']['parsoid'] = [
'url' => $wgServer . $wgScriptPath . '/rest.php',
];
wfLoadExtension( 'GlobalPreferences' );
$GLOBALS['wgGlobalPreferencesDB'] = 'my_database';
These extensions need more database tables. To add them to our database, run:
docker-compose exec mediawiki php maintenance/update.php
At this point, you should be able to see Content Translation enabled in your wiki. Please try navigating to http://localhost:8080/wiki/Special:ContentTranslation
UsageEdit
Running commandsEdit
You can use docker-compose exec mediawiki bash
to open a bash shell in the MediaWiki container, or you can run commands in the container from your host, for example: docker-compose exec mediawiki php maintenance/update.php
Running testsEdit
PHPUnitEdit
Run all tests:
docker-compose exec mediawiki php tests/phpunit/phpunit.php
Run a single test:
docker-compose exec mediawiki php tests/phpunit/phpunit.php /path/to/test
LimitationsEdit
The nodejs is missing in the container. So working with linting tools, developing with vuejs for CX3 may be limiting. Such customizations are possible with a Dockerfile overriding and building it on top of base image.