diff --git a/.env.example b/.env.example new file mode 100644 index 00000000000..afcb91dbbc4 --- /dev/null +++ b/.env.example @@ -0,0 +1,4 @@ +# Set up path to Moodle code +MOODLE_DOCKER_WWWROOT=/path/to/moodle/code +# Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle) +MOODLE_DOCKER_DB=pgsql diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..4c49bd78f1d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/README.md b/README.md index 757c9837a0b..9c43d88e02f 100755 --- a/README.md +++ b/README.md @@ -18,27 +18,22 @@ This repository contains Docker configuration aimed at Moodle developers and tes ## Quick start -```bash -# Set up path to Moodle code -export MOODLE_DOCKER_WWWROOT=/path/to/moodle/code -# Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle) -export MOODLE_DOCKER_DB=pgsql +1. Download or clone this repository +2. Rename `.env.example` to `.env` +3. Specify Moodle directory and db driver in `.env` +4. Run `bin/create-moodle-config`. This copies the `config.php` into Moodle. +You only have to call this command onces. +4. Run `bin/moodle-docker-compose up -d` inside `moodle-docker` folder to create the container. +5. You may have to call also `bin/moodle-docker-wait-for-db` if you use `oracle/mssql`. -# Ensure customized config.php for the Docker containers is in place -cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php +You can now access Moodle under `localhost:8000`. -# Start up containers -bin/moodle-docker-compose up -d +If you want to destroy the container, run `bin/moodle-docker-compose down`. -# Wait for DB to come up (important for oracle/mssql) -bin/moodle-docker-wait-for-db -# Work with the containers (see below) -# [..] +Everytime you reboot your PC or destroyed the container, you just have to start the container with `bin/moodle-docker-compose up -d` +(and with `bin/moodle-docker-wait-for-db` if you use `oracle/mssql`). -# Shut down and destroy containers -bin/moodle-docker-compose down -``` ## Use containers for running behat tests diff --git a/bin/create-moodle-config b/bin/create-moodle-config new file mode 100755 index 00000000000..3b0c7ae175c --- /dev/null +++ b/bin/create-moodle-config @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +if [ -f .env ]; +then + source .env +fi + +cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php + + diff --git a/bin/moodle-docker-compose b/bin/moodle-docker-compose index fd7bdafc897..6b9523e540b 100755 --- a/bin/moodle-docker-compose +++ b/bin/moodle-docker-compose @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -e +if [ -f .env ]; +then + source .env +fi + if [ ! -d "$MOODLE_DOCKER_WWWROOT" ]; then echo 'Error: $MOODLE_DOCKER_WWWROOT is not set or not an existing directory' diff --git a/bin/moodle-docker-wait-for-db b/bin/moodle-docker-wait-for-db index 9fb25a553ae..9a42f21eb6a 100755 --- a/bin/moodle-docker-wait-for-db +++ b/bin/moodle-docker-wait-for-db @@ -1,6 +1,11 @@ #!/usr/bin/env bash set -e +if [ -f .env ]; +then + source .env +fi + basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" if [ -z "$MOODLE_DOCKER_DB" ];