Page MenuHomePhabricator

Add .env file creation to docker start command
Closed, ResolvedPublic

Description

If there is no .env file in the mediawiki/core repository, the docker start command should create a default .env file.

Acceptance Criteria:

  • Docker start checks for existence of .env file and creates it if it doesn't exist.
    • The default .env file contains the following:
MW_DOCKER_PORT=8080
MW_SCRIPT_PATH=/
MW_SERVER=http://localhost:8080
MEDIAWIKI_USER=Admin
MEDIAWIKI_PASSWORD=dockerpass
XDEBUG_CONFIG=''
  • For Linux users, the user ID and group ID should be added to the .env file as MW_DOCKER_UID and MW_DOCKER_GID

Event Timeline

Why would the user set the environment variables and not set a LocalSettings.php ?

Why would the user set the environment variables and not set a LocalSettings.php ?

+1 any mediawiki settings should just be set in LocalSettings.

However I think there is still a case for creating a default .env file the first time start is run.
This is similar behaviour to mwdd-v1 which will create a .env file for you initially
https://github.com/addshore/mediawiki-docker-dev/blob/v1/control/src/Files/DotEnv.php#L43-L65
This currently still uses 2 separate env files (default and user provided) merging them together into one at runtime.

In my attempted go port this can be seen in the first couple of methods at https://gerrit.wikimedia.org/r/c/mediawiki/tools/cli/+/597864/9/env/env.go

Why would the user set the environment variables and not set a LocalSettings.php ?

A few reasons:

I agree that some of these things should live in .env and be used an env vars.
I think any further mediawiki customizations should be done in LS.php directly though.
This minimizes the complexity and responsibilities of the development environment.

Looking at mwdd-v1 only things relating to the dev environment are in the .env https://github.com/addshore/mediawiki-docker-dev/blob/4d380cf638bc60b5b6c22853a199639a3eb70b0b/default.env
Mediawiki configuration happens the normal way (this also stops people from needing to know and learn 2 different ways of interacting with these things)

thcipriani assigned this task to Addshore.