Skip to content

Instantly share code, notes, and snippets.

@siddharthvp
Created October 15, 2021 18:02
Show Gist options
  • Save siddharthvp/bd6ad5575b3fc75943e08170bd5207fa to your computer and use it in GitHub Desktop.
Save siddharthvp/bd6ad5575b3fc75943e08170bd5207fa to your computer and use it in GitHub Desktop.
MW dev env on macOS
version: '3' # MediaWiki with MariaDB, Access via "http://localhost:8080"
services:
mediawiki:
build: .
restart: always
ports:
- 8080:80
links:
- database
volumes:
- "./mediawiki:/var/www/html"
- "./setup.sh:/var/www/setup.sh"
- "./LocalSettings.php:/var/www/LocalSettings.php"
- "/var/www/html/images"
database:
image: mariadb # https://registry.hub.docker.com/_/mariadb
restart: always
ports:
- 3312:3306
environment:
# @see https://phabricator.wikimedia.org/source/mediawiki/browse/master/includes/DefaultSettings.php
MYSQL_DATABASE: my_wiki
MYSQL_USER: wikiuser
MYSQL_PASSWORD: wikipassword
MYSQL_RANDOM_ROOT_PASSWORD: 'yes'
FROM mediawiki
WORKDIR /var/www
RUN rm -rf html
WORKDIR /var/www/html
<?php
# This file was automatically generated by the MediaWiki 1.35.1
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See includes/DefaultSettings.php for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;
$wgSitename = "Wikipedia";
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "";
## The protocol and server name to use in fully-qualified URLs
$wgServer = "http://localhost:8080";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
## The URL paths to the logo. Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogos = [ '1x' => "$wgResourceBasePath/resources/assets/wiki.png" ];
## UPO means: this is also a user preference option
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgEmergencyContact = "apache@🌻.invalid";
$wgPasswordSender = "apache@🌻.invalid";
$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "database";
$wgDBname = "my_wiki";
$wgDBuser = "wikiuser";
$wgDBpassword = "wikipassword";
# MySQL specific settings
$wgDBprefix = "";
# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
# Shared database table
# This has no effect unless $wgSharedDB is also set.
$wgSharedTables[] = "actor";
## Shared memory settings
$wgMainCacheType = CACHE_ACCEL;
$wgMemCachedServers = [];
## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = true;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = true;
# Periodically send a pingback to https://www.mediawiki.org/ with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = false;
## If you use ImageMagick (or any other shell command) on a
## Linux server, this will need to be set to the name of an
## available UTF-8 locale. This should ideally be set to an English
## language locale so that the behaviour of C library functions will
## be consistent with typical installations. Use $wgLanguageCode to
## localise the wiki.
$wgShellLocale = "C.UTF-8";
## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publicly accessible from the web.
#$wgCacheDirectory = "$IP/cache";
# Site language code, should be one of the list in ./languages/data/Names.php
$wgLanguageCode = "en";
$wgSecretKey = "602762d962b045ea6bc6160199ff22d64d9101d858ccae34534017aeccd35a70";
# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";
# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "f2d4c71933b049f3";
## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";
# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";
## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";
# End of automatically generated settings.
# Add more configuration options below.
# Show errors in case things go wrong
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;
# Allow uploads from URL (mw:Manual:Configuring_file_uploads#Uploading_directly_from_a_URL_("Sideloading"))
$wgAllowCopyUploads = true;
$wgGroupPermissions['user']['upload_by_url'] = true;
# Enable Special:JavaScriptTest
$wgEnableJavaScriptTest = true;
# Enabled skins.
# The following skins were automatically enabled:
//wfLoadSkin( 'MonoBook' );
//wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );
# Enabled extensions. Most of the extensions are enabled by adding
# wfLoadExtension( 'ExtensionName' );
# to LocalSettings.php. Check specific extension documentation for more details.
# The following extensions were automatically enabled:
//wfLoadExtension( 'SpamBlacklist' );
wfLoadExtension( 'TitleBlacklist' );
wfLoadExtension( 'WikiEditor' );
wfLoadExtension( 'Gadgets' );
wfLoadExtension( 'PageTriage' );
$wgExtraNamespaces[118] = 'Draft';
$wgPageTriageDraftNamespaceId = 118;
wfLoadExtension( 'CodeEditor' );
$wgDefaultUserOptions['usebetatoolbar'] = 1; # user option provided by WikiEditor extension
wfLoadExtension( 'Scribunto' );
$wgScribuntoDefaultEngine = 'luastandalone';
wfLoadExtension( 'CodeMirror' );
$wgDefaultUserOptions['usecodemirror'] = 1;
$wgCodeMirrorEnableBracketMatching = true;
$wgCodeMirrorLineNumberingNamespaces = null;
wfLoadExtension( 'TemplateSandbox' );
wfLoadExtension( 'OAuth' );
$wgGroupPermissions['sysop']['mwoauthproposeconsumer'] = true;
$wgGroupPermissions['sysop']['mwoauthupdateownconsumer'] = true;
$wgGroupPermissions['sysop']['mwoauthmanageconsumer'] = true;
$wgGroupPermissions['sysop']['mwoauthmanagemygrants'] = true;
$wgGroupPermissions['sysop']['mwoauthviewprivate'] = true;
$PARSOID_INSTALL_DIR = 'extensions/parsoid';
AutoLoader::$psr4Namespaces += [
// Keep this in sync with the "autoload" clause in
// $PARSOID_INSTALL_DIR/composer.json
'Wikimedia\\Parsoid\\' => "$PARSOID_INSTALL_DIR/src",
];
wfLoadExtension( 'Parsoid', "$PARSOID_INSTALL_DIR/extension.json" );
# Manually configure Parsoid
$wgVisualEditorParsoidAutoConfig = false;
$wgParsoidSettings = [
'useSelser' => true,
'rtTestMode' => false,
'linting' => true,
];
$wgVirtualRestConfig['modules']['parsoid'] = array(
'url' => 'http://host.docker.internal:8080' . $wgScriptPath . '/rest.php',
);
wfLoadExtension( 'VisualEditor' );
wfLoadExtension( 'Echo' );
wfLoadExtension( 'Linter' );
$wgLocaltimezone = 'UTC';
wfLoadExtension( 'DiscussionTools' );
rm -f "$(dirname $0)"/mediawiki/LocalSettings.php
docker-compose up --detach --build
sleep 15 # need to give some time for the database to start working properly
docker exec mw-dev_mediawiki_1 bash /var/www/setup.sh
{
"scripts": {
"start": "docker-compose start",
"stop": "docker-compose stop",
"create": "bash main.sh",
"destroy": "docker-compose down",
"recreate": "npm run destroy && npm run create",
"update": "docker exec mw-dev_mediawiki_1 php maintenance/update.php --quick",
"setup": "docker exec mw-dev_mediawiki_1 bash /var/www/setup.sh"
}
}
php maintenance/install.php Wikipedia Wikiuser --pass=wikipassword \
--server=http://localhost:8080 \
--dbserver=database \
--dbtype=mysql \
--dbname=my_wiki \
--dbprefix="" \
--installdbuser=wikiuser \
--installdbpass=wikipassword \
--dbuser=wikiuser \
--dbpass=wikipassword \
--scriptpath="" \
--extensions=TitleBlacklist,WikiEditor
# Overwrite installer-generated LocalSettings.php with our file from /var/www
cp ../LocalSettings.php ./LocalSettings.php
php maintenance/update.php --quick
# Include every grant in bot password, too bad there isn't an --all-grants option
php maintenance/createBotPassword.php --appid=bp --grants=basic,blockusers,createaccount,createeditmovepage,delete,editinterface,editmycssjs,editmyoptions,editmywatchlist,editpage,editprotected,editsiteconfig,highvolume,mergehistory,oversight,patrol,privateinfo,protect,rollback,sendemail,uploadeditmovefile,uploadfile,viewdeleted,viewmywatchlist,viewrestrictedlogs Wikiuser 12345678901234567890123456789012
# Create a spare account too
php maintenance/createAndPromote.php Wikiuser2 wikipassword
# Add bot password
php maintenance/createBotPassword.php --appid=bp --grants=basic,blockusers,createaccount,createeditmovepage,delete,editinterface,editmycssjs,editmyoptions,editmywatchlist,editpage,editprotected,editsiteconfig,highvolume,mergehistory,oversight,patrol,privateinfo,protect,rollback,sendemail,uploadeditmovefile,uploadfile,viewdeleted,viewmywatchlist,viewrestrictedlogs Wikiuser2 12345678901234567890123456789012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment