diff --git a/bin/moodle-compose b/bin/moodle-compose index 2ef04478cbe..a7b3744f53c 100755 --- a/bin/moodle-compose +++ b/bin/moodle-compose @@ -31,6 +31,7 @@ fi if [ -r "$MOODLE_DOCKER_WWWROOT/projectinfo.yml" ]; then MOODLE_CODENAME=$(grep -e '^codename' "$MOODLE_DOCKER_WWWROOT/projectinfo.yml" | awk -F ': ' '{print $2}') MOODLE_DB_TYPE=$(grep -e '^sqltype' "$MOODLE_DOCKER_WWWROOT/projectinfo.yml" | awk -F ': ' '{print $2}') + MOODLE_DOCKER_THEMEDEVEL=$(grep -e '^themedevel' "$MOODLE_DOCKER_WWWROOT/projectinfo.yml" | awk -F ': ' '{print $2}') fi if [ -z "${MOODLE_CODENAME}" ]; then @@ -42,6 +43,7 @@ if [ -z "${MOODLE_CODENAME}" ]; then fi export MOODLE_CODENAME=${MOODLE_CODENAME} +export MOODLE_DOCKER_THEMEDEVEL=${MOODLE_DOCKER_THEMEDEVEL:-} # Related to Moodle if [ -z "${MOODLE_DB_TYPE}" ]; then diff --git a/bin/moodle-docker-compose b/bin/moodle-docker-compose index 0bd794dc131..58d3f9d7250 100755 --- a/bin/moodle-docker-compose +++ b/bin/moodle-docker-compose @@ -31,6 +31,12 @@ dockercompose="${dockercompose} -f ${basedir}/service.mail.yml" # PHP Version. export MOODLE_DOCKER_PHP_VERSION=${MOODLE_DOCKER_PHP_VERSION:-7.3} +# Enable Theme developement mode (specify the theme _name_ in that variable +if [ -n "$MOODLE_DOCKER_THEMEDEVEL" ]; +then + dockercompose="${dockercompose} -f ${basedir}/themedevel.yml" +fi + # Enable Traefik if [ -n "$MOODLE_DOCKER_TRAEFIK" ]; then diff --git a/config.docker-template.php b/config.docker-template.php index bb64db9b8ce..1275d619e90 100644 --- a/config.docker-template.php +++ b/config.docker-template.php @@ -32,6 +32,20 @@ $CFG->wwwroot .= ":{$port}"; } } + +$themedevel = getenv('MOODLE_DOCKER_THEMEDEVEL'); +if (!empty($themedevel)) { + $CFG->theme = $themedevel; + $CFG->devel_custom_additional_head = ''; + + $webhost = getenv('MOODLE_DOCKER_BROWSERSYNC_WEBHOST'); + if (!empty($webhost)) { + $CFG->browsersyncurl = 'https://'.$webhost; + $CFG->wwwroot = 'https://'.$webhost; + $CFG->reverseproxy = true; + } +} + $CFG->dataroot = '/var/www/moodledata'; $CFG->admin = 'admin'; $CFG->directorypermissions = 0777; diff --git a/themedevel.yml b/themedevel.yml new file mode 100644 index 00000000000..57ca60bfc64 --- /dev/null +++ b/themedevel.yml @@ -0,0 +1,38 @@ +version: "2" +services: + themedevel: + image: "node:15" # node-sass doesn't support node 16 https://github.com/sass/node-sass/issues/3077 + depends_on: + - webserver + volumes: + - "${MOODLE_DOCKER_WWWROOT}:/var/www/html" + - "/var/www/html/theme/${MOODLE_DOCKER_THEMEDEVEL}/node_modules" + - "themebuild:/var/www/html/theme/${MOODLE_DOCKER_THEMEDEVEL}/build" + working_dir: /var/www/html/theme/${MOODLE_DOCKER_THEMEDEVEL} + command: bash -c "npm install && npm run start" + ports: + - 3000 + - 3001 + environment: + - MOODLE_DOCKER_THEMEDEVEL=${MOODLE_DOCKER_THEMEDEVEL} + - MOODLE_DOCKER_BROWSERSYNC_WEBHOST=browsersync.${MOODLE_DOCKER_WEB_HOST} + - MOODLE_DOCKER_WEBSERVER_INTERNAL=webserver_for_themedevel + labels: + - "traefik.enable=true" + - "traefik.frontend.rule=Host:browsersync.${MOODLE_DOCKER_WEB_HOST}" + - 'traefik.docker.network=pontsun' + networks: + - default + - pontsun + webserver: + environment: + - MOODLE_DOCKER_THEMEDEVEL=${MOODLE_DOCKER_THEMEDEVEL} + - MOODLE_DOCKER_BROWSERSYNC_WEBHOST=browsersync.${MOODLE_DOCKER_WEB_HOST} + networks: + default: + aliases: + - webserver_for_themedevel + volumes: + - "themebuild:/var/www/html/theme/${MOODLE_DOCKER_THEMEDEVEL}/build" +volumes: + themebuild: