Skip to content

Commit

Permalink
No local DB when using an external DB
Browse files Browse the repository at this point in the history
  • Loading branch information
scara committed Nov 13, 2022
1 parent 95b584c commit e0bf9bd
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 48 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -240,12 +240,6 @@ bin/moodle-docker-compose down
unset MOODLE_DOCKER_DBHOST MOODLE_DOCKER_DBNAME MOODLE_DOCKER_DBUSER MOODLE_DOCKER_DBPASS
```

Please note that the local DB server will be still available to allow e.g. the usage of the specific DB client to connect to the remote DB server:

```
bin/moodle-docker-compose exec db mysql -h instance-name.mysql.database.azure.com -u ******** -p'********' -e "SELECT VERSION();"
```

## Using XDebug for live debugging

The XDebug PHP Extension is not included in this setup and there are reasons not to include it by default.
Expand Down
45 changes: 24 additions & 21 deletions bin/moodle-docker-compose
Original file line number Diff line number Diff line change
Expand Up @@ -35,32 +35,35 @@ dockercompose="${dockercompose} -f ${basedir}/service.mail.yml"
# PHP Version.
export MOODLE_DOCKER_PHP_VERSION=${MOODLE_DOCKER_PHP_VERSION:-7.4}

# Database flavour.
dockercompose="${dockercompose} -f ${basedir}/db.${MOODLE_DOCKER_DB}.yml"

# Add support for version specific database settings.
if [ ! -z "$MOODLE_DOCKER_DB_VERSION" ];
if [ -z "${MOODLE_DOCKER_DBHOST}" ];
then
filename="${basedir}/db.${MOODLE_DOCKER_DB}.${MOODLE_DOCKER_DB_VERSION}.yml"
if [ -f $filename ]; then
dockercompose="${dockercompose} -f ${filename}"
fi
fi

# Support PHP version overrides for DB not available any more.
# Database flavour.
dockercompose="${dockercompose} -f ${basedir}/db.${MOODLE_DOCKER_DB}.yml"

# 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 == *":"* ]]
# Add support for version specific database settings.
if [ ! -z "$MOODLE_DOCKER_DB_VERSION" ];
then
export MOODLE_DOCKER_DB_PORT=127.0.0.1:$MOODLE_DOCKER_DB_PORT
filename="${basedir}/db.${MOODLE_DOCKER_DB}.${MOODLE_DOCKER_DB_VERSION}.yml"
if [ -f $filename ]; then
dockercompose="${dockercompose} -f ${filename}"
fi
fi
filename="${basedir}/db.${MOODLE_DOCKER_DB}.port.yml"
if [ -f $filename ];

# Support PHP version overrides for DB not available any more.

# Expose DB port if requested.
if [[ $MOODLE_DOCKER_DB_PORT == *":"* ]] || [[ $MOODLE_DOCKER_DB_PORT -gt 0 ]]
then
dockercompose="${dockercompose} -f ${filename}"
# 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
fi

Expand Down
44 changes: 23 additions & 21 deletions bin/moodle-docker-compose.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,31 @@ IF "%MOODLE_DOCKER_PHP_VERSION%"=="" (
SET MOODLE_DOCKER_PHP_VERSION=7.4
)

SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\db.%MOODLE_DOCKER_DB%.yml"
IF "%MOODLE_DOCKER_DBHOST%"=="" (
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\db.%MOODLE_DOCKER_DB%.yml"

SET filenamedbversion=%BASEDIR%\db.%MOODLE_DOCKER_DB%.%MOODLE_DOCKER_DB_VERSION%.yml
IF EXIST "%filenamedbversion%" (
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filenamedbversion%"
)

REM Support PHP version overrides for DB not available any more.
SET filenamedbversion=%BASEDIR%\db.%MOODLE_DOCKER_DB%.%MOODLE_DOCKER_DB_VERSION%.yml
IF EXIST "%filenamedbversion%" (
SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filenamedbversion%"
)

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%"
REM Support PHP version overrides for DB not available any more.

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%"
)
)
)
)
Expand Down

0 comments on commit e0bf9bd

Please sign in to comment.