diff --git a/README.md b/README.md
index 7545da8769e..82fd483dc40 100644
--- a/README.md
+++ b/README.md
@@ -211,24 +211,25 @@ bin/moodle-docker-compose start
You can change the configuration of the docker images by setting various environment variables **before** calling `bin/moodle-docker-compose up`.
When you change them, use `bin/moodle-docker-compose down && bin/moodle-docker-compose up -d` to recreate your environment.
-| Environment Variable | Mandatory | Allowed values | Default value | Notes |
-|-------------------------------------------|-----------|---------------------------------------|---------------|------------------------------------------------------------------------------|
-| `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: 8.0
pgsql: 13
mariadb: 10.7
mssql: 2017-latest
oracle: 21| The database server docker image tag |
-| `MOODLE_DOCKER_PHP_VERSION` | no | 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6| 8.2 | The php version to use |
-| `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_BBB_MOCK` | no | any value | not set | If set the BigBlueButton mock image is started and configured |
-| `MOODLE_DOCKER_MATRIX_MOCK` | no | any value | not set | If set the Matrix mock image is started and configured |
-| `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 |
-| `MOODLE_DOCKER_APP_PATH` | no | path on your file system | not set | If set and the chrome browser is selected, it will start an instance of the Moodle app from your local codebase |
-| `MOODLE_DOCKER_APP_VERSION` | no | a valid [app docker image version](https://docs.moodle.org/dev/Moodle_App_Docker_images) | not set | If set will start an instance of the Moodle app if the chrome browser is selected |
-| `MOODLE_DOCKER_TIMEOUT_FACTOR` | no | any integer value | 1 | If set the timeouts in behat will be multiplied by the factor |
+| Environment Variable | Mandatory | Allowed values | Default value | Notes |
+|-------------------------------------------|-----------|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
+| `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: 8.0
pgsql: 13
mariadb: 10.7
mssql: 2017-latest
oracle: 21 | The database server docker image tag |
+| `MOODLE_DOCKER_PHP_VERSION` | no | 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6 | 8.2 | The php version to use |
+| `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_BBB_MOCK` | no | any value | not set | If set the BigBlueButton mock image is started and configured |
+| `MOODLE_DOCKER_MATRIX_MOCK` | no | any value | not set | If set the Matrix mock image is started and configured |
+| `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 |
+| `MOODLE_DOCKER_APP_PATH` | no | path on your file system | not set | If set and the chrome browser is selected, it will start an instance of the Moodle app from your local codebase |
+| `MOODLE_DOCKER_APP_VERSION` | no | a valid [app docker image version](https://docs.moodle.org/dev/Moodle_App_Docker_images) | not set | If set will start an instance of the Moodle app if the chrome browser is selected |
+| `MOODLE_DOCKER_APP_PORT` | no | any integer value | 8100 | The app will be served on this port, 0 will mean the app is not available on the host machine |
+| `MOODLE_DOCKER_TIMEOUT_FACTOR` | no | any integer value | 1 | If set the timeouts in behat will be multiplied by the factor |
In addition to that, `MOODLE_DOCKER_RUNNING=1` env variable is defined and available
in the webserver container to flag being run by `moodle-docker`. Developer
diff --git a/bin/moodle-docker-compose b/bin/moodle-docker-compose
index 716965b7373..6edfe3c881d 100755
--- a/bin/moodle-docker-compose
+++ b/bin/moodle-docker-compose
@@ -102,17 +102,23 @@ then
export MOODLE_DOCKER_APP_NODE_VERSION="$appnodeversion"
fi
-# Guess mobile app port (only when using Docker app images)
-if [[ -z "$MOODLE_DOCKER_APP_PORT" ]] && [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]];
+
+if [[ -z "$MOODLE_DOCKER_APP_INTERNAL_PORT" ]] && [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]];
then
+ # Guess mobile app port (only when using Docker app images)
if [[ "$MOODLE_DOCKER_APP_RUNTIME" = "ionic5" ]];
then
- export MOODLE_DOCKER_APP_PORT="80"
+ export MOODLE_DOCKER_APP_INTERNAL_PORT="80"
else
- export MOODLE_DOCKER_APP_PORT="443"
+ export MOODLE_DOCKER_APP_INTERNAL_PORT="443"
fi
fi
+if [[ -z "$MOODLE_DOCKER_APP_PORT" ]];
+then
+ export MOODLE_DOCKER_APP_PORT="8100"
+fi
+
# Guess mobile app protocol
if [[ -z "$MOODLE_DOCKER_APP_PROTOCOL" ]];
then
@@ -156,10 +162,20 @@ then
if [[ ! -z "$MOODLE_DOCKER_APP_PATH" ]];
then
dockercompose="${dockercompose} -f ${basedir}/moodle-app-dev.yml"
+
+ if [[ "$MOODLE_DOCKER_APP_PORT" != "0" ]];
+ then
+ dockercompose="${dockercompose} -f ${basedir}/moodle-app-dev-port.yml"
+ fi
elif [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]];
then
# Mobile app using a docker image
dockercompose="${dockercompose} -f ${basedir}/moodle-app.yml"
+
+ if [[ "$MOODLE_DOCKER_APP_PORT" != "0" ]];
+ then
+ dockercompose="${dockercompose} -f ${basedir}/moodle-app-port.yml"
+ fi
fi
fi
diff --git a/bin/moodle-docker-compose.cmd b/bin/moodle-docker-compose.cmd
index 8ee7df306fc..3d47e390ac3 100644
--- a/bin/moodle-docker-compose.cmd
+++ b/bin/moodle-docker-compose.cmd
@@ -71,17 +71,21 @@ IF "%MOODLE_DOCKER_APP_NODE_VERSION%"=="" (
)
)
-REM Guess mobile app port (only when using Docker app images)
-IF "%MOODLE_DOCKER_APP_PORT%"=="" (
+IF "%MOODLE_DOCKER_APP_INTERNAL_PORT%"=="" (
IF NOT "%MOODLE_DOCKER_APP_VERSION%"=="" (
+ REM Guess mobile app port (only when using Docker app images)
IF "%MOODLE_DOCKER_APP_RUNTIME%"=="ionic5" (
- SET MOODLE_DOCKER_APP_PORT=80
+ SET MOODLE_DOCKER_APP_INTERNAL_PORT=80
) ELSE (
- SET MOODLE_DOCKER_APP_PORT=443
+ SET MOODLE_DOCKER_APP_INTERNAL_PORT=443
)
)
)
+IF "%MOODLE_DOCKER_APP_PORT%"=="" (
+ SET MOODLE_DOCKER_APP_PORT=8100
+)
+
REM Guess mobile app protocol
IF "%MOODLE_DOCKER_APP_PROTOCOL%"=="" (
if "%MOODLE_DOCKER_APP_RUNTIME%"=="ionic5" (
@@ -118,9 +122,17 @@ IF "%MOODLE_DOCKER_BROWSER_TAG%"=="" (
IF "%MOODLE_DOCKER_BROWSER_NAME%"=="chrome" (
IF NOT "%MOODLE_DOCKER_APP_PATH%"=="" (
- SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app-dev.yml"
+ IF NOT "%MOODLE_DOCKER_APP_PORT%"=="0" (
+ SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app-dev.yml" -f "%BASEDIR%\moodle-app-dev-port.yml"
+ ) ELSE (
+ SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app-dev.yml"
+ )
) ELSE IF NOT "%MOODLE_DOCKER_APP_VERSION%"=="" (
- SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml"
+ IF NOT "%MOODLE_DOCKER_APP_PORT%"=="0" (
+ SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml" -f "%BASEDIR%\moodle-app-port.yml"
+ ) ELSE (
+ SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml"
+ )
)
)
diff --git a/moodle-app-dev-port.yml b/moodle-app-dev-port.yml
new file mode 100644
index 00000000000..1650fe91960
--- /dev/null
+++ b/moodle-app-dev-port.yml
@@ -0,0 +1,6 @@
+services:
+ moodleapp:
+ ports:
+ - "$MOODLE_DOCKER_APP_PORT:8100"
+ - "35729:35729"
+ - "53703:53703"
diff --git a/moodle-app-dev.yml b/moodle-app-dev.yml
index 98daf958885..71992cc0e7b 100644
--- a/moodle-app-dev.yml
+++ b/moodle-app-dev.yml
@@ -13,7 +13,3 @@ services:
- 8100
- 35729
- 53703
- ports:
- - "8100:8100"
- - "35729:35729"
- - "53703:53703"
diff --git a/moodle-app-port.yml b/moodle-app-port.yml
new file mode 100644
index 00000000000..be5506dffdc
--- /dev/null
+++ b/moodle-app-port.yml
@@ -0,0 +1,4 @@
+services:
+ moodleapp:
+ ports:
+ - "$MOODLE_DOCKER_APP_PORT:$MOODLE_DOCKER_APP_INTERNAL_PORT"
diff --git a/moodle-app.yml b/moodle-app.yml
index 8808d9d660d..acae7b39094 100644
--- a/moodle-app.yml
+++ b/moodle-app.yml
@@ -2,9 +2,7 @@ services:
webserver:
environment:
MOODLE_DOCKER_APP: "true"
- MOODLE_DOCKER_APP_PORT: ${MOODLE_DOCKER_APP_PORT}
+ MOODLE_DOCKER_APP_PORT: ${MOODLE_DOCKER_APP_INTERNAL_PORT}
MOODLE_DOCKER_APP_PROTOCOL: ${MOODLE_DOCKER_APP_PROTOCOL}
moodleapp:
image: "moodlehq/moodleapp:${MOODLE_DOCKER_APP_VERSION}"
- ports:
- - "8100:$MOODLE_DOCKER_APP_PORT"