From 7184e94feb32c4e0a1348cf85899ec06d0a835aa Mon Sep 17 00:00:00 2001 From: Fritz Grimpen Date: Sun, 10 Nov 2024 02:59:31 +0100 Subject: [PATCH] Add some complications to MediaWiki image --- mediawiki/Containerfile | 41 +++++++++++++++++++---------------- mediawiki/README.md | 26 ++++++++++++++++++++++ mediawiki/composer.local.json | 7 ++++++ mediawiki/config.json | 40 +++++++++++++++++++++++----------- 4 files changed, 82 insertions(+), 32 deletions(-) create mode 100644 mediawiki/README.md create mode 100644 mediawiki/composer.local.json diff --git a/mediawiki/Containerfile b/mediawiki/Containerfile index d9b9dc9..142e223 100644 --- a/mediawiki/Containerfile +++ b/mediawiki/Containerfile @@ -5,36 +5,39 @@ WORKDIR /usr/src RUN apk update && apk add git ADD https://releases.wikimedia.org/mediawiki/1.42/mediawiki-1.42.3.tar.gz . -RUN tar -xzf mediawiki-1.42.3.tar.gz +RUN tar -xzf mediawiki-1.42.3.tar.gz && mv mediawiki-1.42.3 mediawiki -RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend; \ - rm -rf MobileFrontend/.git +WORKDIR /usr/src/mediawiki -RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/PluggableAuth; \ - rm -rf PluggableAuth/.git +RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/MobileFrontend extensions/MobileFrontend; \ + rm -rf extensions/MobileFrontend/.git -RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/OpenIDConnect; \ - rm -rf OpenIDConnect/.git +RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/PluggableAuth extensions/PluggableAuth; \ + rm -rf extensions/PluggableAuth/.git -RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/Widgets; \ - rm -rf Widgets/.git +RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/OpenIDConnect extensions/OpenIDConnect; \ + rm -rf extensions/OpenIDConnect/.git + +RUN git clone -b REL1_42 https://gerrit.wikimedia.org/r/mediawiki/extensions/Widgets extensions/Widgets; \ + rm -rf extensions/Widgets/.git FROM docker.io/library/unit:php8.2 WORKDIR /var/www/html RUN apt-get update && apt-get install -y \ - libicu-dev librsvg2-bin \ - && docker-php-ext-configure intl \ - && docker-php-ext-install -j$(nproc) intl \ - && docker-php-ext-install -j$(nproc) mysqli \ - && apt-get install -y imagemagick \ + libicu-dev librsvg2-bin imagemagick git unzip \ && rm -rf /var/lib/apt/lists/* -COPY --from=builder --chown=unit:unit /usr/src/mediawiki-1.42.3 w/ -COPY --from=builder --chown=unit:unit /usr/src/MobileFrontend w/extensions/MobileFrontend -COPY --from=builder --chown=unit:unit /usr/src/PluggableAuth w/extensions/PluggableAuth -COPY --from=builder --chown=unit:unit /usr/src/OpenIDConnect w/extensions/OpenIDConnect -COPY --from=builder --chown=unit:unit /usr/src/Widgets w/extensions/Widgets +RUN docker-php-ext-configure intl \ + && docker-php-ext-install -j$(nproc) intl \ + && docker-php-ext-install -j$(nproc) mysqli \ + && docker-php-ext-install -j$(nproc) calendar + +COPY --from=builder --chown=unit:unit /usr/src/mediawiki w/ +COPY --from=docker.io/composer/composer /usr/bin/composer /usr/bin/composer +COPY composer.local.json w/composer.local.json + +RUN cd /var/www/html/w && composer update --no-dev COPY config.json /docker-entrypoint.d/config.json diff --git a/mediawiki/README.md b/mediawiki/README.md new file mode 100644 index 0000000..7f1a754 --- /dev/null +++ b/mediawiki/README.md @@ -0,0 +1,26 @@ +# MediaWiki OCI image + +This MediaWiki OCI image is based on NGINX Unit and bundles several extensions, which are in use in wiki.ccchb.de. + +## Bundled extensions + +* MobileFrontend +* PluggableAuth +* OpenIDConnect +* Widgets + +## Ingress + +The image exposes an HTTP service under port 80. +The MediaWiki installation is available below `/w/` and provides article paths below the path `/wiki/`. +A redirect at `/` is not provided by the image, and has to be implemented by the ingress. + +## Volumes + +It is recommended to mount a volume at `/var/www/html/w/images/` for MediaWiki uploads. + +## Configuration + +The MediaWiki installation expects a LocalSettings.php configuration file at the path `/var/www/html/w/LocalSettings.php`. + +Happy helming! diff --git a/mediawiki/composer.local.json b/mediawiki/composer.local.json new file mode 100644 index 0000000..ff2b321 --- /dev/null +++ b/mediawiki/composer.local.json @@ -0,0 +1,7 @@ +{ + "extra": { + "merge-plugin": { + "include": ["extensions/*/composer.json", "skins/*/composer.json"] + } + } +} diff --git a/mediawiki/config.json b/mediawiki/config.json index afd9e43..1438945 100644 --- a/mediawiki/config.json +++ b/mediawiki/config.json @@ -8,42 +8,56 @@ { "match": { "uri": [ - "/w/index.php", - "/w/load.php", - "/w/api.php", - "/w/thumb.php", - "/w/opensearch_desc.php", - "/w/rest.php", - "/w/img_auth.php", - "/w/rest.php/*", - "/w/mw-config/*.php" + "/w/index.php*", + "/w/load.php*", + "/w/api.php*", + "/w/thumb.php*", + "/w/opensearch_desc.php*", + "/w/rest.php*", + "/w/img_auth.php*" ] }, "action": { - "pass": "applications/php_app" + "pass": "applications/php_app/direct" } }, { "match": { "uri": [ + "!*.php", "/w/images/*", "/w/resources/assets/*", "/w/resources/lib/*", "/w/resources/src/*", "/w/extensions/*", - "/w/skins/*", - "favicon.ico" + "/w/skins/*" ] }, "action": { "share": "/var/www/html$uri" } + }, + { + "match": { + "uri": ["/wiki/*"] + }, + "action": { + "pass": "applications/php_app/index" + } } ], "applications": { "php_app": { "type": "php", - "root": "/var/www/html" + "targets": { + "direct": { + "root": "/var/www/html" + }, + "index": { + "root": "/var/www/html", + "script": "w/index.php" + } + } } } }