Skip to content

Commit 2058b53

Browse files
committed
add suport for .env files
1 parent d24327b commit 2058b53

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

bin/moodle-docker-compose

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,6 @@
11
#!/usr/bin/env bash
22
set -e
33

4-
if [ ! -d "$MOODLE_DOCKER_WWWROOT" ];
5-
then
6-
echo 'Error: $MOODLE_DOCKER_WWWROOT is not set or not an existing directory'
7-
exit 1
8-
fi
9-
10-
if [ -z "$MOODLE_DOCKER_DB" ];
11-
then
12-
echo 'Error: $MOODLE_DOCKER_DB is not set'
13-
exit 1
14-
fi
15-
164
# Nasty portable way to the directory of this script, following symlink,
175
# because readlink -f not on OSX. Thanks stack overflow..
186
SOURCE="${BASH_SOURCE[0]}"
@@ -24,6 +12,22 @@ done
2412
basedir="$( cd -P "$( dirname "$SOURCE" )/../" && pwd )"
2513
export ASSETDIR="${basedir}/assets"
2614

15+
if [ -f "${basedir}/.env" ];
16+
then
17+
. "${basedir}/.env"
18+
fi
19+
20+
if [ ! -d "$MOODLE_DOCKER_WWWROOT" ];
21+
then
22+
echo 'Error: $MOODLE_DOCKER_WWWROOT is not set or not an existing directory'
23+
exit 1
24+
fi
25+
26+
if [ -z "$MOODLE_DOCKER_DB" ];
27+
then
28+
echo 'Error: $MOODLE_DOCKER_DB is not set'
29+
exit 1
30+
fi
2731

2832
dockercompose="docker-compose -f ${basedir}/base.yml"
2933
dockercompose="${dockercompose} -f ${basedir}/service.mail.yml"
@@ -35,7 +39,6 @@ export MOODLE_DOCKER_PHP_VERSION=${MOODLE_DOCKER_PHP_VERSION:-7.1}
3539
if [ "$MOODLE_DOCKER_DB" != 'pgsql' ];
3640
then
3741
dockercompose="${dockercompose} -f ${basedir}/db.${MOODLE_DOCKER_DB}.yml"
38-
3942
fi
4043

4144
# Support PHP version overrides for DB..
@@ -74,12 +77,10 @@ then
7477
dockercompose="${dockercompose} -f ${basedir}/webserver.port.yml"
7578
fi
7679

77-
7880
# Mac OS Compatbility
7981
if [[ "$(uname)" == "Darwin" ]]; then
8082
# Support https://docs.docker.com/docker-for-mac/osxfs-caching/
8183
dockercompose="${dockercompose} -f ${basedir}/volumes-cached.yml"
8284
fi
8385

84-
8586
$dockercompose $@

0 commit comments

Comments
 (0)