Skip to content

Commit d7179ba

Browse files
committed
Allow Moodle app port to be configured
Before this change the moodle-app was always put onto port 8100, this makes it impossible to have multiple instances of moodle-docker running if they also have a copy of the app running. After this change while be default nothing should change you may now select the exposed port, or disable it altogether using MOODLE_DOCKER_APP_PORT Before this change MOODLE_DOCKER_APP_PORT was used internally to select the source port for the app, this is now done using MOODLE_DOCKER_APP_INTERNAL_PORT because that name fits better with the other environment variables that let the user set the port available on the host.
1 parent f0f774f commit d7179ba

File tree

7 files changed

+68
-35
lines changed

7 files changed

+68
-35
lines changed

README.md

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -211,24 +211,25 @@ bin/moodle-docker-compose start
211211
You can change the configuration of the docker images by setting various environment variables **before** calling `bin/moodle-docker-compose up`.
212212
When you change them, use `bin/moodle-docker-compose down && bin/moodle-docker-compose up -d` to recreate your environment.
213213

214-
| Environment Variable | Mandatory | Allowed values | Default value | Notes |
215-
|-------------------------------------------|-----------|---------------------------------------|---------------|------------------------------------------------------------------------------|
216-
| `MOODLE_DOCKER_DB` | yes | pgsql, mariadb, mysql, mssql, oracle | none | The database server to run against |
217-
| `MOODLE_DOCKER_WWWROOT` | yes | path on your file system | none | The path to the Moodle codebase you intend to test |
218-
| `MOODLE_DOCKER_DB_VERSION` | no | Docker tag - see relevant database page on docker-hub | mysql: 8.0 <br/>pgsql: 13 <br/>mariadb: 10.7 <br/>mssql: 2017-latest <br/>oracle: 21| The database server docker image tag |
219-
| `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 |
220-
| `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) |
221-
| `MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES` | no | any value | not set | If set, dependencies for memcached, redis, solr, and openldap are added |
222-
| `MOODLE_DOCKER_BBB_MOCK` | no | any value | not set | If set the BigBlueButton mock image is started and configured |
223-
| `MOODLE_DOCKER_MATRIX_MOCK` | no | any value | not set | If set the Matrix mock image is started and configured |
224-
| `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 |
225-
| `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". |
226-
| `MOODLE_DOCKER_WEB_HOST` | no | any valid hostname | localhost | The hostname for web |
227-
| `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.<br/>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) |
228-
| `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 |
229-
| `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 |
230-
| `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 |
231-
| `MOODLE_DOCKER_TIMEOUT_FACTOR` | no | any integer value | 1 | If set the timeouts in behat will be multiplied by the factor |
214+
| Environment Variable | Mandatory | Allowed values | Default value | Notes |
215+
|-------------------------------------------|-----------|------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
216+
| `MOODLE_DOCKER_DB` | yes | pgsql, mariadb, mysql, mssql, oracle | none | The database server to run against |
217+
| `MOODLE_DOCKER_WWWROOT` | yes | path on your file system | none | The path to the Moodle codebase you intend to test |
218+
| `MOODLE_DOCKER_DB_VERSION` | no | Docker tag - see relevant database page on docker-hub | mysql: 8.0 <br/>pgsql: 13 <br/>mariadb: 10.7 <br/>mssql: 2017-latest <br/>oracle: 21 | The database server docker image tag |
219+
| `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 |
220+
| `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) |
221+
| `MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES` | no | any value | not set | If set, dependencies for memcached, redis, solr, and openldap are added |
222+
| `MOODLE_DOCKER_BBB_MOCK` | no | any value | not set | If set the BigBlueButton mock image is started and configured |
223+
| `MOODLE_DOCKER_MATRIX_MOCK` | no | any value | not set | If set the Matrix mock image is started and configured |
224+
| `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 |
225+
| `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". |
226+
| `MOODLE_DOCKER_WEB_HOST` | no | any valid hostname | localhost | The hostname for web |
227+
| `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.<br/>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) |
228+
| `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 |
229+
| `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 |
230+
| `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 |
231+
| `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 |
232+
| `MOODLE_DOCKER_TIMEOUT_FACTOR` | no | any integer value | 1 | If set the timeouts in behat will be multiplied by the factor |
232233

233234
In addition to that, `MOODLE_DOCKER_RUNNING=1` env variable is defined and available
234235
in the webserver container to flag being run by `moodle-docker`. Developer

bin/moodle-docker-compose

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,23 @@ then
102102
export MOODLE_DOCKER_APP_NODE_VERSION="$appnodeversion"
103103
fi
104104

105-
# Guess mobile app port (only when using Docker app images)
106-
if [[ -z "$MOODLE_DOCKER_APP_PORT" ]] && [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]];
105+
106+
if [[ -z "$MOODLE_DOCKER_APP_INTERNAL_PORT" ]] && [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]];
107107
then
108+
# Guess mobile app port (only when using Docker app images)
108109
if [[ "$MOODLE_DOCKER_APP_RUNTIME" = "ionic5" ]];
109110
then
110-
export MOODLE_DOCKER_APP_PORT="80"
111+
export MOODLE_DOCKER_APP_INTERNAL_PORT="80"
111112
else
112-
export MOODLE_DOCKER_APP_PORT="443"
113+
export MOODLE_DOCKER_APP_INTERNAL_PORT="443"
113114
fi
114115
fi
115116

117+
if [[ -z "$MOODLE_DOCKER_APP_PORT" ]];
118+
then
119+
export MOODLE_DOCKER_APP_PORT="8100"
120+
fi
121+
116122
# Guess mobile app protocol
117123
if [[ -z "$MOODLE_DOCKER_APP_PROTOCOL" ]];
118124
then
@@ -156,10 +162,20 @@ then
156162
if [[ ! -z "$MOODLE_DOCKER_APP_PATH" ]];
157163
then
158164
dockercompose="${dockercompose} -f ${basedir}/moodle-app-dev.yml"
165+
166+
if [[ "$MOODLE_DOCKER_APP_PORT" != "0" ]];
167+
then
168+
dockercompose="${dockercompose} -f ${basedir}/moodle-app-dev-port.yml"
169+
fi
159170
elif [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]];
160171
then
161172
# Mobile app using a docker image
162173
dockercompose="${dockercompose} -f ${basedir}/moodle-app.yml"
174+
175+
if [[ "$MOODLE_DOCKER_APP_PORT" != "0" ]];
176+
then
177+
dockercompose="${dockercompose} -f ${basedir}/moodle-app-port.yml"
178+
fi
163179
fi
164180
fi
165181

bin/moodle-docker-compose.cmd

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,17 +71,21 @@ IF "%MOODLE_DOCKER_APP_NODE_VERSION%"=="" (
7171
)
7272
)
7373

74-
REM Guess mobile app port (only when using Docker app images)
75-
IF "%MOODLE_DOCKER_APP_PORT%"=="" (
74+
IF "%MOODLE_DOCKER_APP_INTERNAL_PORT%"=="" (
7675
IF NOT "%MOODLE_DOCKER_APP_VERSION%"=="" (
76+
REM Guess mobile app port (only when using Docker app images)
7777
IF "%MOODLE_DOCKER_APP_RUNTIME%"=="ionic5" (
78-
SET MOODLE_DOCKER_APP_PORT=80
78+
SET MOODLE_DOCKER_APP_INTERNAL_PORT=80
7979
) ELSE (
80-
SET MOODLE_DOCKER_APP_PORT=443
80+
SET MOODLE_DOCKER_APP_INTERNAL_PORT=443
8181
)
8282
)
8383
)
8484

85+
IF "%MOODLE_DOCKER_APP_PORT%"=="" (
86+
SET MOODLE_DOCKER_APP_PORT=8100
87+
)
88+
8589
REM Guess mobile app protocol
8690
IF "%MOODLE_DOCKER_APP_PROTOCOL%"=="" (
8791
if "%MOODLE_DOCKER_APP_RUNTIME%"=="ionic5" (
@@ -118,9 +122,17 @@ IF "%MOODLE_DOCKER_BROWSER_TAG%"=="" (
118122

119123
IF "%MOODLE_DOCKER_BROWSER_NAME%"=="chrome" (
120124
IF NOT "%MOODLE_DOCKER_APP_PATH%"=="" (
121-
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app-dev.yml"
125+
IF NOT "%MOODLE_DOCKER_APP_PORT%"=="0" (
126+
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app-dev.yml" -f "%BASEDIR%\moodle-app-dev-port.yml"
127+
) ELSE (
128+
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app-dev.yml"
129+
)
122130
) ELSE IF NOT "%MOODLE_DOCKER_APP_VERSION%"=="" (
123-
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml"
131+
IF NOT "%MOODLE_DOCKER_APP_PORT%"=="0" (
132+
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml" -f "%BASEDIR%\moodle-app-port.yml"
133+
) ELSE (
134+
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml"
135+
)
124136
)
125137
)
126138

moodle-app-dev-port.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
services:
2+
moodleapp:
3+
ports:
4+
- "$MOODLE_DOCKER_APP_PORT:8100"
5+
- "35729:35729"
6+
- "53703:53703"

moodle-app-dev.yml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,3 @@ services:
1313
- 8100
1414
- 35729
1515
- 53703
16-
ports:
17-
- "8100:8100"
18-
- "35729:35729"
19-
- "53703:53703"

moodle-app-port.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
services:
2+
moodleapp:
3+
ports:
4+
- "$MOODLE_DOCKER_APP_PORT:$MOODLE_DOCKER_APP_INTERNAL_PORT"

moodle-app.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ services:
22
webserver:
33
environment:
44
MOODLE_DOCKER_APP: "true"
5-
MOODLE_DOCKER_APP_PORT: ${MOODLE_DOCKER_APP_PORT}
5+
MOODLE_DOCKER_APP_PORT: ${MOODLE_DOCKER_APP_INTERNAL_PORT}
66
MOODLE_DOCKER_APP_PROTOCOL: ${MOODLE_DOCKER_APP_PROTOCOL}
77
moodleapp:
88
image: "moodlehq/moodleapp:${MOODLE_DOCKER_APP_VERSION}"
9-
ports:
10-
- "8100:$MOODLE_DOCKER_APP_PORT"

0 commit comments

Comments
 (0)