MediaWiki-Docker/Configuration recipes/Customize base image

Sometimes we need to customize the base image used for mediawiki. For example, we may need to install additional packages. To do that follow the below steps:

Modify the mediawiki service in docker-compose.override.yml as follows:

services:
  mediawiki:
    build:
      context: ./path/to/custom/Dockerfile/Directory
      dockerfile: Dockerfile

In that custom Dockerfile, build everything on top of base image. Suppose, we want to install imagemagick

# Important: Make sure the version here matches the latest version of the mediawiki image in docker-compose.yml
FROM docker-registry.wikimedia.org/dev/bookworm-php83-fpm:1.0.0

RUN apt update && \

   apt install -y imagemagick

# Add any additional image preparation code here.

The base image (e.g. bookworm-php83-fpm:1.0.0) should match that used for the mediawiki service in the docker-compose.yml file.

You should run docker compose build after changing this Dockerfile.

Using Blubber

It is possible to use the Blubber BuildKit frontend to write your container build files. Blubber is a helper for building OCI containers that is used widely in the Wikimedia projects.

.settings/blubber.yaml
# syntax=docker-registry.wikimedia.org/repos/releng/blubber/buildkit:v1.3.0
version: v4

variants:
  mediawiki:
    base: docker-registry.wikimedia.org/dev/bookworm-php83-fpm:1.0.0
    runs:
      insecurely: true
    lives:
      in: /var/www/html/w
    apt:
      packages:
        - imagemagick
docker-compose.override.yml
services:
  mediawiki:
    build:
      context: .
      dockerfile: .settings/blubber.yaml
      target: mediawiki
      args:
        LIVES_UID: $MW_DOCKER_UID
        LIVES_GID: $MW_DOCKER_GID
    image: "mediawiki:custom"
    pull_policy: build