This repository contains Docker configuration aimed at Moodle developers and testers to easily deploy a testing environment for Moodle.
- All supported database servers (PostgreSQL, MySQL, Micosoft SQL Server, Oracle XE)
- Behat/Selenium configuration for Firefox and Chrome
- Catch-all smtp server and web interface to messages using MailHog
- All PHP Extensions enabled configured for external services (e.g. solr, ldap)
- All supported PHP versions
- Zero-configuration approach
- Backed by automated tests
- Docker and Docker Compose installed
- 3.25GB of RAM (to run Microsoft SQL Server)
# Set up path to code and choose a db server (pgsql/mssql/oracle/mysql)
export MOODLE_DOCKER_WWWROOT=/path/to/moodle/code
export MOODLE_DOCKER_DB=mssql
# Ensure config.php is in place
cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php
# Start up containers
bin/moodle-docker-compose up -d
# Run behat tests..
bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php
# [..]
bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/run.php --tags=@auth_manual
Running single behat site:
Moodle 3.3rc1 (Build: 20170505), 381db2fe8df5c381f633fa2a92e61c6f0d7308cb
Php: 7.1.5, sqlsrv: 14.00.0500, OS: Linux 4.9.13-moby x86_64
Server OS "Linux", Browser: "firefox"
Started at 25-05-2017, 19:04
...............
2 scenarios (2 passed)
15 steps (15 passed)
1m35.32s (41.60Mb)
# Install for manual testing (optional)
bin/moodle-docker-compose exec webserver php admin/cli/install_database.php --agree-license --fullname="Docker moodle" --shortname="docker_moodle" --adminpass="test" --adminemail="admin@example.com"
# Access http://localhost:8000/ on your browser
# Shut down containers
bin/moodle-docker-compose down
Note that the behat faildump directory is exposed at http://localhost:8000/_/faildumps/.
Moodle is configured to listen on http://localhost:8000/
and mailhog is listening on http://localhost:8000/_/mail
to view emails which Moodle has sent out.
This repo uses branches to accomodate different php versions as well as some of the higher/lower versions of PostgreSQL/MySQL:
Branch Name | PHP Version | Build Status | Notes |
---|---|---|---|
master | 7.1.x | Same as branch php71 | |
php71 | 7.1.x | ||
php70 | 7.0.x | ||
php56 | 5.6.x |
As can be seen in bin/moodle-docker-compose, this repo is just a series of docker-compose configurations and light wrapper which make use of companion docker images. Each part is designed to be reusable and you are encouraged to use the docker[-compose] commands as needed.
The following Moodle customised docker images are close companions of this project:
- moodle-apache-php: Apache/PHP Environment preconfigured for all Moodle environments
- moodle-db-mssql: Microsoft SQL Server for Linux configured for Moodle
- moodle-db-oracle: Oracle XE configured for Moodle
You can change the configuration of the docker images by setting various environment variables before calling bin/moodle-docker-compose up
.
Environment Variable | Options | Notes |
---|---|---|
MOODLE_DOCKER_DB |
pgsql, mariadb, mysql, mssql, oracle | Database server to run agianst |
MOODLE_DOCKER_WWWROOT |
Path on your file system | The path to the Moodle codebase you intend to test. |
MOODLE_DOCKER_BROWSER |
firefox, chrome | The browser to run Behat against |
MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES |
Empty, or set | If set, dependencies for memcached, redis, solr, and openldap are added |
MOODLE_DOCKER_WEB_PORT |
Empty, or set to an integer | Used as the port number for web. If set to 0, no port is used (default 8000) |
Are extremely welcome!