MediaWiki-Docker/Configuration recipes/Dev containers
![]() | This page is under construction Please help review and edit this page. |
Dev containers is a specification for creating and executing development environments inside of containers. This page details how to instantiate a dev container for MediaWiki with IDEs that support it.
Visual Studio Code
- Down all docker containers inside the repo:
docker compose down
. - Install the Dev Containers extension.
- Create a
devcontainers.json
file:- Open the command palette and search "Reopen in container".
- Select "From 'docker-compose.yml'".
- Choose the "mediawiki" service.
- Choose which tools to add.
- Skip adding any optional files or directories.
- The container will fail to open. This is because a specific devcontainer.json file is needed for the IDE.
- Copy and paste the following into your
devcontainers.json
file:// For format details, see https://aka.ms/devcontainer.json. For config options, see the // README at: https://github.com/devcontainers/templates/tree/main/src/docker-existing-docker-compose { "name": "MediaWiki Core", // Update the 'dockerComposeFile' list if you have more compose files or use different names. // The .devcontainer/docker-compose.yml file contains any overrides you need/want to make. "dockerComposeFile": [ "../docker-compose.yml", "../docker-compose.override.yml", "docker-compose.yml" ], // The 'service' property is the name of the service for the container that VS Code should // use. Update this value and .devcontainer/docker-compose.yml to the real service name. "service": "mediawiki", // The optional 'workspaceFolder' property is the path VS Code should open by default when // connected. This is typically a file mount in .devcontainer/docker-compose.yml "workspaceFolder": "/var/www/html/w", // Features to add to the dev container. More info: https://containers.dev/features. // "features": {}, // Use 'forwardPorts' to make a list of ports inside the container available locally. "forwardPorts": [ 9003 ], // Uncomment the next line if you want start specific services in your Docker Compose config. // "runServices": [], // Uncomment the next line if you want to keep your containers running after VS Code shuts down. // "shutdownAction": "none", // Uncomment the next line to run commands after the container is created. "postCreateCommand": "composer update\n/docker/install.sh\nchmod -R o+rwx cache/sqlite", // Configure tool-specific properties. "customizations": { "vscode": { "settings": { "terminal.integrated.defaultProfile.linux": "bash" }, "extensions": [ "xdebug.php-debug" ] } }, // Container environment variables. "containerEnv": { "MW_SCRIPT_PATH": "/w", "MW_SERVER": "http://localhost:8080", "MW_DOCKER_PORT": "8080", "MEDIAWIKI_USER": "Admin", "MEDIAWIKI_PASSWORD": "dockerpass", "XDEBUG_CONFIG": "mode=debug start_with_request=yes discover_client_host=1", "XDEBUG_MODE": "debug", "XDEBUG_ENABLE": "true", "XDEBUG_TRIGGER": "1", "XHPROF_ENABLE": "true" }, // Uncomment to connect as an existing user other than the container default. More info: https://aka.ms/dev-containers-non-root. "remoteUser": "www-data" }
- Make sure you still have a
.env
file set with just theMW_DOCKER_UID
andMW_DOCKER_GID
set up. - Create a
launch.json
that you can use to connect to Xdebug. - It is best to use the operating system the dev container is located in to make and submit reviews to Gerrit.