The image is based on centos and runs MediaWiki software.
The image consists of the following:
- Apache 2.x web server
- PHP 7.x
- Monit
- ImageMagick + FFMpeg + Curl
- Composer
- ClamAV client
Note: the image does not contain a database embed, so it won't work without external MySQL/MariaDB instance connected.
From scratch via Docker Compose
- Clone the sample stack repository https://github.com/WikiTeq/docker-wikiteq-stack
- Copy
.env.exampleto.env - Modify the
.envfile if necessary - Run
docker-compose up -d
From existing wiki dump via Docker Compose
- Clone the sample stack repository https://github.com/WikiTeq/docker-wikiteq-stack
- Copy
.env.exampleto.env - Modify the
.envfile if necessary - Copy your existing database dump to
__initdbdirectory (both.sqland.gzformats are supported) - Copy your existing
imagesdirectory to_data/mediawiki/images - Copy your wiki
LocalSettings.phpfile to_settings/LocalSettings.php - Run
docker-compose up -d
See https://hub.docker.com/_/mysql/ for details on the database dumps importing.
Docker Compose base template
The base minimal docker-compose.yml template could look like below:
version: '2'
services:
db:
image: mysql:8.0
command: --default-authentication-plugin=mysql_native_password --expire_logs_days=3
restart: unless-stopped
environment:
- MYSQL_ROOT_HOST=%
- MYSQL_ROOT_PASSWORD=${MW_DB_INSTALLDB_PASS:-mediawiki}
- MYSQL_DATABASE=${MW_DB_NAME:-mediawiki}
volumes:
- ./__initdb:/docker-entrypoint-initdb.d
- ./_data/mysql:/var/lib/mysql
web:
image: ghcr.io/wikiteq/mediawiki:latest
restart: unless-stopped
ports:
- "${PORT:-127.0.0.1:80}:80"
links:
- db
environment:
# Use .env file to provide values
- MW_ADMIN_USER=${MW_ADMIN_USER:-admin}
- MW_ADMIN_PASS=${MW_ADMIN_PASS:-admin}
- MW_DB_NAME=${MW_DB_NAME:-mediawiki}
- MW_DB_INSTALLDB_USER=${MW_DB_INSTALLDB_USER:-root}
- MW_DB_INSTALLDB_PASS=${MW_DB_INSTALLDB_PASS:-mediawiki}
- MW_DB_USER=${MW_DB_USER:-root}
- MW_DB_PASS=${MW_DB_PASS:-mediawiki}
- MW_LOAD_SKINS=${MW_LOAD_SKINS:-Vector}
- MW_DEFAULT_SKIN=${MW_DEFAULT_SKIN:-Vector}
- MW_LOAD_EXTENSIONS=${MW_LOAD_EXTENSIONS:-ParserFunctions,WikiEditor}
volumes:
- ./_data/mediawiki:/mediawiki
- ./_logs/httpd:/var/log/httpd
- ./_logs/mediawiki:/var/log/mediawikiThe latest recommended version of the stack can be found at https://github.com/WikiTeq/docker-wikiteq-stack with details on the directories structure
Below is the list of evironment variables used by the image:
MW_SITE_SERVERconfigures $wgServer; set this to the server host and include the protocol likehttp://my-wiki:8080MW_SITE_NAMEconfigures $wgSitenameMW_SITE_LANGconfigures $wgLanguageCodeMW_DEFAULT_SKINconfigures $wgDefaultSkinMW_ENABLE_UPLOADSconfigures $wgEnableUploadsMW_USE_INSTANT_COMMONSconfigures $wgUseInstantCommonsMW_ADMIN_USERconfigures the default administrator usernameMW_ADMIN_PASSconfigures the default administrator passwordMW_DB_NAMEspecifies the database name that will be created automatically upon container startupMW_DB_USERspecifies the database user for access to the database specified inMW_DB_NAMEMW_DB_PASSspecifies the database user passwordMW_DB_INSTALLDB_USERspecifies the database superuser name for create database and user specified aboveMW_DB_INSTALLDB_PASSspecifies the database superuser password; should be the same asMYSQL_ROOT_PASSWORDin db section.MW_PROXY_SERVERS(comma separated values) configures $wgSquidServers. Leave empty if no reverse proxy server used.MW_MAIN_CACHE_TYPEconfigures $wgMainCacheType.MW_MEMCACHED_SERVERSshould be provided forCACHE_MEMCACHED.MW_MEMCACHED_SERVERS(comma separated values) configures $wgMemCachedServers.MW_AUTOUPDATEiftrue(by default), run needed maintenance scripts automatically before web server start.MW_SHOW_EXCEPTION_DETAILSiftrue(by default) configures $wgShowExceptionDetails as true.PHP_LOG_ERRORSspecifieslog_errorsparameter inphp.inifile.PHP_ERROR_REPORTINGspecifieserror_reportingparameter inphp.inifile.E_ALLby default, on production should be changed toE_ALL & ~E_DEPRECATED & ~E_STRICT.MW_ENABLE_SITEMAP_GENERATORdefines if sitemap generation is enabled or notMW_SITEMAP_PAUSE_DAYSif the above is enabled, sets the delys between sitemap regenerationsPHP_UPLOAD_MAX_FILESIZEsets max upload sizePHP_POST_MAX_SIZEsets max post sizeLOG_FILES_COMPRESS_DELAYsets logs compression delay in secondsLOG_FILES_REMOVE_OLDER_THAN_DAYSsets lifespan for old logsMW_ENABLE_TRANSCODERdefines if the transcoder service is enabledMW_JOB_TRANSCODER_PAUSEsets the transcoder service delay in secondsMW_ENABLE_JOB_RUNNERdefines if the job runner service is enabledMW_JOB_RUNNER_PAUSEsets the job runner service delay in secondsMW_ENABLE_EMAILcontrols the$wgEnableEmailMW_ENABLE_USER_EMAILcontrols the$wgEnableUserEmailMW_EMERGENCY_CONTACTcontrols the$wgEmergencyContactMW_PASSWORD_SENDERcontrols the$wgPasswordSenderMW_DB_TYPEcontrols the$wgDBtypeMW_DB_SERVERcontrols the$wgDBserverMW_DB_NAMEcontrols the$wgDBnameMW_USE_CACHE_DIRECTORYcontrols the$wgCacheDirectory, if set totrueputs$IP/cacheas a valueMW_SECRET_KEYcontrols the$wgSecretKeyMW_USE_IMAGE_MAGICcontrols the$wgUseImageMagickMW_LOAD_SKINScontrols the list of extension to enable out of the pre-installed skins list (see below)MW_LOAD_EXTENSIONScontrols the list of extension to enable out of the pre-installed extensions list (see below)
The image has the following extensions pre-installed. These pre-installed extensions can be enabled via MW_LOAD_EXTENSIONS env:
- AdminLinks
- AdvancedSearch
- AJAXPoll
- AntiSpoof
- ApprovedRevs
- Arrays
- BetaFeatures
- Bootstrap
- BreadCrumbs2
- CategoryTree
- ChangeAuthor
- CharInsert
- CheckUser
- CirrusSearch
- ContributionScores
- Elastica
- Cite
- CiteThisPage
- CodeEditor
- CodeMirror
- Collection
- CommentStreams
- CommonsMetadata
- ConfirmAccount
- ConfirmEdit
- ConfirmEdit/QuestyCaptcha
- ConfirmEdit/ReCaptchaNoCaptcha
- ContactPage
- DataTransfer
- DebugMode
- Description2
- Disambiguator
- DismissableSiteNotice
- DisplayTitle
- Echo
- EditAccount
- EmbedVideo
- EncryptedUploads
- EventLogging
- EventStreamConfig
- ExternalData
- FixedHeaderTable
- Flow
- Gadgets
- GlobalNotice
- googleAnalytics
- GoogleAnalyticsMetrics
- GoogleDocCreator
- GoogleDocTag
- GTag
- HeaderFooter
- HeaderTabs
- HeadScript
- HTMLTags
- IframePage
- ImageMap
- InputBox
- Interwiki
- LabeledSectionTransclusion
- Lazyload
- Lingo
- LinkSuggest
- LinkTarget
- LiquidThreads
- LocalisationUpdate
- LockAuthor
- Lockdown
- LookupUser
- Loops
- Maps
- MassMessage
- MassMessageEmail
- MassPasswordReset
- Math
- Mendeley
- MobileDetect
- MobileFrontend
- MsUpload
- MultimediaViewer
- MyVariables
- NCBITaxonomyLookup
- Nuke
- NumerAlpha
- OATHAuth
- OpenGraphMeta
- OpenIDConnect
- PageExchange
- PageForms
- PageImages
- PageSchemas
- ParserFunctions
- PdfHandler
- PluggableAuth
- Poem
- Popups
- PubmedParser
- Renameuser
- ReplaceText
- RevisionSlider
- RottenLinks
- SandboxLink
- SaveSpinner
- Scopus
- Scribunto
- SecureLinkFixer
- SelectCategory
- SemanticExternalQueryLookup
- SemanticExtraSpecialProperties
- SemanticCompoundQueries
- SemanticDrilldown
- SemanticMediaWiki
- SemanticQueryInterface
- SemanticResultFormats
- SemanticScribunto
- ShowMe
- SimpleChanges
- SimpleMathJax
- Skinny
- SkinPerNamespace
- SkinPerPage
- SocialProfile
- SoundManager2Button
- SpamBlacklist
- SRFEventCalendarMod
- SubPageList
- Survey
- Sync
- SyntaxHighlight_GeSHi
- Tabber
- Tabs
- TemplateData
- TemplateStyles
- TextExtracts
- Thanks
- TimedMediaHandler
- TinyMCE
- TitleBlacklist
- TwitterTag
- UniversalLanguageSelector
- UploadWizard
- UploadWizardExtraButtons
- UrlGetParameters
- UserMerge
- Variables
- VEForAll
- VisualEditor
- VoteNY
- WhoIsWatching
- Widgets
- WikiEditor
- WikiForum
- WikiSEO
- Wiretap
- YouTube
The image has the following skins pre-installed, there extensions can be enabled via MW_LOAD_SKINS env:
- chameleon
- CologneBlue
- MinervaNeue
- Modern
- MonoBook
- Refreshed
- Timeless
- Vector
The image has the ClamAV client installed, it expects to have a ClamD installed on the Docker host machine (or somewhere else) and won’t work without it. ClamAV client does not contain the viruses signature database and sends files for scanning to ClamD via TCP Socket (172.17.0.1:3310 by default).
You can install and configure ClamD on the Docker host machine to listen on TCPSocket 3310 (ClamD default TCP port) and TCPAddr 172.17.0.1 (Docker default gateway IP available for all containers).
Just add these parameters to /etc/clamav/clamd.conf file.
And define the antivirus configuration in LocalSettings.php file:
# Antivirus configuration
$wgAntivirusSetup = [
'clamavD' => [
'command' => "/usr/bin/clamdscan --no-summary --fdpass %f",
'codemap' => [
"0" => AV_NO_VIRUS, #no virus
"1" => AV_VIRUS_FOUND, #virus found
"52" => AV_SCAN_ABORTED, #unsupported file format (probably immune)
"*" => AV_SCAN_FAILED, #else scan failed
],
'messagepattern' => '/.*?:(.*)/sim',
],
];
# Use daemonized scanner through socket
$wgAntivirus = "clamavD";
Depending on the setup approach the container will handle the settings files as below:
- Fresh install:
** The default
LocalSettings.phpis generated automatically by the MediaWiki'sinstall.phpscript ** TheDockerSettings.phpcontains settings specific to the container, it handles all the specific of this image like automatically enabling of some settings when certain type of cache is enabled, etc. This file is appended to the defaultLocalSettings.phpgenerated above - Importing existing database:
** The
DockerSettings.phpis symlinked directly as rootLocalSettings.php
The container looks for a custom settings file at _settings/LocalSettings.php so
you can mount the _settings directory to the container and put the LocalSettings.php file there.
This file will be appended to the bottom of the DockerSettings.php
Data like uploaded images and the database files stored in the _data directory
Docker containers write files to these directories using internal users; most likely you cannot change/remove these directories until you change permissions
Log files stored in _logs directory
/mediawiki- the volume that storesimages,cacheand various extension persistent files likecompiled_templatesforWidgetsorconfigfiles for SMW extension which are being symlinked into/var/www/html/w. The volume must be mounted to persistent storage like a folder outside the docker container (./_data/mediawikifor example). The container will not start if/mediawikiis not mounted to a folder, but if you know what you do, you can allow to start the container without mounting/mediawikiif you setMW_ALLOW_UNMOUNTED_VOLUMEenvironment variable astrue./mw_origin_files- a temp/backup directory to toss some of original files and directories of the wiki core/var/www/html/w- the main wiki web root/var/log/apache2- logs for Apache web server
run-apache.sh- main entrypointmwjobrunner.sh- runs MediaWiki jobs via job queuemwtranscoder.sh- runs transcoding jobs via job queuemwsitemapgen.sh- generates sitemapsrotatelogs-compress.sh- rotates and compresses the logs
The entrypoint is run-apache.sh script. This script does all the necessary stuff related to the
initial container setup, detecting settings, detecting the need to do a fresh wiki install or
database initialization. The script is also in response of stating all the rest of the service scripts.
Simplified actions taken are as below:
- Fetch necessary settings via
getMediawikiSettings.php - Do necessary checks to ensure we're good to go
- Syncs
/mw_origin_fileswith/var/www/html/w - Sets directories permissions
- Waits for other services to start
- Starts
maintenance/install.php(if it's a fresh installation) and appends theDockerSettings.phpto the bottom of generated/var/www/html/w/LocalSettings.php - Or symlinks
/var/www/html/w/DockerSettings.php->/mediawiki/LocalSettings.php - Starts service scripts
- Runs
maintenance/update.phpand SMW maintenance scripts - Starts the Apache
The image is bundled with DebugMode extension which can be enabled via MW_DEBUG_MODE=true environment variable
plus adding your IP address to $wgDebugModeForIP array
It's possible to run extra script after the initial setup is done and before the Apache is started in the container,
to do so mount the /post-init.sh script into container. Note, the script will be executed under the root user
so if necessary use chown or run commands via runuser -c "ls -al" -s /bin/bash "$WWW_USER".