Skip to content

Commit

Permalink
add support for database versions
Browse files Browse the repository at this point in the history
  • Loading branch information
skodak committed Oct 6, 2022
1 parent b88d66d commit a0cc379
Show file tree
Hide file tree
Showing 11 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ When you change them, use `bin/moodle-docker-compose down && bin/moodle-docker-c
|-------------------------------------------|-----------|---------------------------------------|---------------|------------------------------------------------------------------------------|
| `MOODLE_DOCKER_DB` | yes | pgsql, mariadb, mysql, mssql, oracle | none | The database server to run against |
| `MOODLE_DOCKER_WWWROOT` | yes | path on your file system | none | The path to the Moodle codebase you intend to test |
| `MOODLE_DOCKER_DB_VERSION` | no | Docker tag - see relevant database page on docker-hub | mysql: 5.7 <br/>pgsql: 12 <br/>mariadb: 10.7 <br/>mssql: 2017-latest <br/>oracle: 21| The database server docker image tag |
| `MOODLE_DOCKER_PHP_VERSION` | no | 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6 | 7.4 | The php version to use |
| `MOODLE_DOCKER_BROWSER` | no | firefox, chrome, firefox:&lt;tag&gt;, chrome:&lt;tag&gt; | firefox:3 | The browser to run Behat against. Supports a colon notation to specify a specific Selenium docker image version to use. e.g. firefox:2.53.1 can be used to run with older versions of Moodle (<3.5) |
| `MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES` | no | any value | not set | If set, dependencies for memcached, redis, solr, and openldap are added |
Expand Down
7 changes: 0 additions & 7 deletions base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,11 @@ services:
- "${MOODLE_DOCKER_WWWROOT}:/var/www/html"
- "${ASSETDIR}/web/apache2_faildumps.conf:/etc/apache2/conf-enabled/apache2_faildumps.conf"
environment:
MOODLE_DOCKER_DBTYPE: pgsql
MOODLE_DOCKER_DBNAME: moodle
MOODLE_DOCKER_DBUSER: moodle
MOODLE_DOCKER_DBPASS: "m@0dl3ing"
MOODLE_DOCKER_BROWSER: firefox
MOODLE_DOCKER_WEB_HOST: "${MOODLE_DOCKER_WEB_HOST}"
db:
image: postgres:12
environment:
POSTGRES_USER: moodle
POSTGRES_PASSWORD: "m@0dl3ing"
POSTGRES_DB: moodle
exttests:
image: moodlehq/moodle-exttests
volumes:
Expand Down
19 changes: 10 additions & 9 deletions bin/moodle-docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -38,18 +38,19 @@ dockercompose="${dockercompose} -f ${basedir}/service.mail.yml"
# PHP Version.
export MOODLE_DOCKER_PHP_VERSION=${MOODLE_DOCKER_PHP_VERSION:-7.4}

# Database flavour
if [ "$MOODLE_DOCKER_DB" != 'pgsql' ];
then
dockercompose="${dockercompose} -f ${basedir}/db.${MOODLE_DOCKER_DB}.yml"
# Database flavour.
dockercompose="${dockercompose} -f ${basedir}/db.${MOODLE_DOCKER_DB}.yml"

# Add support for version specific database settings.
if [ ! -z "$MOODLE_DOCKER_DB_VERSION" ];
then
filename="${basedir}/db.${MOODLE_DOCKER_DB}.${MOODLE_DOCKER_DB_VERSION}.yml"
if [ -f $filename ]; then
dockercompose="${dockercompose} -f ${filename}"
fi
fi

# Support PHP version overrides for DB..
filename="${basedir}/db.${MOODLE_DOCKER_DB}.${MOODLE_DOCKER_PHP_VERSION}.yml"
if [ -f $filename ]; then
dockercompose="${dockercompose} -f ${filename}"
fi
# Support PHP version overrides for DB not available any more.

# Expose DB port if requested.
if [[ $MOODLE_DOCKER_DB_PORT == *":"* ]] || [[ $MOODLE_DOCKER_DB_PORT -gt 0 ]]
Expand Down
7 changes: 5 additions & 2 deletions bin/moodle-docker-compose.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,11 @@ IF "%MOODLE_DOCKER_PHP_VERSION%"=="" (
SET MOODLE_DOCKER_PHP_VERSION=7.4
)

IF NOT "%MOODLE_DOCKER_DB%"=="pgsql" (
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\db.%MOODLE_DOCKER_DB%.yml"
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\db.%MOODLE_DOCKER_DB%.yml"

SET filenamedbversion=%BASEDIR%\db.%MOODLE_DOCKER_DB%.%MOODLE_DOCKER_DB_VERSION%.yml
if exist %filenamedbversion% (
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filenamedbversion%"
)

SET filename=%BASEDIR%\db.%MOODLE_DOCKER_DB%.%MOODLE_DOCKER_PHP_VERSION%.yml
Expand Down
2 changes: 1 addition & 1 deletion db.mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
MOODLE_DOCKER_DBTYPE: mariadb
MOODLE_DOCKER_DBCOLLATION: utf8mb4_bin
db:
image: mariadb:10.7
image: "mariadb:${MOODLE_DOCKER_DB_VERSION:-10.7}"
command: >
--character-set-server=utf8mb4
--collation-server=utf8mb4_bin
Expand Down
5 changes: 0 additions & 5 deletions db.mssql.5.6.yml

This file was deleted.

2 changes: 1 addition & 1 deletion db.mssql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
MOODLE_DOCKER_DBTYPE: sqlsrv
MOODLE_DOCKER_DBUSER: sa
db:
image: moodlehq/moodle-db-mssql
image: moodlehq/moodle-db-mssql:${MOODLE_DOCKER_DB_VERSION:-2017-latest}
environment:
ACCEPT_EULA: "y"
SA_PASSWORD: "m@0dl3ing"
7 changes: 7 additions & 0 deletions db.mysql.8.0.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
version: "2"
services:
db:
image: "mysql:${MOODLE_DOCKER_DB_VERSION:-8.0}"
command: >
--character-set-server=utf8mb4
--collation-server=utf8mb4_bin
2 changes: 1 addition & 1 deletion db.mysql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ services:
MOODLE_DOCKER_DBTYPE: mysqli
MOODLE_DOCKER_DBCOLLATION: utf8mb4_bin
db:
image: mysql:5
image: "mysql:${MOODLE_DOCKER_DB_VERSION:-5.7}"
command: >
--character-set-server=utf8mb4
--collation-server=utf8mb4_bin
Expand Down
2 changes: 1 addition & 1 deletion db.oracle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ services:
MOODLE_DOCKER_DBTYPE: oci
MOODLE_DOCKER_DBNAME: XE
db:
image: moodlehq/moodle-db-oracle-r2:21
image: moodlehq/moodle-db-oracle-r2:${MOODLE_DOCKER_DB_VERSION:-21}
11 changes: 11 additions & 0 deletions db.pgsql.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: "2"
services:
webserver:
environment:
MOODLE_DOCKER_DBTYPE: pgsql
db:
image: "postgres:${MOODLE_DOCKER_DB_VERSION:-12}"
environment:
POSTGRES_USER: moodle
POSTGRES_PASSWORD: "m@0dl3ing"
POSTGRES_DB: moodle

0 comments on commit a0cc379

Please sign in to comment.