在MediaWiki上使用官方docker镜像时如何最好地添加扩展名? [英] How to best add extensions when using official docker image for MediaWiki?

查看:223
本文介绍了在MediaWiki上使用官方docker镜像时如何最好地添加扩展名?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在使用官方的 MediaWiki Docker映像,并希望能够添加其他MediaWiki扩展.

We are using the official MediaWiki Docker image and want to be able to add additional MediaWiki extensions.

问题:

  1. 如果我们当前正在使用下面的docker-compose文件,如果我们在主机上装载了卷,那么这里建议的下一步是什么?是否要构建一个包含官方图像的新图像?在修改后的新图像的某个地方是否有添加MediaWiki扩展的示例?
  2. 或者我们可以仅在当前docker-compose的主机上安装扩展卷,并在需要时对LocalSettings.php进行任何调整吗?
  1. 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?
  2. 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?

Docker网站上的链接是指添加PHP扩展名和库,但是如果要添加MediaWiki特定的扩展名是相同的答案,这对我来说还是不清楚的,因为它确实说了"PHP扩展名".还是该文档页面实际上应该说"MediaWiki Extensions",即使这暗示它们是用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?

这是我们当前针对mediawiki的docker-compose文件条目:

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):

  • embedvideo
  • multimediaviewer
  • visualeditor

使用官方mediawiki图像作为其"FROM"以包含mediawiki扩展和更新的docker-compose(如果同时需要)以添加mediawiki扩展的下游docker图像的任何示例都是:乐于助人.也许最好解释一下,如果mediawiki扩展本身依赖于基本图像中尚未包含的php扩展或库,而不是添加一个不依赖任何其他php扩展或库的mediawiki扩展.

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.

推荐答案

如OP所建议的,您需要创建一个包装正式MediaWiki图像的图像.

As OP suggested, you need to create an image which wraps the official MediaWiki image.

作为一个最小的示例,我们将创建一个图像,其中包含 EmbedVideo 扩展名,从1.31版开始,它不与MediaWiki捆绑在一起.在文件my-mediawiki/Dockerfile中添加以下说明:

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

构建图像

使用docker build将此Dockerfile转换为映像:

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

测试图像

使用docker run测试图像:

$ docker run --rm -p 8080:80 username/mediawiki

此容器正在运行时,请使用Web浏览器访问localhost:8080.系统将要求您执行设置过程.当您进入选项页面时,EmbedVideo扩展名将包含在扩展名列表中.

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.

需要其他步骤才能使MediaWiki在docker中运行,例如提供LocalSettings.php文件并将其连接到数据库.请按照官方MediaWiki Docker文档进行这些步骤,将您的username/mediawiki图像替换为官方mediawiki图片.

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.

可以通过在my-mediawiki/Dockerfile的末尾附加更多RUN指令来安装多个插件.例如,要添加 Scribunto ,请在文件底部添加以下内容:

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

修改Dockerfile后,使用以下方法更新图像:

After modifying the Dockerfile update the image using:

docker build -t username/mediawiki ./my-mediawiki

大多数扩展名都需要您修改LocalSettings.php,像Scribunto一样,某些扩展名需要在下载后运行其他安装命令(请检查每个扩展名的README).诸如 VisualEditor 之类的复杂扩展将需要其他容器来运行诸如Parsoid之类的守护程序.我自己的 Dockerfile

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.

这篇关于在MediaWiki上使用官方docker镜像时如何最好地添加扩展名?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆