We are using the official MediaWiki Docker image and want to be able to add additional MediaWiki extensions.
Questions:
- What is the recommended next step here if we are currently using the docker-compose file below were we mount volumes on the host? Is it to build a new image that wraps the official image? Is there an example somewhere of this modified new image for adding a mediawiki extension?
- Or can we just mount an extensions volume on the host in the current docker-compose and if needed make any adjustments the
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.
As OP suggested, you need to create an image which wraps the official MediaWiki image.
Write instructions to make an image with extra extensions
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
Build the image
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
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.
Perform the rest of setup
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.
Add additional plugins
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.
来源:https://stackoverflow.com/questions/49267591/how-to-best-add-extensions-when-using-official-docker-image-for-mediawiki