diff --git a/Dockerfile b/Dockerfile index 94be2c8..53a2789 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,15 +1,13 @@ -FROM mediawiki:1.35 - -# Plugins are not compatible with composer 2 yet -ARG COMPOSER_VERSION=1.10.22 +FROM mediawiki:1.37.1 ENV \ WG_SITENAME="Test Wiki" \ WG_SCRIPT_PATH="" \ WG_SERVER="https://wiki.example.com" \ SEMANTIC_URL="wiki.example.com" \ - WG_ENABLE_UPLOADS="false" \ - WG_ENABLE_EMAIL="false" \ + WG_ENABLE_UPLOADS="0" \ + WG_USE_INSTANT_COMMONS="0" \ + WG_ENABLE_EMAIL="0" \ WG_UPLOAD_PATH="/uploads" \ WG_META_NAMESPACE="Meta" \ WG_LANGUAGE_CODE="en" \ @@ -27,11 +25,21 @@ ENV \ WG_SECRET_KEY="0000000000000000000000000000000000000000000000000000000000000000" \ WG_EMERGENCY_CONTACT="admin@example.com" \ WG_PASSWORD_SENDER="wiki@example.com" \ - ALLOW_PUBLIC_REGISTRATION="false" \ - ALLOW_PUBLIC_EDIT="false" \ - ALLOW_PUBLIC_READ="true" \ - DISABLE_ICONS="false" \ - DEBUG="false" + ALLOW_PUBLIC_REGISTRATION="0" \ + ALLOW_AUTO_REGISTRATION="1" \ + ALLOW_PUBLIC_EDIT="0" \ + ALLOW_PUBLIC_READ="1" \ + USE_REMOTE_AUTH="0" \ + DISABLE_ICONS="0" \ + S3_ENDPOINT="https://s3.us-east-1.amazonaws.com" \ + S3_INSECURE="0" \ + S3_KEY="" \ + S3_SECRET="" \ + S3_REGION="us-east-1" \ + S3_BUCKET_DOMAIN_NAME="\$1.s3.amazonaws.com" \ + S3_BUCKET_NAME="" \ + S3_SUBDIRECTORY="" \ + DEBUG="0" # System dependencies for extensions RUN set -eu; \ @@ -59,24 +67,37 @@ RUN set -eu; \ # Non-composer based extensions # JsonConfig required by Graph. RUN set -eu; \ - cd /var/www/html/extensions; \ - curl https://extdist.wmflabs.org/dist/extensions/JsonConfig-REL1_35-a33f0ce.tar.gz |tar -xz; \ - curl https://extdist.wmflabs.org/dist/extensions/Graph-REL1_35-cfbc8e6.tar.gz |tar -xz; \ - curl https://extdist.wmflabs.org/dist/extensions/SubPageList3-REL1_35-df04b70.tar.gz |tar -xz; \ - curl https://extdist.wmflabs.org/dist/extensions/MsUpload-REL1_35-2c46852.tar.gz |tar -xz; \ - curl https://extdist.wmflabs.org/dist/extensions/TemplateStyles-REL1_35-dae9271.tar.gz |tar -xz + cd /var/www/html/extensions \ + && git clone https://github.com/edwardspec/mediawiki-aws-s3.git AWS && bash -c "(cd AWS && git checkout be6887a53a0e0fbe3e129cab8d0bae1bd7820cb2)" \ + && curl https://extdist.wmflabs.org/dist/extensions/JsonConfig-REL1_37-becf774.tar.gz |tar -xz \ + && curl https://extdist.wmflabs.org/dist/extensions/Graph-REL1_37-5a47efe.tar.gz |tar -xz \ + && curl https://extdist.wmflabs.org/dist/extensions/SubPageList3-REL1_37-fae904e.tar.gz |tar -xz \ + && curl https://extdist.wmflabs.org/dist/extensions/MsUpload-REL1_37-1698666.tar.gz |tar -xz \ + && curl https://extdist.wmflabs.org/dist/extensions/TemplateStyles-REL1_37-eec8c6c.tar.gz |tar -xz \ + && curl https://extdist.wmflabs.org/dist/extensions/Auth_remoteuser-REL1_37-267291a.tar.gz |tar -xz # Install composer packages +COPY --from=composer:2.1 /usr/bin/composer /usr/bin/composer RUN set -eu; \ - curl -o /tmp/composer-setup.php https://getcomposer.org/installer; \ - curl -o /tmp/composer-setup.sig https://composer.github.io/installer.sig; \ - php -r "if (hash('SHA384', file_get_contents('/tmp/composer-setup.php')) !== trim(file_get_contents('/tmp/composer-setup.sig'))) { unlink('/tmp/composer-setup.php'); echo 'Invalid installer' . PHP_EOL; exit(1); }"; \ - php /tmp/composer-setup.php --no-ansi --install-dir=/usr/local/bin --filename=composer --version=${COMPOSER_VERSION}; \ - rm -rf /tmp/composer-setup.php; \ ln -s /var/www/conf/LocalSettings.local.php /var/www/html/LocalSettings.local.php; \ ln -s /var/www/conf/LocalSettings.php /var/www/html/LocalSettings.php -COPY composer.local.json /var/www/html -RUN composer update --no-dev + +# Make AWS (S3) dependencies installable +RUN echo '{"extra": {"merge-plugin": {"include": ["extensions/AWS/composer.json"]}}}' > composer.local.json + +# Install SMB via composer +# css-sanitizer is a dependency of TemplateStyles +RUN composer require --with-all-dependencies --no-update \ + wikimedia/css-sanitizer:"3.0.2" \ + mediawiki/semantic-media-wiki:"~4.0.0" \ + mediawiki/semantic-result-formats:"~4.0.1" \ + mediawiki/maps:"~9.0.7" \ + mediawiki/mermaid:"~3.0.1" \ + mediawiki/semantic-extra-special-properties:"~3.0.1" \ + mediawiki/semantic-compound-queries:"~2.2.0" \ + mediawiki/page-forms:"~5.3.4" \ + mediawiki/semantic-scribunto:"~2.2.0" +RUN composer update # Place config files COPY conf/* /var/www/conf/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3e62160 --- /dev/null +++ b/Makefile @@ -0,0 +1,8 @@ +build: + docker build -t tmp . + +run: + docker-compose up + +install: + docker-compose exec wiki bash db-setup.sh \ No newline at end of file diff --git a/composer.local.json b/composer.local.json deleted file mode 100644 index 1cf7f3f..0000000 --- a/composer.local.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "require": { - "mediawiki/semantic-bundle": "~5.0", - "mediawiki/semantic-scribunto": "~2.1", - - "wikimedia/css-sanitizer": "3.0.2" - } -} \ No newline at end of file diff --git a/conf/LocalSettings.php b/conf/LocalSettings.php index f6a0646..f3fa93b 100644 --- a/conf/LocalSettings.php +++ b/conf/LocalSettings.php @@ -14,6 +14,8 @@ $wgSitename = getenv("WG_SITENAME"); $wgMetaNamespace = "Meta"; $wgScriptPath = getenv("WG_SCRIPT_PATH"); +## The URL path to static resources (images, scripts, etc.) +$wgResourceBasePath = $wgScriptPath; $wgServer = getenv("WG_SERVER"); @@ -23,19 +25,17 @@ $wgUploadPath = getenv("WG_UPLOAD_PATH"); $wgArticlePath = "/wiki/$1"; $wgUploadDirectory = "/var/www/localstore/images"; -## The URL path to static resources (images, scripts, etc.) -$wgResourceBasePath = $wgScriptPath; ## UPO means: this is also a user preference option -$wgEnableEmail = getenv("WG_ENABLE_EMAIL"); +$wgEnableEmail = !!getenv("WG_ENABLE_EMAIL"); $wgEnableUserEmail = true; # UPO $wgEmergencyContact = getenv("WG_EMERGENCY_CONTACT"); $wgPasswordSender = getenv("WG_PASSWORD_SENDER"); -$wgEnotifUserTalk = false; # UPO -$wgEnotifWatchlist = false; # UPO +$wgEnotifUserTalk = !!getenv("WG_ENABLE_EMAIL"); # UPO +$wgEnotifWatchlist = !!getenv("WG_ENABLE_EMAIL"); # UPO $wgEmailAuthentication = true; ## Database settings @@ -62,11 +62,11 @@ if(php_sapi_name() == "cli") { } $wgMemCachedServers = []; -$wgEnableUploads = getenv("WG_ENABLE_UPLOADS"); +$wgEnableUploads = !!getenv("WG_ENABLE_UPLOADS"); $wgUseImageMagick = true; $wgImageMagickConvertCommand = "/usr/bin/convert"; -$wgUseInstantCommons = false; +$wgUseInstantCommons = !!getenv("WG_USE_INSTANT_COMMONS"); # telemetry $wgPingback = false; @@ -76,6 +76,12 @@ $wgPingback = false; ## available UTF-8 locale $wgShellLocale = "C.UTF-8"; +# Site language code, should be one of the list in ./languages/data/Names.php +$wgLanguageCode = "en"; + +# Time zone +$wgLocaltimezone = "UTC"; + ## Set $wgCacheDirectory to a writable directory on the web server ## to make your wiki go slightly faster. The directory should not ## be publically accessible from the web. @@ -91,7 +97,7 @@ $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 = "15ae97f94f551121"; +$wgUpgradeKey = "f6490612e52548f9"; ## For attaching licensing metadata to pages, and displaying an ## appropriate copyright notice / icon. GNU Free Documentation @@ -105,17 +111,38 @@ $wgRightsIcon = ""; $wgDiff3 = "/usr/bin/diff3"; $wgGroupPermissions['*']['createaccount'] = !!getenv("ALLOW_PUBLIC_REGISTRATION"); +$wgGroupPermissions['*']['autocreateaccount'] = !!getenv("ALLOW_AUTO_REGISTRATION"); $wgGroupPermissions['*']['edit'] = !!getenv("ALLOW_PUBLIC_EDIT"); $wgGroupPermissions['*']['read'] = !!getenv("ALLOW_PUBLIC_READ"); +if (!!getenv("USE_REMOTE_AUTH")) { + # Use remote authentication. + # When using the VisualEditor extension create a specific parsoid user for + # locked down wikis (no anonymous read permission), when Parsoid is running + # on localhost. + $wgAuthRemoteuserUserName = [ + $_SERVER[ 'REMOTE_USER' ], + $_SERVER[ 'REDIRECT_REMOTE_USER' ], + $_SERVER[ 'REMOTE_ADDR' ] == '127.0.0.1' ? 'parsoid' : '' + ]; + $wgAuthRemoteuserUserPrefs = [ + 'realname' => $_SERVER[ 'AUTHENTICATE_DISPLAYNAME' ], + 'language' => 'en', + 'disablemail' => 0 + ]; + // Users email address should not be changed inside MediaWiki. + $wgAuthRemoteuserUserPrefsForced = [ + 'email' => $_SERVER[ 'AUTHENTICATE_MAIL' ] + ]; +} + ## Default skin: you can change the default skin. Use the internal symbolic ## names, ie 'vector', 'monobook': $wgDefaultSkin = "vector"; # Enabled skins. -# The following skins were automatically enabled: -wfLoadSkin( 'MonoBook' ); -wfLoadSkin( 'Timeless' ); +#wfLoadSkin( 'MonoBook' ); +#wfLoadSkin( 'Timeless' ); wfLoadSkin( 'Vector' ); # Enabled extensions. Most of the extensions are enabled by adding @@ -124,35 +151,88 @@ wfLoadSkin( 'Vector' ); # The following extensions were automatically enabled: wfLoadExtension( 'CategoryTree' ); wfLoadExtension( 'Cite' ); +wfLoadExtension( 'CiteThisPage' ); wfLoadExtension( 'CodeEditor' ); +wfLoadExtension( 'ConfirmEdit' ); +wfLoadExtension( 'Gadgets' ); +wfLoadExtension( 'Graph' ); wfLoadExtension( 'ImageMap' ); wfLoadExtension( 'InputBox' ); #wfLoadExtension( 'OATHAuth' ); +wfLoadExtension( 'Interwiki' ); +wfLoadExtension( 'JsonConfig' ); # Configuration via Special Wiki Pages containing JSON +wfLoadExtension( 'LocalisationUpdate' ); +wfLoadExtension( 'Maps' ); # OSM Maps +wfLoadExtension( 'Mermaid' ); # Diagrams and flowcharts +wfLoadExtension( 'MsUpload' ); # Better upload formulars +wfLoadExtension( 'MultimediaViewer' ); +wfLoadExtension( 'Nuke' ); # Mass delete pages +wfLoadExtension( 'PageImages' ); wfLoadExtension( 'ParserFunctions' ); wfLoadExtension( 'PdfHandler' ); +wfLoadExtension( 'Poem' ); # Formatting of poems +wfLoadExtension( 'Renameuser' ); +wfLoadExtension( 'ReplaceText' ); +wfLoadExtension( 'Scribunto' ); # Lua Scripting +wfLoadExtension( 'SecureLinkFixer' ); +wfLoadExtension( 'SpamBlacklist' ); +wfLoadExtension( 'SubPageList3' ); wfLoadExtension( 'SyntaxHighlight_GeSHi' ); +wfLoadExtension( 'TemplateData' ); # Template schema information +wfLoadExtension( 'TemplateStyles' ); # Embedd Styles from Wiki Pages containing CSS +wfLoadExtension( 'TextExtracts' ); +wfLoadExtension( 'TitleBlacklist' ); +require_once "$IP/extensions/Validator/Validator.php"; +wfLoadExtension( 'VisualEditor' ); # WYSIWYG editor wfLoadExtension( 'WikiEditor' ); -# End of automatically generated settings. -# Add more configuration options below. - -# Load our extensions -wfLoadExtension( 'JsonConfig' ); # Configuration via Special Wiki Pages containing JSON -wfLoadExtension( 'TemplateStyles' ); # Embedd Styles from Wiki Pages containing CSS -wfLoadExtension( 'Scribunto' ); # Lua scripting -wfLoadExtension( 'SemanticScribunto' ); # Lua scripting using semantic information -#wfLoadExtension( 'Mermaid' ); # Diagrams and flowcharts, AUTOMATICALLY ENABLED as part of semanticBundle! -wfLoadExtension( 'VisualEditor' ); # WYSIWYG editor, already installed in 1.35+ -wfLoadExtension( 'TemplateData' ); # Template schema information, already installed in 1.35+ - # scribunto configuration $wgScribuntoDefaultEngine = 'luastandalone'; -require_once '/var/www/html/extensions/SemanticBundle/SemanticBundle.php'; +# Load SMW Extensions +wfLoadExtension( 'PageForms' ); # SMW Dependency +wfLoadExtension( 'SemanticCompoundQueries' ); # Allow combined queries in SMW +wfLoadExtension( 'SemanticExtraSpecialProperties' ); +wfLoadExtension( 'SemanticResultFormats' ); +wfLoadExtension( 'SemanticScribunto' ); # Lua scripting using semantic information # Turn on SemanticMediaWiki +$smwgUpgradeKey = 'smw:2020-04-18'; +wfLoadExtension( 'SemanticMediaWiki' ); enableSemantics( getenv("SEMANTIC_URL") ); +# Configure S3 Storage +if (getenv("S3_SECRET")) { + wfLoadExtension( 'AWS' ); + $wgAWSCredentials = [ + 'key' => getenv("S3_KEY"), + 'secret' => getenv("S3_SECRET"), + 'token' => false + ]; + $wgAWSRegion = getenv("S3_REGION"); + $wgAWSBucketName = getenv("S3_BUCKET_NAME"); + + # If you are using minio, you need to set a public policy like this: + # mc policy set public instance/bucket/ + # mc admin config set instance/bucket/ api cors_allow_origin=https://wiki.example.com + + $wgAWSBucketTopSubdirectory = getenv("S3_SUBDIRECTORY"); + $wgAWSRepoHashLevels = '2'; # Default 0; But 2 means that S3 objects + # will be named a/ab/Filename.png (same + # as when MediaWiki stores files in local + # directories) + # --- + $wgAWSRepoDeletedHashLevels = '3'; # Default 0; But 3 for naming + # a/ab/abc/Filename.png (same as + # when MediaWiki stores deleted + # files in local directories) + + //The url used for the API (PutObject, etc.) + $wgFileBackends['s3']['endpoint'] = getenv("S3_ENDPOINT"); + //The url used for showing images. $1 is translated to the bucket name. + $wgAWSBucketDomain = getenv("S3_BUCKET_DOMAIN_NAME"); +} + # Set Subpages on $wgNamespacesWithSubpages[NS_MAIN] = 1; @@ -170,12 +250,12 @@ ini_set('memory_limit', '-1'); # Move the SMW config directory $smwgConfigFileDir = '/var/www/localstore/smwconfig'; -# Logo, 135x135px -$wgLogo = "/wiki/Special:Redirect/file/Logo.png"; +# Logos +$wgLogos = [ '1x' => "/wiki/Special:Redirect/file/Logo.png" ]; # Footer icons - if (getenv("DISABLE_ICONS")) { + $wgFooterIcons['poweredby']['semanticmediawiki'] = false; unset( $wgFooterIcons['poweredby'] ); }