We are using the official MediaWiki Docker image and want to be able to add additional MediaWiki extensions.
Questions:
LocalSettings.php
? This link on the docker website refers to adding PHP extensions and libraries but its not clear to me if this is attempting to be the same answer if wanting to add MediaWiki specific extensions since it does clearly say "PHP Extensions". Or should this documentation page have actually said "MediaWiki Extensions" even though that implies they are written in PHP?
Here is our current docker-compose file entry for mediawiki:
mediawiki:
image: mediawiki
container_name: mediawiki_production
mem_limit: 4g
volumes:
- /var/www/mediawiki/uploads:/var/www/html/uploads
- /var/www/mediawiki/LocalSettings.php:/var/www/html/LocalSettings.php
environment:
- MEDIAWIKI_DB_NAME=
- MEDIAWIKI_DB_HOST=
- MEDIAWIKI_DB_USER=
- MEDIAWIKI_DB_PASSWORD=
- VIRTUAL_HOST=wiki.exmaple.com
- TERM=xterm
restart: always
network_mode: bridge
The extensions we are considering that are not part of the official image first off are (but would like a scalable solution for more later):
Any examples of an downstream docker image that uses the official mediawiki image as its "FROM" to include a mediawiki extension(s) and an updated docker-compose (if both are required) to be able to add mediawiki extensions would be helpful. Perhaps it may be good to explain what needs to change if the mediawiki extension itself relies on php extensions or libraries that are not already included in base image already vs adding a mediawiki extension that doesn't rely on any additional php extensions or libraries.
A new docker container based on “linuxconfig/mediawiki” will expose port 80 which can be linked to the docker host port for an immediate Mediawiki web configuration/installation access. Below command will download and create a new docker container called mediawiki and link local host system port 80 with container’s exposed port 80.
The Mediawiki runs on Debian GNU/Linux system featuring Apache web server, MariaDB ( MySQL ), database and PHP5. A new docker container based on “linuxconfig/mediawiki” will expose port 80 which can be linked to the docker host port for an immediate Mediawiki web configuration/installation access.
Wiki users can browse through extensions. System administrators can install (or remove) extensions on the MediaWiki installations that they manage. Developers can write new extensions or improve or maintain extensions. While some extensions are maintained by MediaWiki developers, others were written by third-party developers.
That’s right, you can host a wiki, using MediaWiki, even in a Windows 10 Docker container. We suggest you start with their official instructions though I’ve covered how to install Docker in Debian 10 in another post about Mastodon.
As OP suggested, you need to create an image which wraps the official MediaWiki image.
As a minimal example we'll create an image which includes the EmbedVideo extension, which is not bundled with MediaWiki as of version 1.31. Add the following instructions the file my-mediawiki/Dockerfile
:
FROM mediawiki:latest
RUN git clone --depth 1 https://github.com/HydraWiki/mediawiki-embedvideo.git /var/www/html/extensions/EmbedVideo
Turn this Dockerfile into an image using docker build
:
$ docker build -t username/mediawiki ./my-mediawiki
Sending build context to Docker daemon 2.048kB
Step 1/2 : FROM mediawiki:latest
latest: Pulling from library/mediawiki
802b00ed6f79: Pull complete
# [lines omitted]
8b47ece631d8: Pull complete
Digest: sha256:5922653b254073c6d6a535bbdb0101f8a5eadbf557e2f31d590c234001c55b60
Status: Downloaded newer image for mediawiki:latest
---> 27fe73856ca7
Step 2/2 : RUN git clone --depth 1 https://github.com/HydraWiki/mediawiki-embedvideo.git /var/www/html/extensions/EmbedVideo
---> Running in 30a411511341
Cloning into '/var/www/html/extensions/EmbedVideo'...
Removing intermediate container 30a411511341
---> 5b297228bb08
Successfully built 5b297228bb08
Successfully tagged username/mediawiki:latest
Test the image using docker run
:
$ docker run --rm -p 8080:80 username/mediawiki
While this container is running visit localhost:8080
with a web browser. You will be asked to perform the setup procedure. When you get to the options page the EmbedVideo extension will be included in the list of extensions.
Other steps are needed to get MediaWiki running in docker, such as providing a LocalSettings.php
file and connecting it to a database. Follow the official MediaWiki Docker documentation for these steps, substituting your username/mediawiki
image for the official mediawiki
image.
Multiple plugins can be installed by appending more RUN
instructions to the end of my-mediawiki/Dockerfile
. For example, to add Scribunto, append the following to the bottom of the file:
RUN git clone --depth 1 -b $MEDIAWIKI_BRANCH \
https://gerrit.wikimedia.org/r/p/mediawiki/extensions/Scribunto \
/var/www/html/extensions/Scribunto \
&& chmod a+x /var/www/html/extensions/Scribunto/includes/engines/LuaStandalone/binaries/lua*_linux_*/lua
After modifying the Dockerfile
update the image using:
docker build -t username/mediawiki ./my-mediawiki
Most extensions require you to modify LocalSettings.php
, and like Scribunto some will require additional installation commands to be run after download (check each extensions's README
). Complex extensions like VisualEditor will require additional containers to run daemons such as Parsoid. My own Dockerfile
and docker-compose.yml
illustrate how other plugins can be configured.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With