Difference between revisions of "Pymediawikidocker"

From BITPlan Wiki
Jump to navigation Jump to search
 
(15 intermediate revisions by the same user not shown)
Line 7: Line 7:
 
|title=pymediawikidocker
 
|title=pymediawikidocker
 
|url=https://github.com/WolfgangFahl/pymediawikidocker
 
|url=https://github.com/WolfgangFahl/pymediawikidocker
|version=0.21.1
+
|version=0.22.1
 
|description=Python controlled mediawiki docker image installation
 
|description=Python controlled mediawiki docker image installation
|date=2025-09-03
+
|date=2025-11-19
 
|since=2021-06-08
 
|since=2021-06-08
 
|storemode=property
 
|storemode=property
Line 37: Line 37:
  
 
<graphviz>
 
<graphviz>
// generated by /Users/wf/py-workspace/pymediawikidocker/tests/test_install.py on 2025-07-08T11:40:08.769991
+
// generated by /Users/wf/py-workspace/pymediawikidocker/tests/test_install.py on 2025-11-18T11:42:35.172993
 
digraph mwcluster {
 
digraph mwcluster {
 
   rankdir="RL"
 
   rankdir="RL"
 
   mew0 [ label="mw-135-mw\nMediaWiki 1.35.13\nport 9080" ]
 
   mew0 [ label="mw-135-mw\nMediaWiki 1.35.13\nport 9080" ]
   mdb0 [ label="mw-135-db\nMariaDB 10.11\nport 9306" ]
+
   mdb0 [ label="mw-135-db\nMariaDB 11.4\nport 9306" ]
 
   subgraph cluster_0{
 
   subgraph cluster_0{
 
     label="mw-135"
 
     label="mw-135"
 
     mew0->mdb0
 
     mew0->mdb0
 
   }
 
   }
   mew1 [ label="mw-139-mw\nMediaWiki 1.39.13\nport 9081" ]
+
   mew1 [ label="mw-139-mw\nMediaWiki 1.39.15\nport 9081" ]
   mdb1 [ label="mw-139-db\nMariaDB 10.11\nport 9307" ]
+
   mdb1 [ label="mw-139-db\nMariaDB 11.4\nport 9307" ]
 
   subgraph cluster_1{
 
   subgraph cluster_1{
 
     label="mw-139"
 
     label="mw-139"
 
     mew1->mdb1
 
     mew1->mdb1
 
   }
 
   }
   mew2 [ label="mw-143-mw\nMediaWiki 1.43.2\nport 9082" ]
+
   mew2 [ label="mw-143-mw\nMediaWiki 1.43.5\nport 9082" ]
   mdb2 [ label="mw-143-db\nMariaDB 10.11\nport 9308" ]
+
   mdb2 [ label="mw-143-db\nMariaDB 11.4\nport 9308" ]
 
   subgraph cluster_2{
 
   subgraph cluster_2{
 
     label="mw-143"
 
     label="mw-143"
 
     mew2->mdb2
 
     mew2->mdb2
 
   }
 
   }
   mew3 [ label="mw-144-mw\nMediaWiki 1.44.0\nport 9083" ]
+
   mew3 [ label="mw-144-mw\nMediaWiki 1.44.2\nport 9083" ]
   mdb3 [ label="mw-144-db\nMariaDB 10.11\nport 9309" ]
+
   mdb3 [ label="mw-144-db\nMariaDB 11.4\nport 9309" ]
 
   subgraph cluster_3{
 
   subgraph cluster_3{
 
     label="mw-144"
 
     label="mw-144"
Line 70: Line 70:
 
== Prerequisites ==
 
== Prerequisites ==
 
Docker on Windows, Mac or Linux suppporting "docker compose up" using the Docker composer V2 CLI
 
Docker on Windows, Mac or Linux suppporting "docker compose up" using the Docker composer V2 CLI
=== Ubuntu 22.04 LTS installation ===
+
=== Ubuntu 24.04 LTS installation ===
see https://docs.docker.com/engine/install/ubuntu/ on how to setup the docker repositorysudo
+
see https://docs.docker.com/engine/install/ubuntu/ on how to setup the docker repository
<source lang='bash' highlight='1-2,4'>
+
 
 +
<source lang='bash' highlight='1-12,15,17-18'>
 +
sudo apt-get install ca-certificates curl gnupg
 +
sudo install -m 0755 -d /etc/apt/keyrings
 +
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
 +
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
 +
sudo chmod a+r /etc/apt/keyrings/docker.gpg
 +
echo \
 +
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
 +
  https://download.docker.com/linux/ubuntu noble stable" | \
 +
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
 +
sudo apt-get update
 
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
 
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
 
docker --version
 
docker --version
Docker version 23.0.2, build 569dd73
+
Docker version 29.0.2, build 8108357
 +
# Create the docker group if it does not exist
 +
sudo groupadd docker 2>/dev/null || true
 +
# Add your current user to the docker group
 +
sudo usermod -aG docker "$USER"
 
docker run hello-world
 
docker run hello-world
 
Hello from Docker!
 
Hello from Docker!
This message shows that your installation appears to be working correctly.
 
 
...
 
 
</source>
 
</source>
 +
The <nowiki>"Hello from Docker"</nowiki> message shows that your installation appears to be working correctly.
  
 
=== Compatibility test ===
 
=== Compatibility test ===
Line 93: Line 106:
 
</source>
 
</source>
  
=== Installation of Docker Compose V2 CLI ===
+
=== Test of docker compose ===
 
<source lang='bash' highlight='1'>
 
<source lang='bash' highlight='1'>
lsb_release -a
 
 
No LSB modules are available.
 
No LSB modules are available.
 
Distributor ID: Ubuntu
 
Distributor ID: Ubuntu
Description: Ubuntu 22.04.e LTS
+
Description: Ubuntu 24.04.3 LTS
Release: 22.04
+
Release: 24.04
Codename: jammy
+
Codename: noble
 
</source>
 
</source>
==== docker-ce from docker repo ====
 
<source lang='bash'>
 
# Update existing list of packages
 
sudo apt update
 
  
# Install prerequisite packages which let apt use packages over HTTPS
 
sudo apt install apt-transport-https ca-certificates curl software-properties-common
 
 
# Add Docker’s official GPG key
 
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
 
 
# Add Docker repository to APT sources
 
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
 
 
# Update the package database with Docker packages from the newly added repo
 
sudo apt update
 
 
# Make sure you are about to install from the Docker repo instead of the default Ubuntu repo
 
apt-cache policy docker-ce
 
 
# Install Docker CE
 
sudo apt install docker-ce
 
</source>
 
 
==== docker compose (not docker-compose) ====
 
==== docker compose (not docker-compose) ====
 
<source lang='bash' highlight='1'>
 
<source lang='bash' highlight='1'>
 
docker compose version
 
docker compose version
Docker Compose version v2.26.1
+
Docker Compose version v2.40.3
</source>
 
<source lang='bash' highlight='1-2,7'>
 
sudo apt  install docker-compose
 
docker-compose version
 
docker-compose version 1.29.2, build unknown
 
docker-py version: 5.0.3
 
CPython version: 3.10.12
 
OpenSSL version: OpenSSL 3.0.2 15 Mar 2022
 
which docker-compose
 
/usr/bin/docker-compose
 
 
</source>
 
</source>
  
Line 156: Line 136:
 
<source lang='bash' highlight='1'>
 
<source lang='bash' highlight='1'>
 
mwcluster -V
 
mwcluster -V
pymediawikidocker 0.20.0 2025-08-08
+
pymediawikidocker 0.22.1 2025-11-18
 
</source>
 
</source>
  
 
= Usage =
 
= Usage =
 
<source lang='bash' highlight='1'>
 
<source lang='bash' highlight='1'>
mwcluster -h
+
usage: mwcluster [-h] [-a] [-d] [--debugLocalPath DEBUGLOCALPATH]
mwcluster -h
+
                [--debugPort DEBUGPORT] [--debugRemotePath DEBUGREMOTEPATH]
usage: mwcluster [-h] [-a] [-d] [--debugLocalPath DEBUGLOCALPATH] [--debugPort DEBUGPORT] [--debugRemotePath DEBUGREMOTEPATH]
+
                 [--debugServer DEBUGSERVER] [-f] [-q] [-v] [-V]
                 [--debugServer DEBUGSERVER] [-f] [-q] [-v] [-V] [--article_path ARTICLE_PATH] [-bm] [-cn CONTAINER_NAME] [-dcn DB_CONTAINER_NAME]
+
                [--article_path ARTICLE_PATH] [-bm] [-cn CONTAINER_NAME]
                [-el [EXTENSIONNAMELIST ...]] [-ej EXTENSIONJSONFILE] [--forceRebuild] [-fu] [--host HOST] [-dp DOCKER_PATH] [--lenient] [--logo LOGO]
+
                [-dcn DB_CONTAINER_NAME] [-el [EXTENSIONNAMELIST ...]]
                 [-mv MARIADBVERSION] [--mysqlPassword MYSQLPASSWORD] [-rp] [-p PASSWORD] [-pl PASSWORD_LENGTH] [--prefix PREFIX] [--prot PROT]
+
                [-ej EXTENSIONJSONFILE] [--forceRebuild] [-fu] [--host HOST]
                 [--script_path SCRIPT_PATH] [--url URL] [-sp SQL_PORT] [-smw SMW_VERSION] [-u USER] [--uid UID] [--gid GID] [-bp BASE_PORT]
+
                [-dp DOCKER_PATH] [--lenient] [--logo LOGO]
                [-vl [VERSIONS ...]] [--create] [--down] [--check] [--list]
+
                 [-mv MARIADBVERSION] [--mysqlRootPassword MYSQLROOTPASSWORD]
 +
                [--mysqlPassword MYSQLPASSWORD] [-rp] [-p PASSWORD]
 +
                [-pl PASSWORD_LENGTH] [--prefix PREFIX] [--prot PROT]
 +
                 [--script_path SCRIPT_PATH] [--url URL] [-sp SQL_PORT]
 +
                [-smw SMW_VERSION] [-u USER] [--uid UID] [--gid GID]
 +
                [-bp BASE_PORT] [-vl [VERSIONS ...]] [--create] [--down]
 +
                [--check] [--list]
  
 
Python controlled (semantic) mediawiki docker application cluster installation
 
Python controlled (semantic) mediawiki docker application cluster installation
Line 177: Line 163:
 
   -d, --debug          enable debug output
 
   -d, --debug          enable debug output
 
   --debugLocalPath DEBUGLOCALPATH
 
   --debugLocalPath DEBUGLOCALPATH
                         remote debug Server path mapping - localPath - path on machine where python runs
+
                         remote debug Server path mapping - localPath - path on
 +
                        machine where python runs
 
   --debugPort DEBUGPORT
 
   --debugPort DEBUGPORT
 
                         remote debug Port [default: 5678]
 
                         remote debug Port [default: 5678]
 
   --debugRemotePath DEBUGREMOTEPATH
 
   --debugRemotePath DEBUGREMOTEPATH
                         remote debug Server path mapping - remotePath - path on debug server
+
                         remote debug Server path mapping - remotePath - path
 +
                        on debug server
 
   --debugServer DEBUGSERVER
 
   --debugServer DEBUGSERVER
 
                         remote debug Server
 
                         remote debug Server
Line 189: Line 177:
 
   -V, --version        show program's version number and exit
 
   -V, --version        show program's version number and exit
 
   --article_path ARTICLE_PATH
 
   --article_path ARTICLE_PATH
                         change to any article_path you might need to set [default: ]
+
                         change to any article_path you might need to set
 +
                        [default: ]
 
   -bm, --bind-mount    use bind mounts instead of volumes
 
   -bm, --bind-mount    use bind mounts instead of volumes
 
   -cn CONTAINER_NAME, --container_name CONTAINER_NAME
 
   -cn CONTAINER_NAME, --container_name CONTAINER_NAME
                         set container name (only valid and recommended for single version call)
+
                         set container name (only valid and recommended for
 +
                        single version call)
 
   -dcn DB_CONTAINER_NAME, --db_container_name DB_CONTAINER_NAME
 
   -dcn DB_CONTAINER_NAME, --db_container_name DB_CONTAINER_NAME
                         set database container name [default: mw-139-db]
+
                         set database container name [default: None]
 
   -el [EXTENSIONNAMELIST ...], --extensionList [EXTENSIONNAMELIST ...]
 
   -el [EXTENSIONNAMELIST ...], --extensionList [EXTENSIONNAMELIST ...]
                         list of extensions to be installed [default: ['Admin Links', 'Header Tabs', 'ParserFunctions', 'SyntaxHighlight', 'Variables']]
+
                         list of extensions to be installed [default: ['Admin
 +
                        Links', 'Header Tabs', 'ParserFunctions',
 +
                        'SyntaxHighlight', 'Variables']]
 
   -ej EXTENSIONJSONFILE, --extensionJson EXTENSIONJSONFILE
 
   -ej EXTENSIONJSONFILE, --extensionJson EXTENSIONJSONFILE
                         additional extension descriptions default: [default: None]
+
                         additional extension descriptions default: [default:
 +
                        None]
 
   --forceRebuild        force rebuilding [default: False]
 
   --forceRebuild        force rebuilding [default: False]
 
   -fu, --force_user    force overwrite of wikiuser
 
   -fu, --force_user    force overwrite of wikiuser
   --host HOST          the host to serve / listen from [default: localhost]
+
   --host HOST          the host to serve / listen from [default:
 +
                        noah.bitplan.com]
 
   -dp DOCKER_PATH, --docker_path DOCKER_PATH
 
   -dp DOCKER_PATH, --docker_path DOCKER_PATH
                         the base directory to store docker and jinja template files [default: /Users/wf/.pymediawikidocker]
+
                         the base directory to store docker and jinja template
 +
                        files [default: /home/wf/.pymediawikidocker]
 
   --lenient            do not throw error on wikiuser difference
 
   --lenient            do not throw error on wikiuser difference
   --logo LOGO          set Logo [default: $wgResourceBasePath/resources/assets/wiki.png]
+
   --logo LOGO          set Logo [default:
 +
                        $wgResourceBasePath/resources/assets/wiki.png]
 
   -mv MARIADBVERSION, --mariaDBVersion MARIADBVERSION
 
   -mv MARIADBVERSION, --mariaDBVersion MARIADBVERSION
 
                         mariaDB Version to be installed [default: 11.4]
 
                         mariaDB Version to be installed [default: 11.4]
 +
  --mysqlRootPassword MYSQLROOTPASSWORD
 +
                        set sql root Password [default: None] - random
 +
                        password if None
 
   --mysqlPassword MYSQLPASSWORD
 
   --mysqlPassword MYSQLPASSWORD
                         set sqlRootPassword [default: None] - random password if None
+
                         set sql user Password [default: None] - random
 +
                        password if None
 
   -rp, --random_password
 
   -rp, --random_password
 
                         create random password and create wikiuser while at it
 
                         create random password and create wikiuser while at it
Line 215: Line 215:
 
                         set password for initial user [default: sysop-1234!]
 
                         set password for initial user [default: sysop-1234!]
 
   -pl PASSWORD_LENGTH, --password_length PASSWORD_LENGTH
 
   -pl PASSWORD_LENGTH, --password_length PASSWORD_LENGTH
                         set the password length for random passwords[default: 15]
+
                         set the password length for random passwords[default:
 +
                        15]
 
   --prefix PREFIX      the container name prefix to use [default: mw]
 
   --prefix PREFIX      the container name prefix to use [default: mw]
 
   --prot PROT          change to https in case [default: http]
 
   --prot PROT          change to https in case [default: http]
 
   --script_path SCRIPT_PATH
 
   --script_path SCRIPT_PATH
                         change to any script_path you might need to set [default: ]
+
                         change to any script_path you might need to set
   --url URL            will set prot host,script_path, and optionally port based on the url given [default: None]
+
                        [default: ]
 +
   --url URL            will set prot host,script_path, and optionally port
 +
                        based on the url given [default: None]
 
   -sp SQL_PORT, --sql_base_port SQL_PORT
 
   -sp SQL_PORT, --sql_base_port SQL_PORT
                         set base mySql port 3306 to be exposed - incrementing by one for each version [default: 9306]
+
                         set base mySql port 3306 to be exposed - incrementing
 +
                        by one for each version [default: 9306]
 
   -smw SMW_VERSION, --smw_version SMW_VERSION
 
   -smw SMW_VERSION, --smw_version SMW_VERSION
                         set SemanticMediaWiki Version to be installed default is None - no installation of SMW
+
                         set SemanticMediaWiki Version to be installed default
   -u USER, --user USER  set username of initial user with sysop rights [default: Sysop]
+
                        is None - no installation of SMW
 +
   -u USER, --user USER  set username of initial user with sysop rights
 +
                        [default: Sysop]
 
   --uid UID            User ID (default: 33 for www-data)
 
   --uid UID            User ID (default: 33 for www-data)
 
   --gid GID            Group ID (default: 33 for www-data)
 
   --gid GID            Group ID (default: 33 for www-data)
 
   -bp BASE_PORT, --base_port BASE_PORT
 
   -bp BASE_PORT, --base_port BASE_PORT
                         set how base html port 80 to be exposed - incrementing by one for each version [default: 9080]
+
                         set how base html port 80 to be exposed - incrementing
 +
                        by one for each version [default: 9080]
 
   -vl [VERSIONS ...], --version_list [VERSIONS ...]
 
   -vl [VERSIONS ...], --version_list [VERSIONS ...]
                         mediawiki versions to create docker applications for [default: ['1.35.13', '1.39.13', '1.43.3', '1.44.0']]
+
                         mediawiki versions to create docker applications for
 +
                        [default: ['1.35.13', '1.39.15', '1.43.5', '1.44.2']]
 
   --create
 
   --create
 
   --down
 
   --down
Line 243: Line 251:
 
Starts a cluster with versions 1.35.13,1.39.13, 1.43.2, and 1.44.0 using MariaDB 10.11.
 
Starts a cluster with versions 1.35.13,1.39.13, 1.43.2, and 1.44.0 using MariaDB 10.11.
 
Essentially this is automatic generation of the configuration with a docker compose up for all versions asked for.
 
Essentially this is automatic generation of the configuration with a docker compose up for all versions asked for.
<source lang='bash' highlight='1'>
+
<source lang='bash' highlight='2'>
 
# force new user and random password
 
# force new user and random password
 
mwcluster --create -f -fu -rp
 
mwcluster --create -f -fu -rp
creating docker compose applications for mediawiki versions ['1.35.13', '1.39.13', '1.43.2', '1.44.0']
+
starting mw-135 1.35.13 docker application ...
 
...
 
...
Initializing MediaWiki SQL tables
+
starting mw-139 1.39.15 docker application ...
Executing docker command /root/installExtensions.sh
 
Executing docker command /root/initdb.sh
 
Executing docker command /root/update.sh
 
Executing docker command /root/addSysopUser.sh
 
Executing docker command /root/addCronTabEntry.sh
 
 
...
 
...
 +
starting mw-143 1.43.5 docker application ...
 +
...
 +
starting mw-144 1.44.2 docker application ...
 +
✔ Network mw-144_default    Created                                      0.1s
 +
✔ Volume mw-144_mysql-data  Created                                      0.0s
 +
✔ Volume mw-144_wiki-sites  Created                                      0.0s
 +
✔ Volume mw-144_wiki-etc    Created                                      0.0s
 +
✔ Volume mw-144_wiki-html  Created                                      0.0s
 +
✔ Container mw-144-db      Started                                      5.4s
 +
✔ Container mw-144-mw      Started                                      4.1s
 +
mw-144-mw 🟢 started in 0.01s
 +
mw-144-db 🟢 started in 0.01s
 +
Initializing MediaWiki SQL tables ...
 +
...
 +
Starting periodic command scheduler: cron.
 +
MediaWiki setup complete!
 +
MediaWiki mw-144 is ready at ...
 
</source>
 
</source>
 
Mediawiki applications will be available at
 
Mediawiki applications will be available at
Line 265: Line 285:
 
<source lang='bash' highlight='1'>
 
<source lang='bash' highlight='1'>
 
mwcluster --check -f
 
mwcluster --check -f
checking docker access for mediawiki versions ['1.35.13', '1.38.6', '1.39.8', '1.40.4', '1.41.2', '1.42.1']
 
 
1:checking 1.35.13 ...
 
1:checking 1.35.13 ...
 
mediawiki webserver container mw-135-mw:✅
 
mediawiki webserver container mw-135-mw:✅
 
mediawiki database container mw-135-db:✅
 
mediawiki database container mw-135-db:✅
 
port binding 9080= expected  port 9080?:✅
 
port binding 9080= expected  port 9080?:✅
Checking http://fixit.bitplan.com:9080/index.php/Special:Version ...
+
Checking http://noah.bitplan.com:9080/index.php?title=Special:Version ...
 
Special Version accessible ...:✅
 
Special Version accessible ...:✅
 
Mediawiki Version 1.35.13= expected  1.35.13?:✅
 
Mediawiki Version 1.35.13= expected  1.35.13?:✅
Maria DB Version 10.11 fitting expected 10.11?:✅
+
Maria DB Version 11.4 fitting expected 11.4?:✅
2:checking 1.38.6 ...
+
2:checking 1.39.15 ...
mediawiki webserver container mw-138-mw:✅
+
mediawiki webserver container mw-139-mw:✅
mediawiki database container mw-138-db:✅
+
mediawiki database container mw-139-db:✅
 
port binding 9081= expected  port 9081?:✅
 
port binding 9081= expected  port 9081?:✅
Checking http://fixit.bitplan.com:9081/index.php/Special:Version ...
+
Checking http://noah.bitplan.com:9081/index.php?title=Special:Version ...
 
Special Version accessible ...:✅
 
Special Version accessible ...:✅
Mediawiki Version 1.38.6= expected  1.38.6?:✅
+
Mediawiki Version 1.39.15= expected  1.39.15?:✅
Maria DB Version 10.11 fitting expected 10.11?:✅
+
Maria DB Version 11.4 fitting expected 11.4?:✅
3:checking 1.39.8 ...
+
3:checking 1.43.5 ...
mediawiki webserver container mw-139-mw:✅
+
mediawiki webserver container mw-143-mw:✅
mediawiki database container mw-139-db:✅
+
mediawiki database container mw-143-db:✅
 
port binding 9082= expected  port 9082?:✅
 
port binding 9082= expected  port 9082?:✅
Checking http://fixit.bitplan.com:9082/index.php/Special:Version ...
+
Checking http://noah.bitplan.com:9082/index.php?title=Special:Version ...
 
Special Version accessible ...:✅
 
Special Version accessible ...:✅
Mediawiki Version 1.39.8= expected  1.39.8?:✅
+
Mediawiki Version 1.43.5= expected  1.43.5?:✅
Maria DB Version 10.11 fitting expected 10.11?:✅
+
Maria DB Version 11.4 fitting expected 11.4?:✅
4:checking 1.40.4 ...
+
4:checking 1.44.2 ...
mediawiki webserver container mw-140-mw:✅
+
mediawiki webserver container mw-144-mw:✅
mediawiki database container mw-140-db:✅
+
mediawiki database container mw-144-db:✅
 
port binding 9083= expected  port 9083?:✅
 
port binding 9083= expected  port 9083?:✅
Checking http://fixit.bitplan.com:9083/index.php/Special:Version ...
+
Checking http://noah.bitplan.com:9083/index.php?title=Special:Version ...
Special Version accessible ...:✅
 
Mediawiki Version 1.40.4= expected  1.40.4?:✅
 
Maria DB Version 10.11 fitting expected 10.11?:✅
 
5:checking 1.41.2 ...
 
mediawiki webserver container mw-141-mw:✅
 
mediawiki database container mw-141-db:✅
 
port binding 9084= expected  port 9084?:✅
 
Checking http://fixit.bitplan.com:9084/index.php/Special:Version ...
 
 
Special Version accessible ...:✅
 
Special Version accessible ...:✅
Mediawiki Version 1.41.2= expected  1.41.2?:✅
+
Mediawiki Version 1.44.2= expected  1.44.2?:✅
Maria DB Version 10.11 fitting expected 10.11?:✅
+
Maria DB Version 11.4 fitting expected 11.4?:✅
6:checking 1.42.1 ...
 
mediawiki webserver container mw-142-mw:✅
 
mediawiki database container mw-142-db:✅
 
port binding 9085= expected  port 9085?:✅
 
Checking http://fixit.bitplan.com:9085/index.php/Special:Version ...
 
Special Version accessible ...:✅
 
Mediawiki Version 1.42.1= expected  1.42.1?:✅
 
Maria DB Version 10.11 fitting expected 10.11?:✅
 
 
</source>
 
</source>
  
Line 319: Line 322:
 
<source lang='bash' highlight='1'>
 
<source lang='bash' highlight='1'>
 
mwcluster --down -f
 
mwcluster --down -f
running docker compose down for mediawiki versions ['1.35.13', '1.38.6', '1.39.8', '1.40.4', '1.41.2', '1.42.1']
 
 
running docker compose down for mw-135 1.35.13 docker application ...
 
running docker compose down for mw-135 1.35.13 docker application ...
[+] Running 6/6
+
[+] Running 7/7
  ✔ Container mw-135-mw      Removed                                      1.1s
+
  ✔ Container mw-135-mw      Removed                                      1.2s
  ✔ Container mw-135-db      Removed                                      0.5s
+
  ✔ Container mw-135-db      Removed                                      0.4s
✔ Volume mw-135_wiki-etc    Removed                                      0.3s
+
  ✔ Volume mw-135_mysql-data  Removed                                      0.0s
  ✔ Volume mw-135_mysql-data  Removed                                      0.3s
+
  ✔ Volume mw-135_wiki-etc    Removed                                      0.0s  
  ✔ Volume mw-135_wiki-www    Removed                                      0.3s
+
  ✔ Volume mw-135_wiki-sites Removed                                      0.0s  
✔ Network mw-135_default    Removed                                      0.1s
+
  ✔ Volume mw-135_wiki-html  Removed                                      0.4s  
running docker compose down for mw-138 1.38.6 docker application ...
+
  ✔ Network mw-135_default   Removed                                      0.2s
[+] Running 6/6
+
running docker compose down for mw-139 1.39.15 docker application ...
✔ Container mw-138-mw      Removed                                      1.2s
+
[+] Running 7/7
✔ Container mw-138-db      Removed                                      0.5s
 
✔ Volume mw-138_wiki-etc    Removed                                      0.0s  
 
  ✔ Volume mw-138_mysql-data Removed                                      0.0s  
 
  ✔ Volume mw-138_wiki-www    Removed                                      0.4s  
 
  ✔ Network mw-138_default   Removed                                      0.1s
 
running docker compose down for mw-139 1.39.8 docker application ...
 
[+] Running 6/6
 
 
  ✔ Container mw-139-mw      Removed                                      1.2s  
 
  ✔ Container mw-139-mw      Removed                                      1.2s  
 
  ✔ Container mw-139-db      Removed                                      0.5s  
 
  ✔ Container mw-139-db      Removed                                      0.5s  
  ✔ Volume mw-139_wiki-www    Removed                                      0.3s
+
  ✔ Volume mw-139_wiki-sites  Removed                                      0.0s
  ✔ Volume mw-139_wiki-etc    Removed                                      0.3s
+
  ✔ Volume mw-139_wiki-etc    Removed                                      0.0s
  ✔ Volume mw-139_mysql-data  Removed                                      0.3s
+
✔ Volume mw-139_wiki-html  Removed                                      0.5s
  ✔ Network mw-139_default    Removed                                      0.1s
+
  ✔ Volume mw-139_mysql-data  Removed                                      0.5s
running docker compose down for mw-140 1.40.4 docker application ...
+
  ✔ Network mw-139_default    Removed                                      0.2s
[+] Running 6/6
+
running docker compose down for mw-143 1.43.5 docker application ...
  ✔ Container mw-140-mw      Removed                                      1.2s
+
[+] Running 7/7
  ✔ Container mw-140-db      Removed                                      0.5s
+
  ✔ Container mw-143-mw      Removed                                      1.4s
  ✔ Volume mw-140_wiki-etc    Removed                                      0.0s  
+
  ✔ Container mw-143-db      Removed                                      0.6s
  ✔ Volume mw-140_mysql-data Removed                                      0.0s
+
  ✔ Volume mw-143_wiki-etc    Removed                                      0.0s  
  ✔ Volume mw-140_wiki-www    Removed                                      0.4s
+
  ✔ Volume mw-143_wiki-html  Removed                                      0.6s
  ✔ Network mw-140_default   Removed                                      0.1s
+
✔ Volume mw-143_wiki-sites Removed                                      0.6s
running docker compose down for mw-141 1.41.2 docker application ...
+
  ✔ Volume mw-143_mysql-data  Removed                                      0.6s
[+] Running 6/6
+
  ✔ Network mw-143_default   Removed                                      0.2s
  ✔ Container mw-141-mw      Removed                                      1.2s
+
running docker compose down for mw-144 1.44.2 docker application ...
  ✔ Container mw-141-db      Removed                                      0.5s  
+
[+] Running 7/7
  ✔ Volume mw-141_mysql-data  Removed                                      0.4s
+
  ✔ Container mw-144-mw      Removed                                      1.4s
  ✔ Volume mw-141_wiki-etc    Removed                                      0.4s
+
  ✔ Container mw-144-db      Removed                                      0.5s  
  ✔ Volume mw-141_wiki-www    Removed                                      0.4s
+
  ✔ Volume mw-144_wiki-html  Removed                                      0.6s
✔ Network mw-141_default    Removed                                      0.1s
+
  ✔ Volume mw-144_wiki-sites Removed                                      0.0s
running docker compose down for mw-142 1.42.1 docker application ...
+
  ✔ Volume mw-144_mysql-data  Removed                                      0.6s
[+] Running 6/6
+
  ✔ Volume mw-144_wiki-etc    Removed                                      0.6s
✔ Container mw-142-mw      Removed                                      1.2s
+
  ✔ Network mw-144_default   Removed                                      0.1s
✔ Container mw-142-db      Removed                                      0.5s
 
  ✔ Volume mw-142_wiki-www    Removed                                      0.4s
 
✔ Volume mw-142_mysql-data  Removed                                      0.0s
 
  ✔ Volume mw-142_wiki-etc    Removed                                      0.0s
 
  ✔ Network mw-142_default   Removed                                      0.1s
 
 
</source>
 
</source>
  
== Single 1.39.10 LTS ==
+
== Single 1.39.15 LTS ==
 
<source lang='bash' highlight="2">
 
<source lang='bash' highlight="2">
 
# python mwdocker/mwcluster.py  can be used instead of mwcluster if you test from your locally cloned environment
 
# python mwdocker/mwcluster.py  can be used instead of mwcluster if you test from your locally cloned environment
Line 376: Line 366:
 
   --create \
 
   --create \
 
   --forceRebuild\
 
   --forceRebuild\
   --version_list 1.39.10\
+
   --version_list 1.39.15\
 
   --base_port 8480\
 
   --base_port 8480\
   --sql_base_port 10306\
+
   --sql_base_port 10308\
   --mariaDBVersion 11.6\
+
   --mariaDBVersion 11.8\
 
   --container_name mw139lts\
 
   --container_name mw139lts\
 
   --logo https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Bigsmile_smiley_yellow_simple.svg/128px-Bigsmile_smiley_yellow_simple.svg.png
 
   --logo https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Bigsmile_smiley_yellow_simple.svg/128px-Bigsmile_smiley_yellow_simple.svg.png
 
creating docker compose applications for mediawiki versions ['1.39.10']
 
creating docker compose applications for mediawiki versions ['1.39.10']
starting mw139lts 1.39.10 docker application ...
+
starting mw139lts 1.39.15 docker application ...  
 
</source>
 
</source>
 
Mediawiki application will be available at
 
Mediawiki application will be available at
Line 389: Line 379:
 
[[File:pyMediaWikiDocker-ExampleMW135WithLogo.png|600px]]
 
[[File:pyMediaWikiDocker-ExampleMW135WithLogo.png|600px]]
  
== Single 1.35 with Semantic Mediawiki ==
+
== Single 1.35 with Semantic Mediawiki - deprecated ==
 
There might be more current versions of SMW available see https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki_Version_History and adapt
 
There might be more current versions of SMW available see https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki_Version_History and adapt
 
the example below if you see the need to do so.
 
the example below if you see the need to do so.
Line 494: Line 484:
 
<source lang='bash' higlight="1-3">
 
<source lang='bash' higlight="1-3">
 
pwd
 
pwd
/Users/***/.pymediawikidocker/mw1_35_2
+
/Users/***/.pymediawikidocker/mw-139
 
ls -l
 
ls -l
total 176
+
total 128
-rw-r--r-- 1 wf staff   1057 22 Jun 07:03 Dockerfile
+
-rwxrwxr-x 1 wf wf  349 Nov 18 12:40 addSysopUser.sh
-rw-r--r-- 1 wf  staff  4580 22 Jun 07:03 LocalSettings.php
+
-rw-rw-r-- 1 wf wf    23 Nov 18 12:40 composer.local.json
-rw-r--r-- 1 wf staff   1161 22 Jun 07:03 docker-compose.yml
+
-rwxrwxr-x 1 wf wf   465 Nov 18 12:40 disable_sudo.sh
-rw-r--r-- 1 wf  staff    317 22 Jun 07:03 initdb.sh
+
-rw-rw-r-- 1 wf wf  1952 Nov 18 12:40 docker-compose.yml
-rw-r--r--  1 wf staff    125 22 Jun 07:03 phpinfo.php
+
-rw-rw-r-- 1 wf wf  1410 Nov 18 12:40 Dockerfile
-rw-r--r-- 1 wf staff  64515 22 Jun 07:03 wiki.sql
+
-rwxrwxr-x 1 wf wf   153 Nov 18 12:40 install_djvu.sh
 +
-rwxrwxr-x 1 wf wf  1378 Nov 18 12:40 installExtensions.sh
 +
-rw-rw-r-- 1 wf wf  6905 Nov 18 12:40 LocalSettings.php
 +
-rw-rw-r-- 1 wf wf  1059 Nov 18 12:40 MwConfig.json
 +
-rw-rw-r-- 1 wf wf  267 Nov 18 12:40 phpinfo.php
 +
-rwxrwxr-x 1 wf wf 2339 Nov 18 12:40 plantuml.sh
 +
-rwxrwxr-x 1 wf wf 10491 Nov 18 12:40 setup-mediawiki.sh
 +
-rw-rw-r-- 1 wf wf  206 Nov 18 12:40 upload.ini
 +
-rw-rw-r-- 1 wf wf 64482 Nov 18 12:40 wiki.sql
 
</source>
 
</source>
 
== Check installed docker images ==
 
== Check installed docker images ==
 
<source lang='bash' highlight='1'>
 
<source lang='bash' highlight='1'>
docker images | grep mw
+
docker images | grep mw
mw-142-mw     latest   13e469c7d859  54 minutes ago      1.17GB
+
WARNING: This output is designed for human readability. For machine-readable output, please use --format.
mw-141-mw     latest   99578ea06019  55 minutes ago      1.2GB
+
mw-135-mw:latest       f4fac7e4ab24      1.58GB          347MB  U   
mw-140-mw     latest    d84a2410dbea  56 minutes ago      1.13GB
+
mw-139-mw:latest       998a1c08c2f0        1.9GB          411MB  U   
mw-139-mw     latest   f83c36dee73d   58 minutes ago      1.06GB
+
mw-143-mw:latest       12f3e2ba4d4a        2.1GB          458MB  U    
mw-138-mw     latest   8bfb68343139   59 minutes ago     1.03GB
+
mw-144-mw:latest        4a6a421be704      2.13GB         462MB  U   
mw-135-mw     latest   bf7ae8fe499c  About an hour ago  1.03GB
+
mw139-10lts-mw:latest  35aa59eb9dd2        1.9GB          411MB  U   
 +
mw139-11lts-mw:latest  71b736a6acff        1.9GB          411MB       
 +
mw139lts-mw:latest     8e83e31a47e1        1.9GB          411MB  U   
 +
smw4-mw:latest         10a6e1911648        1.9GB          411MB  U   
 
</source>
 
</source>
  
 
== Bash into docker containers ==
 
== Bash into docker containers ==
 
+
<source lang="bash" highlight='2-5,8-11'>
<source lang='bash' highlight='2-6,9-13'>
 
 
# Mediawiki container
 
# Mediawiki container
docker exec -it mw-142-mw /bin/bash
+
docker exec -it mw-144-mw /bin/bash
docker exec -it mw-141-mw /bin/bash
+
docker exec -it mw-143-mw /bin/bash
docker exec -it mw-140-mw /bin/bash
 
 
docker exec -it mw-139-mw /bin/bash
 
docker exec -it mw-139-mw /bin/bash
docker exec -it mw-138-mw /bin/bash
 
 
docker exec -it mw-135-mw /bin/bash
 
docker exec -it mw-135-mw /bin/bash
  
 
# MariaDB container
 
# MariaDB container
docker exec -it mw-142-db /bin/bash
+
docker exec -it mw-144-db /bin/bash
docker exec -it mw-141-db /bin/bash
+
docker exec -it mw-143-db /bin/bash
docker exec -it mw-140-db /bin/bash
 
 
docker exec -it mw-139-db /bin/bash
 
docker exec -it mw-139-db /bin/bash
docker exec -it mw-138-db /bin/bash
 
 
docker exec -it mw-135-db /bin/bash
 
docker exec -it mw-135-db /bin/bash
 +
</source>
 +
 
</source>
 
</source>
  

Latest revision as of 13:40, 19 November 2025

OsProject

OsProject
edit
id  pymediawikidocker
state  active
owner  WolfgangFahl
title  pymediawikidocker
url  https://github.com/WolfgangFahl/pymediawikidocker
version  0.22.1
description  Python controlled mediawiki docker image installation
date  2025-11-19
since  2021-06-08
until  

tickets

Motivation

Official Mediawiki docker images are available for the different Mediawiki versions.

These images need additional infrastructure to create useable Mediawiki environments.

docker run --name local-mediawiki -p 8080:80 -d mediawiki

will only install part of a LAMP environment to install Mediawiki and make it available via http://localhost:8080/. E.g. the database needs to be installed separately.

The goal of this project is to semi-automatically create such environments and test the functionality. Python was choosen as a development environment for the libraries that are needed and available to perform the tasks:

python on whales was chosen over:

Since it works on the command line interface and not via the SDK and supports docker compose.

How it works

The core concept is a "MediawikiCluster" that is a set of docker applications that run MediaWiki instances with varying versions of MediaWiki and the underlying database. The graphic belows shows the docker containers which are created for different versions of Mediawiki

Installation

Prerequisites

Docker on Windows, Mac or Linux suppporting "docker compose up" using the Docker composer V2 CLI

Ubuntu 24.04 LTS installation

see https://docs.docker.com/engine/install/ubuntu/ on how to setup the docker repository

sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
  sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
  https://download.docker.com/linux/ubuntu noble stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin
docker --version
Docker version 29.0.2, build 8108357
# Create the docker group if it does not exist
sudo groupadd docker 2>/dev/null || true
# Add your current user to the docker group
sudo usermod -aG docker "$USER"
docker run hello-world
Hello from Docker!

The "Hello from Docker" message shows that your installation appears to be working correctly.

Compatibility test

# test on a Mac OS machine 2022-07-02
docker 2>&1 | grep compose
  compose*    Docker Compose (Docker Inc., v2.4.1)
# test on an Ubuntu machine 2023-04-07
docker 2>&1 | grep compose
 compose*    Docker Compose (Docker Inc., v2.17.2)

Test of docker compose

No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 24.04.3 LTS
Release:	24.04
Codename:	noble

docker compose (not docker-compose)

docker compose version
Docker Compose version v2.40.3

pymediawikidocker installation via pip

pip install pymediawikidocker
# alternatively if your pip is not a python3 pip
pip3 install pymediawikidocker

upgrade

pip install pymediawikidocker -U
# alternatively if your pip is not a python3 pip
pip3 install pymediawikidocker -U

check version

mwcluster -V
pymediawikidocker 0.22.1 2025-11-18

Usage

usage: mwcluster [-h] [-a] [-d] [--debugLocalPath DEBUGLOCALPATH]
                 [--debugPort DEBUGPORT] [--debugRemotePath DEBUGREMOTEPATH]
                 [--debugServer DEBUGSERVER] [-f] [-q] [-v] [-V]
                 [--article_path ARTICLE_PATH] [-bm] [-cn CONTAINER_NAME]
                 [-dcn DB_CONTAINER_NAME] [-el [EXTENSIONNAMELIST ...]]
                 [-ej EXTENSIONJSONFILE] [--forceRebuild] [-fu] [--host HOST]
                 [-dp DOCKER_PATH] [--lenient] [--logo LOGO]
                 [-mv MARIADBVERSION] [--mysqlRootPassword MYSQLROOTPASSWORD]
                 [--mysqlPassword MYSQLPASSWORD] [-rp] [-p PASSWORD]
                 [-pl PASSWORD_LENGTH] [--prefix PREFIX] [--prot PROT]
                 [--script_path SCRIPT_PATH] [--url URL] [-sp SQL_PORT]
                 [-smw SMW_VERSION] [-u USER] [--uid UID] [--gid GID]
                 [-bp BASE_PORT] [-vl [VERSIONS ...]] [--create] [--down]
                 [--check] [--list]

Python controlled (semantic) mediawiki docker application cluster installation

options:
  -h, --help            show this help message and exit
  -a, --about           show version info and open documentation
  -d, --debug           enable debug output
  --debugLocalPath DEBUGLOCALPATH
                        remote debug Server path mapping - localPath - path on
                        machine where python runs
  --debugPort DEBUGPORT
                        remote debug Port [default: 5678]
  --debugRemotePath DEBUGREMOTEPATH
                        remote debug Server path mapping - remotePath - path
                        on debug server
  --debugServer DEBUGSERVER
                        remote debug Server
  -f, --force           force overwrite or unsafe actions
  -q, --quiet           suppress all output
  -v, --verbose         increase output verbosity
  -V, --version         show program's version number and exit
  --article_path ARTICLE_PATH
                        change to any article_path you might need to set
                        [default: ]
  -bm, --bind-mount     use bind mounts instead of volumes
  -cn CONTAINER_NAME, --container_name CONTAINER_NAME
                        set container name (only valid and recommended for
                        single version call)
  -dcn DB_CONTAINER_NAME, --db_container_name DB_CONTAINER_NAME
                        set database container name [default: None]
  -el [EXTENSIONNAMELIST ...], --extensionList [EXTENSIONNAMELIST ...]
                        list of extensions to be installed [default: ['Admin
                        Links', 'Header Tabs', 'ParserFunctions',
                        'SyntaxHighlight', 'Variables']]
  -ej EXTENSIONJSONFILE, --extensionJson EXTENSIONJSONFILE
                        additional extension descriptions default: [default:
                        None]
  --forceRebuild        force rebuilding [default: False]
  -fu, --force_user     force overwrite of wikiuser
  --host HOST           the host to serve / listen from [default:
                        noah.bitplan.com]
  -dp DOCKER_PATH, --docker_path DOCKER_PATH
                        the base directory to store docker and jinja template
                        files [default: /home/wf/.pymediawikidocker]
  --lenient             do not throw error on wikiuser difference
  --logo LOGO           set Logo [default:
                        $wgResourceBasePath/resources/assets/wiki.png]
  -mv MARIADBVERSION, --mariaDBVersion MARIADBVERSION
                        mariaDB Version to be installed [default: 11.4]
  --mysqlRootPassword MYSQLROOTPASSWORD
                        set sql root Password [default: None] - random
                        password if None
  --mysqlPassword MYSQLPASSWORD
                        set sql user Password [default: None] - random
                        password if None
  -rp, --random_password
                        create random password and create wikiuser while at it
  -p PASSWORD, --password PASSWORD
                        set password for initial user [default: sysop-1234!]
  -pl PASSWORD_LENGTH, --password_length PASSWORD_LENGTH
                        set the password length for random passwords[default:
                        15]
  --prefix PREFIX       the container name prefix to use [default: mw]
  --prot PROT           change to https in case [default: http]
  --script_path SCRIPT_PATH
                        change to any script_path you might need to set
                        [default: ]
  --url URL             will set prot host,script_path, and optionally port
                        based on the url given [default: None]
  -sp SQL_PORT, --sql_base_port SQL_PORT
                        set base mySql port 3306 to be exposed - incrementing
                        by one for each version [default: 9306]
  -smw SMW_VERSION, --smw_version SMW_VERSION
                        set SemanticMediaWiki Version to be installed default
                        is None - no installation of SMW
  -u USER, --user USER  set username of initial user with sysop rights
                        [default: Sysop]
  --uid UID             User ID (default: 33 for www-data)
  --gid GID             Group ID (default: 33 for www-data)
  -bp BASE_PORT, --base_port BASE_PORT
                        set how base html port 80 to be exposed - incrementing
                        by one for each version [default: 9080]
  -vl [VERSIONS ...], --version_list [VERSIONS ...]
                        mediawiki versions to create docker applications for
                        [default: ['1.35.13', '1.39.15', '1.43.5', '1.44.2']]
  --create
  --down
  --check
  --list

Examples

Pymediawikidocker_example_2022-10-26

create with default settings

Starts a cluster with versions 1.35.13,1.39.13, 1.43.2, and 1.44.0 using MariaDB 10.11. Essentially this is automatic generation of the configuration with a docker compose up for all versions asked for.

# force new user and random password
mwcluster --create -f -fu -rp
starting mw-135 1.35.13 docker application ...
...
starting mw-139 1.39.15 docker application ...
...
starting mw-143 1.43.5 docker application ...
...
starting mw-144 1.44.2 docker application ...
✔ Network mw-144_default    Created                                       0.1s 
 ✔ Volume mw-144_mysql-data  Created                                       0.0s 
 ✔ Volume mw-144_wiki-sites  Created                                       0.0s 
 ✔ Volume mw-144_wiki-etc    Created                                       0.0s 
 ✔ Volume mw-144_wiki-html   Created                                       0.0s 
 ✔ Container mw-144-db       Started                                       5.4s 
 ✔ Container mw-144-mw       Started                                       4.1s 
mw-144-mw 🟢 started in 0.01s
mw-144-db 🟢 started in 0.01s
Initializing MediaWiki SQL tables ...
...
Starting periodic command scheduler: cron.
MediaWiki setup complete!
MediaWiki mw-144 is ready at ...

Mediawiki applications will be available at

http://localhost:9080 http://localhost:9080/index.php/Special:Version

http://localhost:9081 http://localhost:9081/index.php/Special:Version

http://localhost:9082 http://localhost:9082/index.php/Special:Version

http://localhost:9083 http://localhost:9083/index.php/Special:Version

check

mwcluster --check -f
1:checking 1.35.13 ...
mediawiki webserver container mw-135-mw:✅
mediawiki database container mw-135-db:✅
port binding 9080= expected  port 9080?:✅
Checking http://noah.bitplan.com:9080/index.php?title=Special:Version ...
Special Version accessible ...:✅
Mediawiki Version 1.35.13= expected  1.35.13?:✅
Maria DB Version 11.4 fitting expected 11.4?:✅
2:checking 1.39.15 ...
mediawiki webserver container mw-139-mw:✅
mediawiki database container mw-139-db:✅
port binding 9081= expected  port 9081?:✅
Checking http://noah.bitplan.com:9081/index.php?title=Special:Version ...
Special Version accessible ...:✅
Mediawiki Version 1.39.15= expected  1.39.15?:✅
Maria DB Version 11.4 fitting expected 11.4?:✅
3:checking 1.43.5 ...
mediawiki webserver container mw-143-mw:✅
mediawiki database container mw-143-db:✅
port binding 9082= expected  port 9082?:✅
Checking http://noah.bitplan.com:9082/index.php?title=Special:Version ...
Special Version accessible ...:✅
Mediawiki Version 1.43.5= expected  1.43.5?:✅
Maria DB Version 11.4 fitting expected 11.4?:✅
4:checking 1.44.2 ...
mediawiki webserver container mw-144-mw:✅
mediawiki database container mw-144-db:✅
port binding 9083= expected  port 9083?:✅
Checking http://noah.bitplan.com:9083/index.php?title=Special:Version ...
Special Version accessible ...:✅
Mediawiki Version 1.44.2= expected  1.44.2?:✅
Maria DB Version 11.4 fitting expected 11.4?:✅

down

mwcluster --down -f
running docker compose down for mw-135 1.35.13 docker application ...
[+] Running 7/7
 ✔ Container mw-135-mw       Removed                                       1.2s 
 ✔ Container mw-135-db       Removed                                       0.4s 
 ✔ Volume mw-135_mysql-data  Removed                                       0.0s 
 ✔ Volume mw-135_wiki-etc    Removed                                       0.0s 
 ✔ Volume mw-135_wiki-sites  Removed                                       0.0s 
 ✔ Volume mw-135_wiki-html   Removed                                       0.4s 
 ✔ Network mw-135_default    Removed                                       0.2s 
running docker compose down for mw-139 1.39.15 docker application ...
[+] Running 7/7
 ✔ Container mw-139-mw       Removed                                       1.2s 
 ✔ Container mw-139-db       Removed                                       0.5s 
 ✔ Volume mw-139_wiki-sites  Removed                                       0.0s 
 ✔ Volume mw-139_wiki-etc    Removed                                       0.0s 
 ✔ Volume mw-139_wiki-html   Removed                                       0.5s 
 ✔ Volume mw-139_mysql-data  Removed                                       0.5s 
 ✔ Network mw-139_default    Removed                                       0.2s 
running docker compose down for mw-143 1.43.5 docker application ...
[+] Running 7/7
 ✔ Container mw-143-mw       Removed                                       1.4s 
 ✔ Container mw-143-db       Removed                                       0.6s 
 ✔ Volume mw-143_wiki-etc    Removed                                       0.0s 
 ✔ Volume mw-143_wiki-html   Removed                                       0.6s 
 ✔ Volume mw-143_wiki-sites  Removed                                       0.6s 
 ✔ Volume mw-143_mysql-data  Removed                                       0.6s 
 ✔ Network mw-143_default    Removed                                       0.2s 
running docker compose down for mw-144 1.44.2 docker application ...
[+] Running 7/7
 ✔ Container mw-144-mw       Removed                                       1.4s 
 ✔ Container mw-144-db       Removed                                       0.5s 
 ✔ Volume mw-144_wiki-html   Removed                                       0.6s 
 ✔ Volume mw-144_wiki-sites  Removed                                       0.0s 
 ✔ Volume mw-144_mysql-data  Removed                                       0.6s 
 ✔ Volume mw-144_wiki-etc    Removed                                       0.6s 
 ✔ Network mw-144_default    Removed                                       0.1s

Single 1.39.15 LTS

# python mwdocker/mwcluster.py  can be used instead of mwcluster if you test from your locally cloned environment
mwcluster \
  --create \
  --forceRebuild\
  --version_list 1.39.15\
  --base_port 8480\
  --sql_base_port 10308\
  --mariaDBVersion 11.8\
  --container_name mw139lts\
  --logo https://upload.wikimedia.org/wikipedia/commons/thumb/f/f9/Bigsmile_smiley_yellow_simple.svg/128px-Bigsmile_smiley_yellow_simple.svg.png
creating docker compose applications for mediawiki versions ['1.39.10']
starting mw139lts 1.39.15 docker application ...

Mediawiki application will be available at

http://localhost:8480 http://localhost:8480/index.php/Special:Version PyMediaWikiDocker-ExampleMW135WithLogo.png

Single 1.35 with Semantic Mediawiki - deprecated

There might be more current versions of SMW available see https://www.semantic-mediawiki.org/wiki/Semantic_MediaWiki_Version_History and adapt the example below if you see the need to do so.

Version 4.1.2

mwcluster \
  --create \
  --container_name smw4\
  --forceRebuild\
  --version_list 1.35.13\
  --base_port 8481\
  --sql_base_port 10307\
  --mariaDBVersion 10.11\
  --smw_version 4.1.2
creating docker compose applications for mediawiki versions ['1.35.13']
starting smw4 1.35.13 docker application ...

debug docker compose results - ports and other configuration parts

cd ~/.pymediawikidocker/smw4
docker-compose up
# in another terminal session:
docker ps
CONTAINER ID   IMAGE                   COMMAND                  CREATED              STATUS         PORTS                     NAMES
87a795d444eb   smw4_mw                 "docker-php-entrypoi…"   About a minute ago   Up 7 seconds   0.0.0.0:8481->80/tcp      smw4-mw
7ca3a0434d31   mariadb:10.11           "docker-entrypoint.s…"   About a minute ago   Up 7 seconds   0.0.0.0:10307->3306/tcp   smw4-db

open bash in docker container

docker exec -it smw4-mw /bin/bash
root@87a795d444eb:/var/www/html#

check installExtensions.sh script

cat /root/installExtensions.sh 
#!/bin/bash
# install the required extensions
# WF 2021-06-23
cd /var/www/html/extensions

# Admin Links
# https://www.mediawiki.org/wiki/Extension:Admin_Links
git clone https://github.com/wikimedia/mediawiki-extensions-AdminLinks --single-branch --branch REL1_35 AdminLinks

# Header Tabs
# https://www.mediawiki.org/wiki/Extension:Header_Tabs
git clone https://github.com/wikimedia/mediawiki-extensions-HeaderTabs --single-branch --branch REL1_35 HeaderTabs

# SyntaxHighlight
# https://www.mediawiki.org/wiki/Extension:SyntaxHighlight
# no installation script command specified

# Variables
# https://www.mediawiki.org/wiki/Extension:Variables
git clone https://github.com/wikimedia/mediawiki-extensions-Variables --single-branch --branch REL1_35 Variables

check Semantic MediaWiki settings in LocalSettings.php

grep -i semantic LocalSettings.php 
# enable Support for Semantic MediaWiki
# see https://www.semantic-mediawiki.org/wiki/Help:EnableSemantics
# Version of SemanticMediaWiki at install time: 4.1.1
wfLoadExtension( 'SemanticMediaWiki' );
enableSemantics();
# https://www.semantic-mediawiki.org/wiki/Help:$smwgQMaxInlineLimit

SMW Version 3.2.3

Installation

mwcluster \
  --create \
  --container_name smw3\
  --forceRebuild\
  --version_list 1.35.13\
  --base_port 8482\
  --sql_base_port 10308\
  --mariaDBVersion 10.11\
  --logo https://www.semantic-mediawiki.org/w/images/4/4e/SMW_logo_180.png\
  --smw_version 3.2.3

Check

mwcluster --check --container_name smw3 --version_list 1.35.13

Down

mwcluster --down --container_name smw3 --version_list 1.35.13 -f
running docker compose down for mediawiki versions ['1.35.13']
running docker compose down for smw3 1.35.10 docker application ...
[+] Running 3/3
 ⠿ Volume smw3_wiki-etc    Removed                                0.0s
 ⠿ Volume smw3_mysql-data  Removed                                0.1s
 ⠿ Volume smw3_wiki-www    Removed                                1.2s

Extensions

see Pymediawikidocker/Extensions

Debugging

Docker files

You'll find the files created by pymediawikidocker in ".pymediawikidocker" in your homedirectory.

pwd
/Users/***/.pymediawikidocker/mw-139
ls -l
total 128
-rwxrwxr-x 1 wf wf   349 Nov 18 12:40 addSysopUser.sh
-rw-rw-r-- 1 wf wf    23 Nov 18 12:40 composer.local.json
-rwxrwxr-x 1 wf wf   465 Nov 18 12:40 disable_sudo.sh
-rw-rw-r-- 1 wf wf  1952 Nov 18 12:40 docker-compose.yml
-rw-rw-r-- 1 wf wf  1410 Nov 18 12:40 Dockerfile
-rwxrwxr-x 1 wf wf   153 Nov 18 12:40 install_djvu.sh
-rwxrwxr-x 1 wf wf  1378 Nov 18 12:40 installExtensions.sh
-rw-rw-r-- 1 wf wf  6905 Nov 18 12:40 LocalSettings.php
-rw-rw-r-- 1 wf wf  1059 Nov 18 12:40 MwConfig.json
-rw-rw-r-- 1 wf wf   267 Nov 18 12:40 phpinfo.php
-rwxrwxr-x 1 wf wf  2339 Nov 18 12:40 plantuml.sh
-rwxrwxr-x 1 wf wf 10491 Nov 18 12:40 setup-mediawiki.sh
-rw-rw-r-- 1 wf wf   206 Nov 18 12:40 upload.ini
-rw-rw-r-- 1 wf wf 64482 Nov 18 12:40 wiki.sql

Check installed docker images

 docker images | grep mw
WARNING: This output is designed for human readability. For machine-readable output, please use --format.
mw-135-mw:latest        f4fac7e4ab24       1.58GB          347MB   U    
mw-139-mw:latest        998a1c08c2f0        1.9GB          411MB   U    
mw-143-mw:latest        12f3e2ba4d4a        2.1GB          458MB   U    
mw-144-mw:latest        4a6a421be704       2.13GB          462MB   U    
mw139-10lts-mw:latest   35aa59eb9dd2        1.9GB          411MB   U    
mw139-11lts-mw:latest   71b736a6acff        1.9GB          411MB        
mw139lts-mw:latest      8e83e31a47e1        1.9GB          411MB   U    
smw4-mw:latest          10a6e1911648        1.9GB          411MB   U

Bash into docker containers

# Mediawiki container
docker exec -it mw-144-mw /bin/bash
docker exec -it mw-143-mw /bin/bash
docker exec -it mw-139-mw /bin/bash
docker exec -it mw-135-mw /bin/bash

# MariaDB container
docker exec -it mw-144-db /bin/bash
docker exec -it mw-143-db /bin/bash
docker exec -it mw-139-db /bin/bash
docker exec -it mw-135-db /bin/bash

</source>

Monkey patching

# Enable raw html in for the wiki
docker exec  mw1_35_8-mw sh -c "echo '\$wgRawHtml = true;\n' >> /var/www/html/LocalSettings.php"

No space left on device issue

e.g. when starting mariadb container see https://stackoverflow.com/questions/37645879/how-can-i-fix-docker-mac-no-space-left-on-device-error

Wiki Backup

The passwords are available from the docker files e.g.

grep PASS docker-compose.yml 
      MYSQL_PASSWORD: "TnbKf2zGRmZPjUvz7B"
      MYSQL_ROOT_PASSWORD: "QWehnR9yLMY7YAb9pw"

In a docker bash a dump can be created

mysqldump wiki -u wikiuser --password=TnbKf2zGRmZPjUvz7B > /tmp/wiki.sql

and then copied to your local machine

docker cp mw1_36_0_db_1:/tmp/wiki.sql /tmp

Docker cleanup procedure

#!/bin/bash
# WF 2023-04-08
# 
# ⚠️ ⚠️ ⚠️ 
#
#  kids  don't do this at home ...
#
# ⚠️ These commands will stop and remove all running docker containers (not only the ones created pymediawikidocker/the mwcluster command) 
# kill/stop all running containers
docker kill $(docker ps -q)
#docker stop $(docker ps -aq)
# remove all docker containers
docker rm $(docker ps -aq)
# remove all images
# ⚠️ This command will remove all your images not only the ones created by pymediawikidocker (docker will hopefully refuse to do this without the -f option) 
docker rmi $(docker images -q)
# ⚠️ these commands will remove all your volumes - you might loose valuable data if you don't check what your volumes contain before starting this command 
# see https://stackoverflow.com/a/46091568/1497139
docker volume rm $(docker volume ls -qf dangling=true | xargs)
#⚠️ WARNING! This will remove:
#  - all stopped containers
#  - all networks not used by at least one container
#  - all dangling images
#  - all dangling build cache
docker system prune --force

Links