Skip to content

Commit

Permalink
Merge pull request #226 from skodak/dbport
Browse files Browse the repository at this point in the history
add support for exposing of database port
  • Loading branch information
stronk7 authored Oct 4, 2022
2 parents f57b43c + cdf9000 commit b88d66d
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:&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 |
| `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.<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) |
| `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 |
Expand Down
15 changes: 15 additions & 0 deletions bin/moodle-docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 18 additions & 0 deletions bin/moodle-docker-compose.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions db.mariadb.port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "2"
services:
db:
ports:
- "${MOODLE_DOCKER_DB_PORT}:3306/tcp"
5 changes: 5 additions & 0 deletions db.mssql.port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "2"
services:
db:
ports:
- "${MOODLE_DOCKER_DB_PORT}:1433/tcp"
5 changes: 5 additions & 0 deletions db.mysql.port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "2"
services:
db:
ports:
- "${MOODLE_DOCKER_DB_PORT}:3306/tcp"
5 changes: 5 additions & 0 deletions db.oracle.port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "2"
services:
db:
ports:
- "${MOODLE_DOCKER_DB_PORT}:1521/tcp"
5 changes: 5 additions & 0 deletions db.pgsql.port.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: "2"
services:
db:
ports:
- "${MOODLE_DOCKER_DB_PORT}:5432/tcp"

0 comments on commit b88d66d

Please sign in to comment.