Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep MediaWiki up to date #241

Draft
wants to merge 19 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ jobs:
shellcheck cleanup/*.sh
shellcheck mariadb/docker-entrypoint.sh
shellcheck mediawiki/*.sh
shellcheck mwlib/docker-entrypoint.sh
shellcheck nextcloud/docker-entrypoint.sh
shellcheck redis/docker-entrypoint.sh
shellcheck rocketchat/docker-entrypoint.sh
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ baseimages/stretch_chroot
baseimages/alpine_chroot
hubot-rocketchat/packages/*
hubot-rocketchat/redis-dump
mediawiki/config/logos.php
mediawiki/config/namespaces.php
mediawiki/kblogo.png
mediawiki/logos/*
mediawiki/_db
mediawiki/_deleted
mediawiki/_images
Expand Down
47 changes: 24 additions & 23 deletions mediawiki/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
FROM alpine:3.13
MAINTAINER Evgeny Golyshev <[email protected]>
FROM alpine:3.20

ENV MEDIAWIKI_VERSION REL1_35
LABEL maintainer="Evgeny Golyshev <[email protected]>"

RUN echo http://mirror.yandex.ru/mirrors/alpine/v3.13/community >> /etc/apk/repositories \
ENV MEDIAWIKI_VERSION REL1_42

RUN echo http://mirror.yandex.ru/mirrors/alpine/v3.20/community >> /etc/apk/repositories \
&& apk --update add \
bash \
curl \
git \
mysql-client \
nginx \
php7 \
php7-ctype \
php7-curl \
php7-dom \
php7-fileinfo \
php7-fpm \
php7-gd \
php7-iconv \
php7-intl \
php7-json \
php7-mbstring \
php7-mysqli \
php7-pecl-apcu \
php7-session \
php7-xml \
php7-xmlreader \
php83 \
php83-ctype \
php83-curl \
php83-dom \
php83-fileinfo \
php83-fpm \
php83-gd \
php83-iconv \
php83-intl \
php83-json \
php83-mbstring \
php83-mysqli \
php83-pecl-apcu \
php83-session \
php83-xml \
php83-xmlreader \
python3 \
supervisor \
&& cd /usr/bin \
Expand Down Expand Up @@ -65,17 +66,17 @@ RUN echo http://mirror.yandex.ru/mirrors/alpine/v3.13/community >> /etc/apk/repo
git \
&& rm -rf /var/cache/apk/*

COPY ./config/LocalSettings.php ./config/namespaces.ph[p] /var/www/w/
COPY ./config/LocalSettings.php ./config/logos.ph[p] ./config/namespaces.ph[p] /var/www/w/

COPY ./config/default /etc/nginx/conf.d/default.conf
COPY ./config/default /etc/nginx/http.d/default.conf

COPY ./config/supervisord.conf /etc/supervisor/supervisord.conf

COPY ./rollout_fixes.sh /usr/bin/rollout_fixes.sh

COPY ./docker-entrypoint.sh /usr/bin/docker-entrypoint.sh

COPY ./logo.svg ./kblogo.pn[g] /var/www/w/resources/assets/
COPY ./logos/ /var/www/w/resources/assets/

RUN /usr/bin/rollout_fixes.sh

Expand Down
136 changes: 109 additions & 27 deletions mediawiki/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ MediaWiki is one of the most famous wiki engines. It's best known for being used
</tr>
<tr>
<td>Version</td>
<td><a href="https://mediawiki.org/wiki/MediaWiki_1.35">1.35</a></td>
<td><a href="https://www.mediawiki.org/wiki/MediaWiki_1.42">1.42</a></td>
</tr>
<tr>
<td>Release date</td>
<td>20 Sep 2020</td>
<td>27 Jun 2024</td>
</tr>
<tr>
<td>Port</td>
<td>8004</td>
</tr>
<tr>
<td>Data volume</td>
<td>Data volumes</td>
<td>
<code>/srv/mediawiki/deleted:/var/www/w/deleted</code><br>
<code>/srv/mediawiki/images:/var/www/w/images</code>
<code>./_deleted:/var/www/w/deleted</code><br>
<code>./_images:/var/www/w/images</code>
</td>
</tr>
<tr>
<td valign="top">Base image</td>
<td><a href="https://hub.docker.com/_/alpine">Official Docker image</a> based on <a href="https://alpinelinux.org/posts/Alpine-3.13.0-released.html">Alpine 3.13</a></td>
<td><a href="https://hub.docker.com/_/alpine">Official Docker image</a> based on <a href="https://alpinelinux.org/posts/Alpine-3.20.0-released.html">Alpine 3.20</a></td>
</tr>
</table>

Expand All @@ -46,7 +46,7 @@ MediaWiki is one of the most famous wiki engines. It's best known for being used

## Features

* Nginx [1.18.0](http://nginx.org/en/CHANGES-1.18) and PHP [7.4.15](http://php.net/ChangeLog-7.php#7.4.15).
* Nginx [1.26.1](http://nginx.org/en/CHANGES-1.26) and PHP [8.3.9](http://php.net/ChangeLog-8.php#8.3.9).
* The [Cite](https://www.mediawiki.org/wiki/Extension:Cite) extension which allows creating references as footnotes on a page, using `<ref>` and `<references />` tags.
* The [MobileFrontend](https://www.mediawiki.org/wiki/Extension:MobileFrontend) extension which provides a mobile view.
* The [SyntaxHighlight](https://mediawiki.org/wiki/Extension:SyntaxHighlight) extension which provides rich formatting of source code using the `<syntaxhighlight>` tag.
Expand All @@ -58,30 +58,94 @@ MediaWiki is one of the most famous wiki engines. It's best known for being used

`docker-compose.yml` supports the following parameters.

| Parameter | Description | Default |
| --- | --- | --- |
| PORT | Port wiki is available on | 8004 |
| WG_SITENAME | Wiki name | My KB |
| WG_META_NAMESPACE | [Name](https://mediawiki.org/wiki/Manual:$wgMetaNamespace) used for the project namespace | My_KB |
| WG_PROTOCOL | Protocol which is used for accessing wiki (`http` and `https`) | `http` |
| WG_SERVER | [Domain or IP](https://mediawiki.org/wiki/Manual:$wgServer) of the wiki host | 127.0.0.1:8004 |
| WG_EMERGENCY_CONTACT | Wiki [admin email address](https://mediawiki.org/wiki/Manual:$wgEmergencyContact) | [email protected] |
| WG_PASSWORD_SENDER | [Password reminder email address](https://mediawiki.org/wiki/Manual:$wgPasswordSender) | [email protected] |
| WG_DB_SERVER | [Database server host](https://mediawiki.org/wiki/Manual:$wgDBserver) | 127.0.0.1:33061 |
| WG_DB_NAME | [Database name](https://mediawiki.org/wiki/Manual:$wgDBname) | knowledge_base |
| WG_DB_USER | [Database user](https://mediawiki.org/wiki/Manual:$wgDBuser) | root |
| WG_DB_PASSWORD | [Database password](https://mediawiki.org/wiki/Manual:$wgDBpassword) | cusdeb |
| ALLOW_ACCOUNT_CREATION | Allows users to create accounts (`true` and `false`) | `true` |
| ALLOW_ACCOUNT_EDITING | Allows users to edit their accounts (`true` and `false`) | `true` |
| ALLOW_ANONYMOUS_READING | Allows users to read wiki anonymously (`true` and `false`). If the parameter is `false`, wiki is **private** | `false` |
| ALLOW_ANONYMOUS_EDITING | Allows users to edit wiki anonymously (`true` and `false`) | `true` |
<table>
<tr>
<th>Parameter</th>
<th>Description</th>
<th>Default</th>
</tr>
<tr>
<th colspan="3">Basic</th>
</tr>
<tr>
<td>PORT</td>
<td>Port wiki is available on</td>
<td>8004</td>
</tr>
<tr>
<td>WG_SITENAME</td>
<td>Wiki name</td>
<td>My KB</td>
</tr>
<tr>
<td>WG_META_NAMESPACE</td>
<td><a href="https://mediawiki.org/wiki/Manual:$wgMetaNamespace">Name</a> used for the project namespace</td>
<td>My_KB</td>
</tr>
<tr>
<td>WG_PROTOCOL</td>
<td>Protocol which is used for accessing wiki (<code>http</code> and <code>https</code>)</td>
<td><code>http</code></td>
</tr>
<tr>
<td>WG_SERVER</td>
<td><a href="https://mediawiki.org/wiki/Manual:$wgServer">Domain or IP</a> of the wiki host</td>
<td>127.0.0.1:8004</td>
</tr>
<tr>
<td>WG_EMERGENCY_CONTACT</td>
<td>Wiki <a href="https://mediawiki.org/wiki/Manual:$wgEmergencyContact">admin email address</a></td>
<td>[email protected]</td>
</tr>
<tr>
<td>WG_PASSWORD_SENDER</td>
<td><a href="https://mediawiki.org/wiki/Manual:$wgPasswordSender">Password reminder email address</a></td>
<td>[email protected]</td>
</tr>
<tr>
<td>WG_DB_NAME</td>
<td><a href="https://mediawiki.org/wiki/Manual:$wgDBname">Database name</a></td>
<td>knowledge_base</td>
</tr>
<tr>
<th colspan="3">Permissions</th>
</tr>
<tr>
<td>ALLOW_ACCOUNT_CREATION</td>
<td>Allows users to create accounts (<code>true</code> and <code>false</code>)</td>
<td><code>true</code></td>
</tr>
<tr>
<td>ALLOW_ACCOUNT_EDITING</td>
<td>Allows users to edit their accounts (<code>true</code> and <code>false</code>)</td>
<td><code>true</code></td>
</tr>
<tr>
<td>ALLOW_ANONYMOUS_READING</td>
<td>Allows users to read wiki anonymously (<code>true</code> and <code>false</code>). If the parameter is <code>false</code>, wiki is <strong>private</strong></td>
<td><code>false</code></td>
</tr>
<tr>
<td>ALLOW_ANONYMOUS_EDITING</td>
<td>Allows users to edit wiki anonymously (<code>true</code> and <code>false</code>)</td>
<td><code>true</code></td>
</tr>
<tr>
<th colspan="3">MobileFrontend</th>
</tr>
<tr>
<td>COLLAPSE_SECTIONS_BY_DEFAULT</td>
<td>Controls whether to collapse sections by default (<code>true</code> and <code>false</code>)</td>
<td><code>false</code></td>
</tr>
</table>

## How to create an administrator

Administrators are wiki users who are members of the "sysop" user group (see details [here](https://mediawiki.org/wiki/Manual:Administrators)). An administrator can be created, using the [createAndPromote.php](https://mediawiki.org/wiki/Manual:CreateAndPromote.php) script:

1. Run `docker exec` on a running MediaWiki container.
2. Run `php7 maintenance/createAndPromote.php --sysop <username> <password>` inside the container.
2. Run `php maintenance/createAndPromote.php --sysop <username> <password>` inside the container.

## How to register custom namespaces

Expand All @@ -104,6 +168,24 @@ Then, rebuild the Docker image and re-run the container. After this you will get

In order to modify a [php.ini](https://php.net/manual/en/configuration.file.php) parameter, use the environment variable the name of which consists of `PHP_INI_` and the name of the parameter. For example, to change the [post_max_size](https://php.net/manual/en/ini.core.php#ini.post-max-size) parameter, pass the `PHP_INI_post_max_size` environment variable to the container.

## How to change logo
## How to change logos

Place all the logos in the `logos` directory, they can be accessed using the path `$wgResourceBasePath/resources/assets`. For example, you have placed `cusdeb.svg` and `cusdeb-wordmark.svg` in this directory. Next, create a file `config/logos.php` with the following content:

```php
$wgLogos = [
'icon' => "$wgResourceBasePath/resources/assets/cusdeb.svg",
'tagline' => [
'src' => "$wgResourceBasePath/resources/assets/cusdeb-wordmark.svg",
'width' => 135,
'height' => 15,
],
];
```

and rebuild the image. See [$wgLogos](https://mediawiki.org/wiki/Manual:$wgLogos) for details.

## How to upgrade from MariaDB 10.5 to MariaDB 10.6

Provide a square logo named `kblogo.png` which is 135x135px or 150x150px.
1. Run `docker exec` on a running MariaDB container.
2. Run `mariadb-upgrade -uroot -p`.
12 changes: 4 additions & 8 deletions mediawiki/config/LocalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;

## The URL path to the logo. Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogo = "$wgResourceBasePath/resources/assets/wiki.png";

## UPO means: this is also a user preference option

$wgEnableEmail = false;
Expand Down Expand Up @@ -135,7 +131,7 @@

## Default skin: you can change the default skin. Use the internal symbolic
## names, ie 'vector', 'monobook':
$wgDefaultSkin = "vector";
$wgDefaultSkin = "vector-2022";
wfLoadSkin( 'vector' );

# End of automatically generated settings.
Expand All @@ -154,10 +150,9 @@
// that $wgVirtualRestConfig['modules']['parsoid']['url'] be pointed to localhost if this setting is enabled.
$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;

$wgMFDefaultSkinClass = 'SkinVector';
$wgMFCollapseSectionsByDefault = COLLAPSE_SECTIONS_BY_DEFAULT;

// Cannot use wfLoadExtension here since extension.json does not exist.
require "$IP/extensions/Collection/Collection.php";
$wgMFDefaultSkinClass = 'SkinVector';

$wgCollectionFormats = array(
'rl' => 'PDF',
Expand All @@ -175,6 +170,7 @@ function wfMetricCounter() {
}

wfLoadExtension('Cite');
wfLoadExtension('Collection');
wfLoadExtension('MobileFrontend');
wfLoadExtension('Parsoid', 'vendor/wikimedia/parsoid/extension.json');
wfLoadExtension('SyntaxHighlight_GeSHi');
Expand Down
2 changes: 1 addition & 1 deletion mediawiki/config/default
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ server {
location ~ ^/w/(index|load|api|thumb|opensearch_desc|rest|img_auth)\.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
fastcgi_pass unix:/var/run/php/php8.3-fpm.sock;
}

location /w/images {
Expand Down
2 changes: 1 addition & 1 deletion mediawiki/config/supervisord.conf
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socke
command=/usr/sbin/nginx -g 'daemon off;' -c /etc/nginx/nginx.conf

[program:php-fpm]
command=/usr/sbin/php-fpm7 --nodaemonize
command=/usr/sbin/php-fpm83 --nodaemonize

Loading
Loading