This is a sample code to create a moodle plugin development environment with vscode remote containers. The plugin is a sample that adds a static HTML block. Based on moodle plugin development guide.
DevContainer packed with:
- Docker image for moodle plugin development with php,composer,xdebug,phpcs preconfigured.
- Maria db container with persistent volumes.
- Preconfigured remote debugging with xdebug on vscode.
- Preconfigured linter and formatter by phpcs configured for moodle based on moodle-local_codechecker.
- phpMyAdmin manipulating a moodle db.
- Clone repository
$ git clone https://github.com/aoisupersix/moodle-plugin-devcontainer
$ code moodle-plugin-devcontainer/
-
Run
Extensions: Configure Recommended Extensions (Workspace Folder)
from the vscode command palette -
Run
Remote-Containers: Open Workspace in Container...
from the vscode command palette -
Open
http://localhost:8080
and do the moodle installation
Select XDebug on DevContainer
from RUN AND DEBUG
on vscode.
Open http://localhost:8081
Change the MOODLE_VERSION
in .devcontainer/docker-compose.yml
args:
- MOODLE_VERSION=${moodle_version}
Change directory path of the following properties↓
workspaceFolder
in .devcontainer/devcontainer.json
"workspaceFolder": "/var/www/html/${plugin_type}/${plugin_name}",
volumes
in .devcontainer/docker-compose.yml
volumes:
- './php.ini:/usr/local/etc/php/php.ini'
- './container-volumes/moodledata_data:/var/www/moodledata'
- '..:/var/www/html/${plugin_type}/${plugin_name}:cached'
pathMappings
in .vscode/launch.json
"pathMappings": {
"/var/www/html/${plugin_type}/${plugin_name}": "${workspaceFolder}"
}
Change .devcontainer/moodle/config.php
Change .devcontainer/moodle/Dockerfile
# Set timezone
ENV TZ Asia/Tokyo
RUN echo "${TZ}" > /etc/timezone \
&& dpkg-reconfigure -f noninteractive tzdata
# Set locale
RUN echo 'ja_JP.UTF-8 UTF-8' >> /etc/locale.gen \
&& locale-gen \
&& update-locale LANG=ja_JP.UTF-8
rm -rf .devcontainer/container-volumes