Page MenuHomePhabricator

Docker MW installation command line doesn't work on Windows command shell or PowerShell
Closed, ResolvedPublic

Description

This command line given in DEVELOPERS.md doesn't work on a Windows 10 host:

docker-compose exec mediawiki \
bash -c 'php maintenance/install.php \
--server $MW_SERVER \
--scriptpath=$MW_SCRIPTPATH \
--dbtype $MW_DBTYPE \
--dbpath $MW_DBPATH \
--lang $MW_LANG \
--pass $MW_PASS \
$MW_SITENAME $MW_USER'

I've tried replacing the backslashes with backticks for line continuations in PowerShell, but no combination I've tried works out so far. Additionally the variables seem to get interpolated early in the shell, and I'm having trouble figuring out how to get them correctly tuned to get interpolated in the bash command only with no luck so far.

Workaround:

Copy-paste the bash command line (minus the "docker-compose" line) into a file install.sh, eg:

#!/bin/sh
bash -c 'php maintenance/install.php \
--server $MW_SERVER \
--scriptpath=$MW_SCRIPTPATH \
--dbtype $MW_DBTYPE \
--dbpath $MW_DBPATH \
--lang $MW_LANG \
--pass $MW_PASS \
$MW_SITENAME $MW_USER'

and then run from the Windows shell:

docker-compose exec mediawiki ./install.sh

Event Timeline

Change 584111 had a related patch set uploaded (by Kosta Harlan; owner: Kosta Harlan):
[releng/dev-images@master] Add install script to work around shell issues

https://gerrit.wikimedia.org/r/584111

kostajh moved this task from Backlog to In Progress on the MediaWiki-Docker board.
kostajh added a project: User-kostajh.

Change 584119 had a related patch set uploaded (by Kosta Harlan; owner: Kosta Harlan):
[mediawiki/core@master] [docker] Update install instructions

https://gerrit.wikimedia.org/r/584119

brennen triaged this task as High priority.Apr 1 2020, 4:14 PM
brennen added a project: User-brennen.
brennen moved this task from Backlog to Needs/Waiting Response on the User-brennen board.

Change 584111 merged by Brennen Bearnes:
[releng/dev-images@master] Add install script to work around shell issues

https://gerrit.wikimedia.org/r/584111

Mentioned in SAL (#wikimedia-releng) [2020-04-03T20:30:17Z] <brennen> Updating dev-images docker-pkg files on contint1001 for T246953

Change 584119 merged by jenkins-bot:
[mediawiki/core@master] [docker] Use install.sh, add instructions for same

https://gerrit.wikimedia.org/r/584119

@brion when you have a moment, would you mind re-testing the install on a Windows setup (probably in a new directory + new clone of mediawiki/core to make your life easier)? Thanks!

The instructions to create an .env file from a bash command fail in both PowerShell and CMD.exe... There is a mention of a /docker/install.sh file later in the instructions but I don't know where it's supposed to come from?

The instructions to create an .env file from a bash command fail in both PowerShell and CMD.exe.

Ah. Hmm. Maybe it's easier to just say "Create a file called .env and put these contents in it."

docker-compose exec mediawiki /bin/bash /docker/install.sh

That runs /bin/bash /docker/install.sh inside the container; install.sh is a script we added to the docker image to avoid needing to pass the bash variables.

I presume I have to create an .env file in some other way, like using a text editor? Ideally there should be a ready-to-copy-and-paste chunk of text that requires no execution in a platform-specific shell. What should I use for MW_DOCKER_UID and MW_DOCKER_GID? UID and GID are Unix-specific concepts and I don't know if they have any meaning in Windows?

Change 586428 had a related patch set uploaded (by Kosta Harlan; owner: Kosta Harlan):
[mediawiki/core@master] [docker] Fix install instructions for Windows

https://gerrit.wikimedia.org/r/586428

Change 586428 merged by jenkins-bot:
[mediawiki/core@master] [docker] Fix install instructions for Windows

https://gerrit.wikimedia.org/r/586428

Now works as written. :D