Skip to content

Commit d9c2765

Browse files
authored
Merge pull request #225 from skodak/dbversion
add support for database versions
2 parents 1a7e8c5 + 7c3129b commit d9c2765

12 files changed

+42
-36
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ When you change them, use `bin/moodle-docker-compose down && bin/moodle-docker-c
205205
|-------------------------------------------|-----------|---------------------------------------|---------------|------------------------------------------------------------------------------|
206206
| `MOODLE_DOCKER_DB` | yes | pgsql, mariadb, mysql, mssql, oracle | none | The database server to run against |
207207
| `MOODLE_DOCKER_WWWROOT` | yes | path on your file system | none | The path to the Moodle codebase you intend to test |
208+
| `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 |
208209
| `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 |
209210
| `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) |
210211
| `MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES` | no | any value | not set | If set, dependencies for memcached, redis, solr, and openldap are added |

base.yml

+1-8
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,17 @@ services:
88
- "${MOODLE_DOCKER_WWWROOT}:/var/www/html"
99
- "${ASSETDIR}/web/apache2_faildumps.conf:/etc/apache2/conf-enabled/apache2_faildumps.conf"
1010
environment:
11-
MOODLE_DOCKER_DBTYPE: pgsql
1211
MOODLE_DOCKER_DBNAME: moodle
1312
MOODLE_DOCKER_DBUSER: moodle
1413
MOODLE_DOCKER_DBPASS: "m@0dl3ing"
1514
MOODLE_DOCKER_BROWSER: firefox
1615
MOODLE_DOCKER_WEB_HOST: "${MOODLE_DOCKER_WEB_HOST}"
17-
db:
18-
image: postgres:12
19-
environment:
20-
POSTGRES_USER: moodle
21-
POSTGRES_PASSWORD: "m@0dl3ing"
22-
POSTGRES_DB: moodle
2316
exttests:
2417
image: moodlehq/moodle-exttests
2518
volumes:
2619
- "${ASSETDIR}/exttests/apache2_ports.conf:/etc/apache2/ports.conf"
2720
- "${ASSETDIR}/exttests/apache2.conf:/etc/apache2/sites-enabled/000-default.conf"
2821
selenium:
29-
image: "selenium/standalone-firefox${MOODLE_DOCKER_SELENIUM_SUFFIX}:${MOODLE_DOCKER_BROWSER_TAG}"
22+
image: "selenium/standalone-firefox${MOODLE_DOCKER_SELENIUM_SUFFIX:-}:${MOODLE_DOCKER_BROWSER_TAG}"
3023
volumes:
3124
- "${MOODLE_DOCKER_WWWROOT}:/var/www/html:ro"

bin/moodle-docker-compose

+10-9
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,19 @@ dockercompose="${dockercompose} -f ${basedir}/service.mail.yml"
3535
# PHP Version.
3636
export MOODLE_DOCKER_PHP_VERSION=${MOODLE_DOCKER_PHP_VERSION:-7.4}
3737

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

41+
# Add support for version specific database settings.
42+
if [ ! -z "$MOODLE_DOCKER_DB_VERSION" ];
43+
then
44+
filename="${basedir}/db.${MOODLE_DOCKER_DB}.${MOODLE_DOCKER_DB_VERSION}.yml"
45+
if [ -f $filename ]; then
46+
dockercompose="${dockercompose} -f ${filename}"
47+
fi
4348
fi
4449

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

5152
# Expose DB port if requested.
5253
if [[ $MOODLE_DOCKER_DB_PORT == *":"* ]] || [[ $MOODLE_DOCKER_DB_PORT -gt 0 ]]

bin/moodle-docker-compose.cmd

+7-9
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ IF "%MOODLE_DOCKER_PHP_VERSION%"=="" (
2525
SET MOODLE_DOCKER_PHP_VERSION=7.4
2626
)
2727

28-
IF NOT "%MOODLE_DOCKER_DB%"=="pgsql" (
29-
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\db.%MOODLE_DOCKER_DB%.yml"
30-
)
28+
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\db.%MOODLE_DOCKER_DB%.yml"
3129

32-
SET filename=%BASEDIR%\db.%MOODLE_DOCKER_DB%.%MOODLE_DOCKER_PHP_VERSION%.yml
33-
if exist %filename% (
34-
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filename%"
30+
SET filenamedbversion=%BASEDIR%\db.%MOODLE_DOCKER_DB%.%MOODLE_DOCKER_DB_VERSION%.yml
31+
IF EXIST "%filenamedbversion%" (
32+
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filenamedbversion%"
3533
)
3634

35+
REM Support PHP version overrides for DB not available any more.
36+
3737
IF "%MOODLE_DOCKER_DB_PORT%"=="" (
3838
SET MOODLE_DOCKER_DB_PORT=
3939
) ELSE (
@@ -46,7 +46,7 @@ IF "%MOODLE_DOCKER_DB_PORT%"=="" (
4646
SET MOODLE_DOCKER_DB_PORT=127.0.0.1:%MOODLE_DOCKER_DB_PORT%
4747
)
4848
SET filedbport=%BASEDIR%\db.%MOODLE_DOCKER_DB%.port.yml
49-
IF EXIST %filedbport% (
49+
IF EXIST "%filedbport%" (
5050
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filedbport%"
5151
)
5252
)
@@ -144,6 +144,4 @@ IF "%MOODLE_DOCKER_SELENIUM_VNC_PORT%"=="" (
144144
)
145145
)
146146

147-
echo %MOODLE_DOCKER_SELENIUM_SUFFIX% %MOODLE_DOCKER_BROWSER_TAG%
148-
149147
%DOCKERCOMPOSE% %*

db.mariadb.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
MOODLE_DOCKER_DBTYPE: mariadb
66
MOODLE_DOCKER_DBCOLLATION: utf8mb4_bin
77
db:
8-
image: mariadb:10.7
8+
image: mariadb:${MOODLE_DOCKER_DB_VERSION:-10.7}
99
command: >
1010
--character-set-server=utf8mb4
1111
--collation-server=utf8mb4_bin

db.mssql.5.6.yml

-5
This file was deleted.

db.mssql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
MOODLE_DOCKER_DBTYPE: sqlsrv
66
MOODLE_DOCKER_DBUSER: sa
77
db:
8-
image: moodlehq/moodle-db-mssql
8+
image: moodlehq/moodle-db-mssql:${MOODLE_DOCKER_DB_VERSION:-2017-latest}
99
environment:
1010
ACCEPT_EULA: "y"
1111
SA_PASSWORD: "m@0dl3ing"

db.mysql.8.0.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
version: "2"
2+
services:
3+
db:
4+
image: mysql:${MOODLE_DOCKER_DB_VERSION:-8.0}
5+
command: >
6+
--character-set-server=utf8mb4
7+
--collation-server=utf8mb4_bin

db.mysql.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services:
55
MOODLE_DOCKER_DBTYPE: mysqli
66
MOODLE_DOCKER_DBCOLLATION: utf8mb4_bin
77
db:
8-
image: mysql:5
8+
image: mysql:${MOODLE_DOCKER_DB_VERSION:-5.7}
99
command: >
1010
--character-set-server=utf8mb4
1111
--collation-server=utf8mb4_bin

db.oracle.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ services:
55
MOODLE_DOCKER_DBTYPE: oci
66
MOODLE_DOCKER_DBNAME: XE
77
db:
8-
image: moodlehq/moodle-db-oracle-r2:21
8+
image: moodlehq/moodle-db-oracle-r2:${MOODLE_DOCKER_DB_VERSION:-21}

db.pgsql.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: "2"
2+
services:
3+
webserver:
4+
environment:
5+
MOODLE_DOCKER_DBTYPE: pgsql
6+
db:
7+
image: postgres:${MOODLE_DOCKER_DB_VERSION:-12}
8+
environment:
9+
POSTGRES_USER: moodle
10+
POSTGRES_PASSWORD: "m@0dl3ing"
11+
POSTGRES_DB: moodle

selenium.chrome.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ services:
44
environment:
55
MOODLE_DOCKER_BROWSER: chrome
66
selenium:
7-
image: "selenium/standalone-chrome${MOODLE_DOCKER_SELENIUM_SUFFIX}:${MOODLE_DOCKER_BROWSER_TAG}"
7+
image: "selenium/standalone-chrome${MOODLE_DOCKER_SELENIUM_SUFFIX:-}:${MOODLE_DOCKER_BROWSER_TAG}"
88
volumes:
99
- /dev/shm:/dev/shm

0 commit comments

Comments
 (0)