File tree 7 files changed +101
-25
lines changed
7 files changed +101
-25
lines changed Original file line number Diff line number Diff line change @@ -61,6 +61,36 @@ to the instance you expect to. See
61
61
[ envvars] ( https://docs.docker.com/compose/reference/envvars/ )
62
62
to see more about ` docker-compose ` environment variables.
63
63
64
+ ## Environment setting defaults via ./moodle-docker.env
65
+
66
+ In Linux and macOS it is also possible to created ` moodle-docker.env ` file
67
+ in directory where ` bin/moodle-docker-compose ` is executed, the file contents are
68
+ then used as default environment values.
69
+
70
+ If ` moodle-docker.env ` is in Moodle code root, then MOODLE_DOCKER_WWWROOT default
71
+ is set to Moodle directory and COMPOSE_PROJECT_NAME defaults to Moodle directory name.
72
+
73
+ Example:
74
+
75
+ 1 . Create ` /path/to/moodle/moodle-docker.env ` file with the following content:
76
+ ```
77
+ # file location /path/to/moodle/moodle-docker.env
78
+ MOODLE_DOCKER_DB=pgsql
79
+ ```
80
+ 2 . Copy config.docker-template.php file to ` /path/to/moodle/config.php `
81
+ 3 . Start containers:
82
+ ``` bash
83
+ cd /path/to/moodle
84
+ /path/to/moodle-docker/bin/moodle-docker-compose up -d
85
+ ```
86
+ 4 . Switch to MariaDB temporarily:
87
+ ``` bash
88
+ cd /path/to/moodle
89
+ /path/to/moodle-docker/bin/moodle-docker-compose down
90
+ export MOODLE_DOCKER_DB=mariadb
91
+ /path/to/moodle-docker/bin/moodle-docker-compose up -d
92
+ ```
93
+
64
94
## Use containers for running behat tests
65
95
66
96
``` bash
Original file line number Diff line number Diff line change
1
+ @ ECHO OFF
2
+
3
+ IF EXIST " moodle-docker.env" (
4
+ for /f " usebackq tokens=1* delims== eol=#" %%i in (moodle-docker.env) do (
5
+ if not defined %%i (
6
+ SET %%i =%%j
7
+ )
8
+ )
9
+
10
+ IF EXIST " lib/moodlelib.php" (
11
+ IF " %MOODLE_DOCKER_WWWROOT% " == " " (
12
+ SET MOODLE_DOCKER_WWWROOT = %cd%
13
+ )
14
+ IF " %COMPOSE_PROJECT_NAME% " == " " (
15
+ FOR %% * IN (.) DO SET COMPOSE_PROJECT_NAME = %%~nx *
16
+ )
17
+ )
18
+ )
19
+
20
+ IF NOT EXIST " %MOODLE_DOCKER_WWWROOT% " (
21
+ ECHO Error: MOODLE_DOCKER_WWWROOT is not set or not an existing directory
22
+ EXIT /B 1
23
+ )
24
+
25
+ IF " %MOODLE_DOCKER_DB% " == " " (
26
+ ECHO Error: MOODLE_DOCKER_DB is not set
27
+ EXIT /B 1
28
+ )
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ # If moodle-docker.env file found then use it as default environment values.
4
+ filename=" moodle-docker.env"
5
+ if [ -f $filename ]; then
6
+ envbackup=$( export -p)
7
+ export $( grep -v ' ^#' $filename | xargs)
8
+ eval " $envbackup "
9
+ if [ -z " $MOODLE_DOCKER_WWWROOT " ] && [ -f ' lib/moodlelib.php' ];
10
+ then
11
+ # We know that moodle is in current directory, so use it as default value.
12
+ currentdir=" $( pwd -P ) " ;
13
+ export MOODLE_DOCKER_WWWROOT=" $currentdir " ;
14
+ fi
15
+ if [ -z " $COMPOSE_PROJECT_NAME " ] && [ -f ' lib/moodlelib.php' ];
16
+ then
17
+ # Use moodle directory name as default Compose project name.
18
+ name=" $( basename " $( pwd -P ) " ) "
19
+ export COMPOSE_PROJECT_NAME=" $name " ;
20
+ fi
21
+ fi
22
+
23
+ if [ ! -d " $MOODLE_DOCKER_WWWROOT " ]; then
24
+ echo ' Error: MOODLE_DOCKER_WWWROOT is not set or not an existing directory'
25
+ exit 1
26
+ fi
27
+
28
+ if [ -z " $MOODLE_DOCKER_DB " ];
29
+ then
30
+ echo ' Error: MOODLE_DOCKER_DB is not set'
31
+ exit 1
32
+ fi
Original file line number Diff line number Diff line change 7
7
thisfile=$( readlink " ${BASH_SOURCE[0]} " ) || thisfile=" ${BASH_SOURCE[0]} "
8
8
basedir=" $( cd " $( dirname " $thisfile " ) /../" && pwd -P ) "
9
9
10
- if [ ! -d " $MOODLE_DOCKER_WWWROOT " ];
11
- then
12
- echo ' Error: $MOODLE_DOCKER_WWWROOT is not set or not an existing directory'
13
- exit 1
14
- fi
15
-
16
- if [ -z " $MOODLE_DOCKER_DB " ];
17
- then
18
- echo ' Error: $MOODLE_DOCKER_DB is not set'
19
- exit 1
20
- fi
10
+ # Load all environment settings.
11
+ source " ${basedir} /bin/include/env.sh"
21
12
22
13
export ASSETDIR=" ${basedir} /assets"
23
14
Original file line number Diff line number Diff line change 1
1
@ ECHO OFF
2
2
3
- IF NOT EXIST " %MOODLE_DOCKER_WWWROOT% " (
4
- ECHO Error: MOODLE_DOCKER_WWWROOT is not set or not an existing directory
5
- EXIT /B 1
6
- )
7
-
8
- IF " %MOODLE_DOCKER_DB% " == " " (
9
- ECHO Error: MOODLE_DOCKER_DB is not set
10
- EXIT /B 1
11
- )
3
+ setlocal
12
4
13
5
PUSHD %cd%
14
6
CD %~dp0 ..
15
7
SET BASEDIR = %cd%
16
8
POPD
9
+
10
+ call %BASEDIR% \bin\include\env.cmd || EXIT /B 1
11
+
17
12
SET ASSETDIR = %BASEDIR% \assets
18
13
19
14
SET COMPOSE_CONVERT_WINDOWS_PATHS = true
Original file line number Diff line number Diff line change 4
4
thisfile=$( readlink " ${BASH_SOURCE[0]} " ) || thisfile=" ${BASH_SOURCE[0]} "
5
5
basedir=" $( cd " $( dirname " $thisfile " ) /../" && pwd -P ) "
6
6
7
+ # Load all environment settings.
8
+ source " ${basedir} /bin/include/env.sh"
9
+
7
10
if [[ ! -z " $MOODLE_DOCKER_BROWSER " ]] && [[ " $MOODLE_DOCKER_BROWSER " == " chrome" ]] && ([[ ! -z " $MOODLE_DOCKER_APP_PATH " ]] || [[ ! -z " $MOODLE_DOCKER_APP_VERSION " ]] || [[ ! -z " $MOODLE_APP_VERSION " ]]);
8
11
then
9
12
until $basedir /bin/moodle-docker-compose logs moodleapp | grep -q -E ' dev server running: |Angular Live Development Server is listening|Configuration complete; ready for start up' ;
Original file line number Diff line number Diff line change 4
4
thisfile=$( readlink " ${BASH_SOURCE[0]} " ) || thisfile=" ${BASH_SOURCE[0]} "
5
5
basedir=" $( cd " $( dirname " $thisfile " ) /../" && pwd -P ) "
6
6
7
- if [ -z " $MOODLE_DOCKER_DB " ];
8
- then
9
- echo ' Error: $MOODLE_DOCKER_DB is not set'
10
- exit 1
11
- fi
7
+ # Load all environment settings.
8
+ source " ${basedir} /bin/include/env.sh"
12
9
13
10
if [ " $MOODLE_DOCKER_DB " = " mssql" ];
14
11
then
You can’t perform that action at this time.
0 commit comments