Cli/guide/Docker-Development-Environment/First-Setup

mwcli contains a MediaWiki-Docker-Dev like developer environment.

If you haven't used this development environment before, then this is the guide for you!

If you already have a LocalSettings.php file from a previous developer environment and want to copy settings across please read this guide

If you don't have docker installed, you should install that.

If you are on an older docker version (pre-April 2022) you may also need to install docker-compose. And if you are on Linux, you'll need some additional security configuration to be able to run docker without sudo. As of docker 19.3, this is not required, see this askubuntu thread for details (and follow the linux postinstall instructions).

MediaWiki services

edit

Let's begin with a basic MediaWiki installation and then create the necessary services.

mw docker mediawiki create

You will be guided through a setup wizard that covers:

  • The port the development environment should run on.
  • The location to store the MediaWiki code (new or existing directory).
  • Cloning the MediaWiki code (if missing).
  • Cloning the Vector skin (if missing).
  • Options for cloning the code (Github or Gerrit; shallow or regular; over ssh or http).

After you make these choices, the setup wizard will clone the necessary code.

Here's a replay of the wizard:

 

If you run into a docker.errors.DockerException error, make sure that you are in the docker group using sudo gpasswd -a $USER docker. Then run the mw docker mediawiki create command again.

Once the install is complete, you should be able to see a few running services by executing this command:

mw docker docker-compose ps

You should see output that looks something like this:

               Name                             Command               State               Ports
------------------------------------------------------------------------------------------------------------
mwcli-mwdd-default_dps_1             /app/dns-proxy-server            Up
mwcli-mwdd-default_mediawiki-web_1   /bin/bash /entrypoint.sh         Up      8080/tcp
mwcli-mwdd-default_mediawiki_1       /mwdd/entrypoint.sh              Up      9000/tcp
mwcli-mwdd-default_nginx-proxy_1     /app/docker-entrypoint.sh  ...   Up      80/tcp, 0.0.0.0:8080->8080/tcp

Database

edit

mwcli can use a variety of databases, but for the purposes of this setup guide, we will focus on MySQL.

You can start a MySQL service for MediaWiki by executing the following command:

mw docker mysql create

As before, using mw docker docker-compose ps, you should see some new services running:

          Name                              Command                State               Ports
------------------------------------------------------------------------------------------------------------
...
mwcli-mwdd-default_mysql-replica_1  /mwdd-custom/entrypoint.sh ...   Exit 255   3306/tcp
mwcli-mwdd-default_mysql_1          /mwdd-custom/entrypoint.sh ...   Up         3306/tcp

You'll see that the mysql-replica service has exited, which is just as expected.

MediaWiki installation

edit

The development environment automatically sets various MediaWiki settings, such as database details.

In a fresh install, the setup wizard handles this during installation.

If you have an existing LocalSettings.php, please read this guide.

Install MediaWiki with a MySQL backend using the following command:

mw docker mediawiki install --dbtype=mysql

This will:

  • Prompt to create a LocalSettings.php file (if needed)
  • Run a Composer install if needed
  • Run MediaWiki's install.php script to create database tables
  • Run MediaWiki's update.php to perform any needed updates

When the installer is finished, you will see output that guides you to the login page of your new wiki.

Done in 1.7 s.

***************************************
Installation successful 🎉
User: admin
Pass: mwddpassword
Link: http://default.mediawiki.mwdd.localhost:8080

If you want to access the wiki from your command line you may need to add it to your hosts file.
You can do this with the `hosts add` command that is part of this development environment.
***************************************

You can now log in to your new instance of MediaWiki.

 
Screenshot of a running MediaWiki installation using mwcli