diff --git a/README.md b/README.md index 185dc8faf3c..76836b5f2af 100644 --- a/README.md +++ b/README.md @@ -209,6 +209,7 @@ When you change them, use `bin/moodle-docker-compose down && bin/moodle-docker-c | `MOODLE_DOCKER_BROWSER` | no | firefox, chrome, firefox:<tag>, chrome:<tag> | 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 | | `MOODLE_DOCKER_BEHAT_FAILDUMP` | no | Path on your file system | not set | Behat faildumps are already available at http://localhost:8000/_/faildumps/ by default, this allows for mapping a specific filesystem folder to retrieve the faildumps in bulk / automated ways | +| `MOODLE_DOCKER_DB_PORT` | no | any integer value | none | If you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all). Username is "moodle" (or "sa" for mssql) and password is "m@0dl3ing". | | `MOODLE_DOCKER_WEB_HOST` | no | any valid hostname | localhost | The hostname for web | | `MOODLE_DOCKER_WEB_PORT` | no | any integer value (or bind_ip:integer)| 127.0.0.1:8000| The port number for web. If set to 0, no port is used.
If you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all) | | `MOODLE_DOCKER_SELENIUM_VNC_PORT` | no | any integer value (or bind_ip:integer)| not set | If set, the selenium node will expose a vnc session on the port specified. Similar to MOODLE_DOCKER_WEB_PORT, you can optionally define the host IP to bind to. If you just set the port, VNC binds to 127.0.0.1 | diff --git a/bin/moodle-docker-compose b/bin/moodle-docker-compose index 574469f1472..eaf65aa7387 100755 --- a/bin/moodle-docker-compose +++ b/bin/moodle-docker-compose @@ -51,6 +51,21 @@ if [ -f $filename ]; then dockercompose="${dockercompose} -f ${filename}" fi +# Expose DB port if requested. +if [[ $MOODLE_DOCKER_DB_PORT == *":"* ]] || [[ $MOODLE_DOCKER_DB_PORT -gt 0 ]] +then + # If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 + if [[ ! $MOODLE_DOCKER_DB_PORT == *":"* ]] + then + export MOODLE_DOCKER_DB_PORT=127.0.0.1:$MOODLE_DOCKER_DB_PORT + fi + filename="${basedir}/db.${MOODLE_DOCKER_DB}.port.yml" + if [ -f $filename ]; + then + dockercompose="${dockercompose} -f ${filename}" + fi +fi + # Fix mobile app deprecated variables if [ ! -z "$MOODLE_APP_VERSION" ]; then diff --git a/bin/moodle-docker-compose.cmd b/bin/moodle-docker-compose.cmd index 8176607d994..3966ac417f5 100644 --- a/bin/moodle-docker-compose.cmd +++ b/bin/moodle-docker-compose.cmd @@ -34,6 +34,24 @@ if exist %filename% ( SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filename%" ) +IF "%MOODLE_DOCKER_DB_PORT%"=="" ( + SET MOODLE_DOCKER_DB_PORT= +) ELSE ( + SET "TRUE=" + IF NOT "%MOODLE_DOCKER_DB_PORT%"=="%MOODLE_DOCKER_DB_PORT::=%" SET TRUE=1 + IF NOT "%MOODLE_DOCKER_DB_PORT%"=="0" SET TRUE=1 + IF DEFINED TRUE ( + REM If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 + IF "%MOODLE_DOCKER_DB_PORT%"=="%MOODLE_DOCKER_DB_PORT::=%" ( + SET MOODLE_DOCKER_DB_PORT=127.0.0.1:%MOODLE_DOCKER_DB_PORT% + ) + SET filedbport=%BASEDIR%\db.%MOODLE_DOCKER_DB%.port.yml + IF EXIST %filedbport% ( + SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filedbport%" + ) + ) +) + IF NOT "%MOODLE_APP_VERSION%"=="" ( ECHO Warning: MOODLE_APP_VERSION is deprecated, use MOODLE_DOCKER_APP_VERSION instead diff --git a/db.mariadb.port.yml b/db.mariadb.port.yml new file mode 100644 index 00000000000..a6b6242e305 --- /dev/null +++ b/db.mariadb.port.yml @@ -0,0 +1,5 @@ +version: "2" +services: + db: + ports: + - "${MOODLE_DOCKER_DB_PORT}:3306/tcp" diff --git a/db.mssql.port.yml b/db.mssql.port.yml new file mode 100644 index 00000000000..5b5be0b1b24 --- /dev/null +++ b/db.mssql.port.yml @@ -0,0 +1,5 @@ +version: "2" +services: + db: + ports: + - "${MOODLE_DOCKER_DB_PORT}:1433/tcp" diff --git a/db.mysql.port.yml b/db.mysql.port.yml new file mode 100644 index 00000000000..a6b6242e305 --- /dev/null +++ b/db.mysql.port.yml @@ -0,0 +1,5 @@ +version: "2" +services: + db: + ports: + - "${MOODLE_DOCKER_DB_PORT}:3306/tcp" diff --git a/db.oracle.port.yml b/db.oracle.port.yml new file mode 100644 index 00000000000..c2f9ea7ce75 --- /dev/null +++ b/db.oracle.port.yml @@ -0,0 +1,5 @@ +version: "2" +services: + db: + ports: + - "${MOODLE_DOCKER_DB_PORT}:1521/tcp" diff --git a/db.pgsql.port.yml b/db.pgsql.port.yml new file mode 100644 index 00000000000..0bec6b5ec4f --- /dev/null +++ b/db.pgsql.port.yml @@ -0,0 +1,5 @@ +version: "2" +services: + db: + ports: + - "${MOODLE_DOCKER_DB_PORT}:5432/tcp"