├── .gitattributes ├── .github └── workflows │ ├── auto-author-assign.yml │ └── ci.yml ├── .gitignore ├── .gitpod.yml ├── .gitpod └── setup-env.sh ├── LICENSE ├── README.md ├── assets ├── appbehattests │ └── app.feature ├── exttests │ ├── apache2.conf │ └── apache2_ports.conf └── web │ ├── apache2_faildumps.conf │ └── apache2_mailpit.conf ├── base.yml ├── bbb-mock.yml ├── behat-faildump.yml ├── bin ├── moodle-docker-compose ├── moodle-docker-compose.cmd ├── moodle-docker-wait-for-app └── moodle-docker-wait-for-db ├── config.docker-template.php ├── db.mariadb.port.yml ├── db.mariadb.yml ├── db.mssql.port.yml ├── db.mssql.yml ├── db.mysql.5.6.yml ├── db.mysql.5.7.yml ├── db.mysql.port.yml ├── db.mysql.yml ├── db.oracle.port.yml ├── db.oracle.yml ├── db.pgsql.port.yml ├── db.pgsql.yml ├── matrix-mock.yml ├── mlbackend.yml ├── moodle-app-dev.yml ├── moodle-app.yml ├── phpunit-external-services.yml ├── selenium.chrome.yml ├── selenium.debug.yml ├── service.mail.yml ├── tests ├── app-setup.sh ├── app-teardown.sh ├── app-test.sh ├── behat-setup.sh ├── behat-teardown.sh ├── behat-test.sh ├── integration-setup.sh ├── integration-teardown.sh ├── integration-test.sh ├── phpunit-setup.sh ├── phpunit-teardown.sh └── phpunit-test.sh ├── volumes-cached.yml └── webserver.port.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | bin/moodle-docker-compose.cmd eol=crlf 2 | -------------------------------------------------------------------------------- /.github/workflows/auto-author-assign.yml: -------------------------------------------------------------------------------- 1 | name: Auto Author Assign 2 | 3 | on: 4 | pull_request_target: 5 | types: [ opened, reopened ] 6 | 7 | permissions: 8 | pull-requests: write 9 | 10 | jobs: 11 | assign-author: 12 | name: Auto assign PR 13 | runs-on: ubuntu-latest 14 | steps: 15 | - uses: toshimaru/auto-author-assign@v2.1.0 16 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: moodle-docker CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | integration: 7 | name: Integration checks 8 | runs-on: ubuntu-22.04 9 | 10 | steps: 11 | - name: Checking out moodle-docker 12 | uses: actions/checkout@v4 13 | 14 | - name: Checking out moodle 15 | uses: actions/checkout@v4 16 | with: 17 | repository: moodle/moodle 18 | path: moodle 19 | ref: ${{ matrix.branch }} 20 | 21 | - name: Prepare moodle-docker environment 22 | run: | 23 | cp config.docker-template.php moodle/config.php 24 | tests/integration-setup.sh 25 | 26 | - name: Run moodle-docker tests 27 | run: | 28 | tests/integration-test.sh 29 | 30 | - name: Stop moodle-docker 31 | run: | 32 | tests/integration-teardown.sh 33 | 34 | PHPUnit: 35 | needs: integration 36 | runs-on: ubuntu-22.04 37 | 38 | strategy: 39 | fail-fast: false 40 | matrix: 41 | include: 42 | # PostgreSQL (highest, lowest php supported) 43 | - { branch: main, php: "8.3", database: pgsql, suite: phpunit-full } # Full run only for main. 44 | - { branch: main, php: "8.2", database: pgsql, suite: phpunit-full } 45 | - { branch: MOODLE_405_STABLE, php: "8.3", database: pgsql, suite: phpunit } # Other branches, quicker run. 46 | - { branch: MOODLE_405_STABLE, php: "8.1", database: pgsql, suite: phpunit } 47 | - { branch: MOODLE_404_STABLE, php: "8.3", database: pgsql, suite: phpunit } 48 | - { branch: MOODLE_404_STABLE, php: "8.1", database: pgsql, suite: phpunit } 49 | - { branch: MOODLE_403_STABLE, php: "8.2", database: pgsql, suite: phpunit } 50 | - { branch: MOODLE_403_STABLE, php: "8.0", database: pgsql, suite: phpunit } 51 | - { branch: MOODLE_402_STABLE, php: "8.2", database: pgsql, suite: phpunit } 52 | - { branch: MOODLE_402_STABLE, php: "8.0", database: pgsql, suite: phpunit } 53 | - { branch: MOODLE_401_STABLE, php: "8.1", database: pgsql, suite: phpunit } 54 | - { branch: MOODLE_401_STABLE, php: "7.4", database: pgsql, suite: phpunit } 55 | - { branch: MOODLE_400_STABLE, php: "8.0", database: pgsql, suite: phpunit } 56 | - { branch: MOODLE_400_STABLE, php: "7.3", database: pgsql, suite: phpunit } 57 | - { branch: MOODLE_311_STABLE, php: "8.0", database: pgsql, suite: phpunit } 58 | - { branch: MOODLE_311_STABLE, php: "7.3", database: pgsql, suite: phpunit } 59 | - { branch: MOODLE_310_STABLE, php: "7.4", database: pgsql, suite: phpunit } 60 | - { branch: MOODLE_310_STABLE, php: "7.2", database: pgsql, suite: phpunit } 61 | - { branch: MOODLE_39_STABLE, php: "7.4", database: pgsql, suite: phpunit } 62 | - { branch: MOODLE_39_STABLE, php: "7.2", database: pgsql, suite: phpunit } 63 | # MariaDB (lowest php supported) 64 | - { branch: main, php: "8.2", database: mariadb, suite: phpunit } 65 | - { branch: MOODLE_405_STABLE, php: "8.1", database: mariadb, suite: phpunit } 66 | - { branch: MOODLE_404_STABLE, php: "8.1", database: mariadb, suite: phpunit } 67 | - { branch: MOODLE_403_STABLE, php: "8.0", database: mariadb, suite: phpunit } 68 | - { branch: MOODLE_402_STABLE, php: "8.0", database: mariadb, suite: phpunit } 69 | - { branch: MOODLE_401_STABLE, php: "7.4", database: mariadb, suite: phpunit } 70 | - { branch: MOODLE_400_STABLE, php: "7.3", database: mariadb, suite: phpunit } 71 | - { branch: MOODLE_311_STABLE, php: "7.3", database: mariadb, suite: phpunit } 72 | - { branch: MOODLE_310_STABLE, php: "7.2", database: mariadb, suite: phpunit } 73 | - { branch: MOODLE_39_STABLE, php: "7.2", database: mariadb, suite: phpunit } 74 | # Other databases (highest php supported) 75 | - { branch: main, php: "8.3", database: mssql, suite: phpunit } 76 | - { branch: MOODLE_405_STABLE, php: "8.3", database: mssql, suite: phpunit } 77 | - { branch: MOODLE_404_STABLE, php: "8.3", database: mssql, suite: phpunit } 78 | - { branch: MOODLE_403_STABLE, php: "8.2", database: mssql, suite: phpunit } 79 | - { branch: MOODLE_402_STABLE, php: "8.2", database: mssql, suite: phpunit } 80 | - { branch: MOODLE_401_STABLE, php: "8.1", database: mssql, suite: phpunit } 81 | - { branch: MOODLE_400_STABLE, php: "8.0", database: mssql, suite: phpunit } 82 | - { branch: MOODLE_311_STABLE, php: "8.0", database: mssql, suite: phpunit } 83 | - { branch: MOODLE_310_STABLE, php: "7.4", database: mssql, suite: phpunit } 84 | - { branch: MOODLE_39_STABLE, php: "7.4", database: mssql, suite: phpunit } 85 | - { branch: main, php: "8.3", database: mysql, suite: phpunit } 86 | - { branch: MOODLE_405_STABLE, php: "8.3", database: mysql, suite: phpunit } 87 | - { branch: MOODLE_404_STABLE, php: "8.3", database: mysql, suite: phpunit } 88 | - { branch: MOODLE_403_STABLE, php: "8.2", database: mysql, suite: phpunit } 89 | - { branch: MOODLE_402_STABLE, php: "8.2", database: mysql, suite: phpunit } 90 | - { branch: MOODLE_401_STABLE, php: "8.1", database: mysql, suite: phpunit } 91 | - { branch: MOODLE_400_STABLE, php: "8.0", database: mysql, suite: phpunit } 92 | - { branch: MOODLE_311_STABLE, php: "8.0", database: mysql, suite: phpunit } 93 | - { branch: MOODLE_310_STABLE, php: "7.4", database: mysql, suite: phpunit } 94 | - { branch: MOODLE_39_STABLE, php: "7.4", database: mysql, suite: phpunit } 95 | - { branch: MOODLE_405_STABLE, php: "8.3", database: oracle, suite: phpunit } 96 | - { branch: MOODLE_404_STABLE, php: "8.3", database: oracle, suite: phpunit } 97 | - { branch: MOODLE_403_STABLE, php: "8.2", database: oracle, suite: phpunit } 98 | - { branch: MOODLE_402_STABLE, php: "8.2", database: oracle, suite: phpunit } 99 | - { branch: MOODLE_401_STABLE, php: "8.1", database: oracle, suite: phpunit } 100 | - { branch: MOODLE_400_STABLE, php: "8.0", database: oracle, suite: phpunit } 101 | - { branch: MOODLE_311_STABLE, php: "8.0", database: oracle, suite: phpunit } 102 | - { branch: MOODLE_310_STABLE, php: "7.4", database: oracle, suite: phpunit } 103 | - { branch: MOODLE_39_STABLE, php: "7.4", database: oracle, suite: phpunit } 104 | 105 | steps: 106 | - name: Checking out moodle-docker 107 | uses: actions/checkout@v4 108 | 109 | - name: Checking out moodle 110 | uses: actions/checkout@v4 111 | with: 112 | repository: moodle/moodle 113 | path: moodle 114 | ref: ${{ matrix.branch }} 115 | 116 | - name: Prepare moodle-docker environment 117 | run: | 118 | cp config.docker-template.php moodle/config.php 119 | export MOODLE_DOCKER_DB="${{ matrix.database }}" 120 | export MOODLE_DOCKER_PHP_VERSION="${{ matrix.php }}" 121 | export SUITE="${{ matrix.suite }}" 122 | tests/phpunit-setup.sh 123 | 124 | - name: Run moodle-docker tests 125 | run: | 126 | export MOODLE_DOCKER_DB="${{ matrix.database }}" 127 | export SUITE="${{ matrix.suite }}" 128 | tests/phpunit-test.sh 129 | 130 | - name: Stop moodle-docker 131 | run: | 132 | export MOODLE_DOCKER_DB="${{ matrix.database }}" 133 | export SUITE="${{ matrix.suite }}" 134 | tests/phpunit-teardown.sh 135 | 136 | Behat: 137 | needs: integration 138 | runs-on: ubuntu-22.04 139 | 140 | strategy: 141 | fail-fast: false 142 | matrix: 143 | include: 144 | # PostgreSQL (highest, lowest php supported) 145 | - { branch: main, php: "8.3", database: pgsql, browser: chrome, suite: behat } 146 | - { branch: main, php: "8.2", database: pgsql, browser: firefox, suite: behat } 147 | - { branch: MOODLE_405_STABLE, php: "8.3", database: pgsql, browser: chrome, suite: behat } 148 | - { branch: MOODLE_405_STABLE, php: "8.1", database: pgsql, browser: firefox, suite: behat } 149 | - { branch: MOODLE_404_STABLE, php: "8.3", database: pgsql, browser: chrome, suite: behat } 150 | - { branch: MOODLE_404_STABLE, php: "8.1", database: pgsql, browser: firefox, suite: behat } 151 | - { branch: MOODLE_403_STABLE, php: "8.2", database: pgsql, browser: chrome, suite: behat } 152 | - { branch: MOODLE_403_STABLE, php: "8.0", database: pgsql, browser: firefox, suite: behat } 153 | - { branch: MOODLE_402_STABLE, php: "8.2", database: pgsql, browser: chrome, suite: behat } 154 | - { branch: MOODLE_402_STABLE, php: "8.0", database: pgsql, browser: firefox, suite: behat } 155 | - { branch: MOODLE_401_STABLE, php: "8.1", database: pgsql, browser: chrome, suite: behat } 156 | - { branch: MOODLE_401_STABLE, php: "7.4", database: pgsql, browser: firefox, suite: behat } 157 | - { branch: MOODLE_400_STABLE, php: "8.0", database: pgsql, browser: chrome, suite: behat } 158 | - { branch: MOODLE_400_STABLE, php: "7.3", database: pgsql, browser: firefox, suite: behat } 159 | - { branch: MOODLE_311_STABLE, php: "8.0", database: pgsql, browser: chrome, suite: behat } 160 | - { branch: MOODLE_311_STABLE, php: "7.3", database: pgsql, browser: firefox, suite: behat } 161 | - { branch: MOODLE_310_STABLE, php: "7.4", database: pgsql, browser: chrome, suite: behat } 162 | - { branch: MOODLE_310_STABLE, php: "7.2", database: pgsql, browser: firefox, suite: behat } 163 | - { branch: MOODLE_39_STABLE, php: "7.4", database: pgsql, browser: chrome, suite: behat } 164 | - { branch: MOODLE_39_STABLE, php: "7.2", database: pgsql, browser: firefox, suite: behat } 165 | # MariaDB (lowest php supported) 166 | - { branch: main, php: "8.2", database: mariadb, browser: chrome, suite: behat } 167 | - { branch: MOODLE_405_STABLE, php: "8.1", database: mariadb, browser: firefox, suite: behat } 168 | - { branch: MOODLE_404_STABLE, php: "8.1", database: mariadb, browser: firefox, suite: behat } 169 | - { branch: MOODLE_403_STABLE, php: "8.0", database: mariadb, browser: firefox, suite: behat } 170 | - { branch: MOODLE_402_STABLE, php: "8.0", database: mariadb, browser: firefox, suite: behat } 171 | - { branch: MOODLE_401_STABLE, php: "7.4", database: mariadb, browser: chrome, suite: behat } 172 | - { branch: MOODLE_400_STABLE, php: "7.3", database: mariadb, browser: firefox, suite: behat } 173 | - { branch: MOODLE_311_STABLE, php: "7.3", database: mariadb, browser: chrome, suite: behat } 174 | - { branch: MOODLE_310_STABLE, php: "7.2", database: mariadb, browser: firefox, suite: behat } 175 | - { branch: MOODLE_39_STABLE, php: "7.2", database: mariadb, browser: chrome, suite: behat } 176 | # Other databases (highest php supported") 177 | - { branch: main, php: "8.3", database: mssql, browser: firefox, suite: behat } 178 | - { branch: MOODLE_405_STABLE, php: "8.3", database: mssql, browser: chrome, suite: behat } 179 | - { branch: MOODLE_404_STABLE, php: "8.3", database: mssql, browser: chrome, suite: behat } 180 | - { branch: MOODLE_403_STABLE, php: "8.2", database: mssql, browser: chrome, suite: behat } 181 | - { branch: MOODLE_402_STABLE, php: "8.2", database: mssql, browser: chrome, suite: behat } 182 | - { branch: MOODLE_401_STABLE, php: "8.1", database: mssql, browser: firefox, suite: behat } 183 | - { branch: MOODLE_400_STABLE, php: "8.0", database: mssql, browser: chrome, suite: behat } 184 | - { branch: MOODLE_311_STABLE, php: "8.0", database: mssql, browser: firefox, suite: behat } 185 | - { branch: MOODLE_310_STABLE, php: "7.4", database: mssql, browser: chrome, suite: behat } 186 | - { branch: MOODLE_39_STABLE, php: "7.4", database: mssql, browser: firefox, suite: behat } 187 | - { branch: main, php: "8.3", database: mysql, browser: chrome, suite: behat } 188 | - { branch: MOODLE_405_STABLE, php: "8.3", database: mysql, browser: firefox, suite: behat } 189 | - { branch: MOODLE_404_STABLE, php: "8.3", database: mysql, browser: firefox, suite: behat } 190 | - { branch: MOODLE_403_STABLE, php: "8.2", database: mysql, browser: firefox, suite: behat } 191 | - { branch: MOODLE_402_STABLE, php: "8.2", database: mysql, browser: firefox, suite: behat } 192 | - { branch: MOODLE_401_STABLE, php: "8.1", database: mysql, browser: chrome, suite: behat } 193 | - { branch: MOODLE_400_STABLE, php: "8.0", database: mysql, browser: firefox, suite: behat } 194 | - { branch: MOODLE_311_STABLE, php: "8.0", database: mysql, browser: chrome, suite: behat } 195 | - { branch: MOODLE_310_STABLE, php: "7.4", database: mysql, browser: firefox, suite: behat } 196 | - { branch: MOODLE_39_STABLE, php: "7.4", database: mysql, browser: chrome, suite: behat } 197 | - { branch: MOODLE_405_STABLE, php: "8.3", database: oracle, browser: chrome, suite: behat } 198 | - { branch: MOODLE_404_STABLE, php: "8.3", database: oracle, browser: chrome, suite: behat } 199 | - { branch: MOODLE_403_STABLE, php: "8.2", database: oracle, browser: chrome, suite: behat } 200 | - { branch: MOODLE_402_STABLE, php: "8.2", database: oracle, browser: chrome, suite: behat } 201 | - { branch: MOODLE_401_STABLE, php: "8.1", database: oracle, browser: firefox, suite: behat } 202 | - { branch: MOODLE_400_STABLE, php: "8.0", database: oracle, browser: chrome, suite: behat } 203 | - { branch: MOODLE_311_STABLE, php: "8.0", database: oracle, browser: firefox, suite: behat } 204 | - { branch: MOODLE_310_STABLE, php: "7.4", database: oracle, browser: chrome, suite: behat } 205 | - { branch: MOODLE_39_STABLE, php: "7.4", database: oracle, browser: firefox, suite: behat } 206 | 207 | steps: 208 | - name: Checking out moodle-docker 209 | uses: actions/checkout@v4 210 | 211 | - name: Checking out moodle 212 | uses: actions/checkout@v4 213 | with: 214 | repository: moodle/moodle 215 | path: moodle 216 | ref: ${{ matrix.branch }} 217 | 218 | - name: Prepare moodle-docker environment 219 | run: | 220 | cp config.docker-template.php moodle/config.php 221 | export MOODLE_DOCKER_DB="${{ matrix.database }}" 222 | export MOODLE_DOCKER_PHP_VERSION="${{ matrix.php }}" 223 | export SUITE="${{ matrix.suite }}" 224 | export MOODLE_DOCKER_BROWSER="${{ matrix.browser }}" 225 | tests/behat-setup.sh 226 | 227 | - name: Run moodle-docker tests 228 | run: | 229 | export MOODLE_DOCKER_DB="${{ matrix.database }}" 230 | export SUITE="${{ matrix.suite }}" 231 | tests/behat-test.sh 232 | 233 | - name: Stop moodle-docker 234 | run: | 235 | export MOODLE_DOCKER_DB="${{ matrix.database }}" 236 | export SUITE="${{ matrix.suite }}" 237 | tests/behat-teardown.sh 238 | 239 | App: 240 | needs: integration 241 | runs-on: ubuntu-22.04 242 | 243 | strategy: 244 | fail-fast: false 245 | matrix: 246 | include: 247 | # PostgreSQL (highest, lowest php supported) 248 | # First tests are for app developers. 249 | - { branch: MOODLE_405_STABLE, php: "8.3", suite: app-development, app-version: "latest" } 250 | - { branch: MOODLE_405_STABLE, php: "8.1", suite: app-development, app-version: "latest" } 251 | - { branch: MOODLE_405_STABLE, php: "8.3", suite: app-development, app-version: "main" } 252 | - { branch: MOODLE_405_STABLE, php: "8.1", suite: app-development, app-version: "main" } 253 | # Tests for Moodle plugin developers who want to test against the next version of the app. 254 | - { branch: MOODLE_405_STABLE, php: "8.3", suite: app, app-version: "next-test" } 255 | - { branch: MOODLE_405_STABLE, php: "8.1", suite: app, app-version: "next-test" } 256 | # Tests for Moodle plugin developers testing against all supported versions of Moodle. 257 | - { branch: MOODLE_405_STABLE, php: "8.3", suite: app, app-version: "latest-test" } 258 | - { branch: MOODLE_405_STABLE, php: "8.1", suite: app, app-version: "latest-test" } 259 | - { branch: MOODLE_404_STABLE, php: "8.3", suite: app, app-version: "latest-test" } 260 | - { branch: MOODLE_404_STABLE, php: "8.1", suite: app, app-version: "latest-test" } 261 | - { branch: MOODLE_403_STABLE, php: "8.2", suite: app, app-version: "latest-test" } 262 | - { branch: MOODLE_403_STABLE, php: "8.0", suite: app, app-version: "latest-test" } 263 | - { branch: MOODLE_401_STABLE, php: "8.1", suite: app, app-version: "latest-test" } 264 | - { branch: MOODLE_401_STABLE, php: "7.4", suite: app, app-version: "latest-test" } 265 | 266 | steps: 267 | - name: Checking out moodle-docker 268 | uses: actions/checkout@v4 269 | 270 | - name: Checking out moodle 271 | uses: actions/checkout@v4 272 | with: 273 | repository: moodle/moodle 274 | path: moodle 275 | ref: ${{ matrix.branch }} 276 | 277 | - name: Prepare moodle-docker environment 278 | run: | 279 | cp config.docker-template.php moodle/config.php 280 | export MOODLE_DOCKER_PHP_VERSION="${{ matrix.php }}" 281 | export SUITE="${{ matrix.suite }}" 282 | export MOODLE_DOCKER_APP_VERSION="${{ matrix.app-version }}" 283 | tests/app-setup.sh 284 | 285 | - name: Run moodle-docker tests 286 | run: | 287 | export MOODLE_DOCKER_APP_VERSION="${{ matrix.app-version }}" 288 | export SUITE="${{ matrix.suite }}" 289 | tests/app-test.sh 290 | 291 | - name: Stop moodle-docker 292 | run: | 293 | export SUITE="${{ matrix.suite }}" 294 | export MOODLE_DOCKER_APP_VERSION="${{ matrix.app-version }}" 295 | tests/app-teardown.sh 296 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | local.yml 2 | /moodle/ 3 | -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | tasks: 2 | - name: Moodle Docker 3 | 4 | before: | 5 | # Set up Moodle docker environment vars. 6 | export COMPOSE_PROJECT_NAME=moodle-gitpod 7 | export MOODLE_DOCKER_WWWROOT="$GITPOD_REPO_ROOT"/moodle 8 | export MOODLE_DOCKER_DB=pgsql 9 | 10 | init: | 11 | # Set up Moodle repository. 12 | .gitpod/setup-env.sh 13 | 14 | # Ensure customized config.php for the Docker containers is in place 15 | cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php 16 | 17 | # Start up containers. 18 | bin/moodle-docker-compose up -d 19 | 20 | # Wait for DB to come up. 21 | bin/moodle-docker-wait-for-db 22 | 23 | # Initialize Moodle database for manual testing. 24 | bin/moodle-docker-compose exec webserver php admin/cli/install_database.php --agree-license --fullname="Docker moodle" --shortname="docker_moodle" --summary="Docker moodle site" --adminpass="test" --adminemail="admin@example.com" 25 | 26 | # Hack to avoid when the workspace is restarted. 27 | # It can be removed when https://github.com/gitpod-io/gitpod/issues/17551 is fixed. 28 | bin/moodle-docker-compose exec webserver bash -c 'rm -rf /var/log/apache2/*' 29 | 30 | # Open Moodle site in browser. 31 | gp ports await 8000 && gp preview $(gp url 8000) 32 | 33 | # Change permissions to allow installation of plugins. 34 | bin/moodle-docker-compose exec webserver bash -c 'chmod -R 777 .' 35 | 36 | # Add some data if the file exists. 37 | if [ -r "moodle/admin/tool/generator/tests/fixtures/gitpod-basic-scenario.feature" ]; 38 | then 39 | bin/moodle-docker-compose exec webserver php admin/tool/generator/cli/runtestscenario.php --feature=./../tests/fixtures/gitpod-basic-scenario.feature 40 | fi 41 | 42 | command: | 43 | # Update the patch to the latest version. 44 | cd moodle 45 | git fetch $(git rev-parse --symbolic-full-name --abbrev-ref @{upstream} | sed 's!/! !') 46 | git reset --hard 47 | cd .. 48 | 49 | # Start up containers. 50 | bin/moodle-docker-compose up -d 51 | 52 | # Wait for DB to come up. 53 | bin/moodle-docker-wait-for-db 54 | 55 | ports: 56 | - port: 8000 57 | name: Moodle server 58 | visibility: public 59 | onOpen: ignore 60 | -------------------------------------------------------------------------------- /.gitpod/setup-env.sh: -------------------------------------------------------------------------------- 1 | # Initialize variables to get Moodle code. 2 | if [ -z "$MOODLE_REPOSITORY" ]; 3 | then 4 | export MOODLE_REPOSITORY=https://github.com/moodle/moodle.git 5 | fi 6 | if [ -z "$MOODLE_BRANCH" ]; 7 | then 8 | export MOODLE_BRANCH=main 9 | fi 10 | 11 | if [ -z "$CLONEALL" ]; 12 | then 13 | FASTCLONE='--depth 1' 14 | else 15 | FASTCLONE="" 16 | fi 17 | 18 | # Clone Moodle repository. 19 | cd "${GITPOD_REPO_ROOT}" && git clone ${FASTCLONE} --branch "${MOODLE_BRANCH}" --single-branch "${MOODLE_REPOSITORY}" moodle 20 | 21 | # Download the data file (if given). It will be used to generate some data. 22 | if [ -n "$DATAFILE" ]; 23 | then 24 | wget -O moodle/admin/tool/generator/tests/fixtures/gitpod-basic-scenario.feature "${DATAFILE}" 25 | fi 26 | 27 | # Install adminer. 28 | if [ -n "$INSTALLADMINER" ]; 29 | then 30 | cat << EOF > local.yml 31 | services: 32 | 33 | adminer: 34 | image: adminer:latest 35 | restart: always 36 | ports: 37 | - 8080:8080 38 | depends_on: 39 | - "db" 40 | EOF 41 | fi 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # moodle-docker: Docker Containers for Moodle Developers 2 | [![moodle-docker CI](https://github.com/moodlehq/moodle-docker/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/moodlehq/moodle-docker/actions/workflows/ci.yml) 3 | 4 | This repository contains Docker configuration aimed at Moodle developers and testers to easily deploy a testing environment for Moodle. 5 | 6 | ## Features: 7 | * All supported database servers (PostgreSQL, MySQL, Micosoft SQL Server, Oracle XE) 8 | * Behat/Selenium configuration for Firefox and Chrome 9 | * Catch-all smtp server and web interface to messages using [Mailpit](https://github.com/axllent/mailpit) 10 | * All PHP Extensions enabled configured for external services (e.g. solr, ldap) 11 | * All supported PHP versions 12 | * Zero-configuration approach 13 | * Backed by [automated tests](https://travis-ci.com/moodlehq/moodle-docker/branches) 14 | 15 | ## Prerequisites 16 | * [Docker](https://docs.docker.com) and [Docker Compose](https://docs.docker.com/compose/cli-command/#installing-compose-v2) installed if your Docker CLI version does not support `docker compose` command. 17 | * It's recommended to always run the latest versions of each, but at the minimum Docker v20.10.15 and Docker Compose v2.5.0 should be used. 18 | * 3.25GB of RAM (if you choose [Microsoft SQL Server](https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup#prerequisites) as db server) 19 | 20 | ## Quick start 21 | 22 | ```bash 23 | # Change ./moodle to your /path/to/moodle if you already have it checked out 24 | export MOODLE_DOCKER_WWWROOT=./moodle 25 | 26 | # Choose a db server (Currently supported: pgsql, mariadb, mysql, mssql, oracle) 27 | export MOODLE_DOCKER_DB=pgsql 28 | 29 | # Get Moodle code, you could select another version branch (skip this if you already got the code) 30 | git clone -b [MOODLE_BRANCH] git://git.moodle.org/moodle.git $MOODLE_DOCKER_WWWROOT 31 | 32 | # Ensure customized config.php for the Docker containers is in place 33 | cp config.docker-template.php $MOODLE_DOCKER_WWWROOT/config.php 34 | 35 | # Start up containers 36 | bin/moodle-docker-compose up -d 37 | 38 | # Wait for DB to come up (important for oracle/mssql) 39 | bin/moodle-docker-wait-for-db 40 | 41 | # Work with the containers (see below) 42 | # [..] 43 | 44 | # Shut down and destroy containers 45 | bin/moodle-docker-compose down 46 | ``` 47 | ## Run several Moodle instances 48 | 49 | By default, the script will load a single instance. If you want to run two 50 | or more different versions of Moodle at the same time, you have to add this 51 | environment variable prior running any of the steps at `Quick start`: 52 | 53 | ```bash 54 | # Define a project name; it will appear as a prefix on container names. 55 | export COMPOSE_PROJECT_NAME=moodle34 56 | 57 | # Use a different public web port from those already taken 58 | export MOODLE_DOCKER_WEB_PORT=1234 59 | 60 | # [..] run all "Quick steps" now 61 | ``` 62 | 63 | Having set up several Moodle instances, you need to have set up 64 | the environment variable `COMPOSE_PROJECT_NAME` to just refer 65 | to the instance you expect to. See 66 | [envvars](https://docs.docker.com/compose/reference/envvars/) 67 | to see more about `docker-compose` environment variables. 68 | 69 | ## Use containers for running behat tests 70 | 71 | ```bash 72 | # Initialize behat environment 73 | bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php 74 | # [..] 75 | 76 | # Run behat tests 77 | bin/moodle-docker-compose exec -u www-data webserver php admin/tool/behat/cli/run.php --tags=@auth_manual 78 | Running single behat site: 79 | Moodle 3.4dev (Build: 20171006), 33a3ec7c9378e64c6f15c688a3c68a39114aa29d 80 | Php: 7.1.9, pgsql: 9.6.5, OS: Linux 4.9.49-moby x86_64 81 | Server OS "Linux", Browser: "firefox" 82 | Started at 25-05-2017, 19:04 83 | ............... 84 | 85 | 2 scenarios (2 passed) 86 | 15 steps (15 passed) 87 | 1m35.32s (41.60Mb) 88 | ``` 89 | 90 | Notes: 91 | 92 | * The behat faildump directory is exposed at http://localhost:8000/_/faildumps/. 93 | * Use `MOODLE_DOCKER_BROWSER` to switch the browser you want to run the test against. 94 | You need to recreate your containers using `bin/moodle-docker-compose` as described below, if you change it. 95 | 96 | ## Use containers for running phpunit tests 97 | 98 | ```bash 99 | # Initialize phpunit environment 100 | bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/init.php 101 | # [..] 102 | 103 | # Run phpunit tests 104 | 105 | bin/moodle-docker-compose exec webserver vendor/bin/phpunit auth/manual/tests/manual_test.php 106 | Moodle 4.0.4 (Build: 20220912), ef7a51dcb8e805a6889974b04d3154ba8bd874f2 107 | Php: 7.3.33, pgsql: 11.15 (Debian 11.15-1.pgdg90+1), OS: Linux 5.10.0-11-amd64 x86_64 108 | PHPUnit 9.5.13 by Sebastian Bergmann and contributors. 109 | 110 | .. 2 / 2 (100%) 111 | 112 | Time: 00:00.304, Memory: 72.50 MB 113 | 114 | OK (2 tests, 7 assertions) 115 | ``` 116 | 117 | Notes: 118 | * If you want to run tests with code coverage reports: 119 | ``` 120 | # Build component configuration 121 | bin/moodle-docker-compose exec webserver php admin/tool/phpunit/cli/util.php --buildcomponentconfigs 122 | # Execute tests for component 123 | bin/moodle-docker-compose exec webserver php -d pcov.enabled=1 -d pcov.directory=. vendor/bin/phpunit --configuration reportbuilder --coverage-text 124 | ``` 125 | * See available [Command-Line Options](https://phpunit.readthedocs.io/en/9.5/textui.html#textui-clioptions) for further info 126 | 127 | ## Use containers for manual testing 128 | 129 | ```bash 130 | # Initialize Moodle database for manual testing 131 | bin/moodle-docker-compose exec webserver php admin/cli/install_database.php --agree-license --fullname="Docker moodle" --shortname="docker_moodle" --summary="Docker moodle site" --adminpass="test" --adminemail="admin@example.com" 132 | ``` 133 | 134 | Notes: 135 | * Moodle is configured to listen on `http://localhost:8000/`. 136 | * Mailpit is listening on `http://localhost:8000/_/mail` to view emails which Moodle has sent out. 137 | * The admin `username` you need to use for logging in is `admin` by default. You can customize it by passing `--adminuser='myusername'` 138 | * During manual testing, if you are facing that your Moodle site is logging 139 | you off continuously, putting the correct credentials, clean all cookies 140 | for your Moodle site URL (usually `localhost`) from your browser. 141 | [More info](https://github.com/moodlehq/moodle-docker/issues/256). 142 | 143 | ## Use containers for running behat tests for the Moodle App 144 | 145 | In order to run Behat tests for the Moodle App, you need to install the [local_moodleappbehat](https://github.com/moodlehq/moodle-local_moodleappbehat) plugin in your Moodle site. Everything else should be the same as running standard Behat tests for Moodle. Make sure to filter tests using the `@app` tag. 146 | 147 | The Behat tests will be run against a container serving the mobile application, you have two options here: 148 | 149 | 1. Use a Docker image that includes the application code. You need to specify the `MOODLE_DOCKER_APP_VERSION` env variable and the [moodlehq/moodleapp](https://hub.docker.com/r/moodlehq/moodleapp) image will be downloaded from Docker Hub. You can read about the available images in [Moodle App Docker Images](https://moodledev.io/general/app/development/setup/docker-images) (for Behat, you'll want to run the ones with the `-test` suffix). 150 | 151 | 2. Use a local copy of the application code and serve it through Docker, similar to how the Moodle site is being served. Set the `MOODLE_DOCKER_APP_PATH` env variable to the codebase in you file system. This will assume that you've already initialized the app calling `npm install` locally. 152 | 153 | For both options, you also need to set `MOODLE_DOCKER_BROWSER` to "chrome". 154 | 155 | ```bash 156 | # Install local_moodleappbehat plugin 157 | git clone https://github.com/moodlehq/moodle-local_moodleappbehat "$MOODLE_DOCKER_WWWROOT/local/moodleappbehat" 158 | 159 | # Initialize behat environment 160 | bin/moodle-docker-compose exec webserver php admin/tool/behat/cli/init.php 161 | # (you should see "Configured app tests for version X.X.X" here) 162 | 163 | # Run behat tests 164 | bin/moodle-docker-compose exec -u www-data webserver php admin/tool/behat/cli/run.php --tags="@app&&@mod_login" 165 | Running single behat site: 166 | Moodle 4.0dev (Build: 20200615), a2b286ce176fbe361f0889abc8f30f043cd664ae 167 | Php: 7.2.30, pgsql: 11.8 (Debian 11.8-1.pgdg90+1), OS: Linux 5.3.0-61-generic x86_64 168 | Server OS "Linux", Browser: "chrome" 169 | Browser specific fixes have been applied. See http://docs.moodle.org/dev/Acceptance_testing#Browser_specific_fixes 170 | Started at 13-07-2020, 18:34 171 | ..................................................................... 172 | 173 | 4 scenarios (4 passed) 174 | 69 steps (69 passed) 175 | 3m3.17s (55.02Mb) 176 | ``` 177 | 178 | If you are going with the second option, this *can* be used for local development of the Moodle App, given that the `moodleapp` container serves the app on the local 8100 port. However, this is intended to run Behat tests that require interacting with a local Moodle environment. Normal development should be easier calling `npm start` in the host system. 179 | 180 | By all means, if you don't want to have npm installed locally you can go full Docker executing the following commands before starting the containers: 181 | 182 | ``` 183 | docker run --volume $MOODLE_DOCKER_APP_PATH:/app --workdir /app bash -c "npm install" 184 | ``` 185 | 186 | You can learn more about writing tests for the app in [Acceptance testing for the Moodle App](https://moodledev.io/general/app/development/testing/acceptance-testing). 187 | 188 | ## Using VNC to view behat tests 189 | 190 | If `MOODLE_DOCKER_SELENIUM_VNC_PORT` is defined, selenium will expose a VNC session on the port specified so behat tests can be viewed in progress. 191 | 192 | For example, if you set `MOODLE_DOCKER_SELENIUM_VNC_PORT` to 5900.. 193 | 1. Download a VNC client: https://www.realvnc.com/en/connect/download/viewer/ 194 | 2. With the containers running, enter 0.0.0.0:5900 as the port in VNC Viewer. You will be prompted for a password. The password is 'secret'. 195 | 3. You should be able to see an empty Desktop. When you run any [Javascript requiring Behat tests](https://moodledev.io/general/development/tools/behat#javascript) (e.g. those tagged `@javascript`) a browser will popup and you will see the tests execute. 196 | 197 | ## Stop and restart containers 198 | 199 | `bin/moodle-docker-compose down` which was used above after using the containers stops and destroys the containers. If you want to use your containers continuously for manual testing or development without starting them up from scratch everytime you use them, you can also just stop without destroying them. With this approach, you can restart your containers sometime later, they will keep their data and won't be destroyed completely until you run `bin/moodle-docker-compose down`. 200 | 201 | ```bash 202 | # Stop containers 203 | bin/moodle-docker-compose stop 204 | 205 | # Restart containers 206 | bin/moodle-docker-compose start 207 | ``` 208 | 209 | ## Environment variables 210 | 211 | You can change the configuration of the docker images by setting various environment variables **before** calling `bin/moodle-docker-compose up`. 212 | When you change them, use `bin/moodle-docker-compose down && bin/moodle-docker-compose up -d` to recreate your environment. 213 | 214 | | Environment Variable | Mandatory | Allowed values | Default value | Notes | 215 | |-------------------------------------------|-----------|---------------------------------------|---------------|------------------------------------------------------------------------------| 216 | | `MOODLE_DOCKER_DB` | yes | pgsql, mariadb, mysql, mssql, oracle | none | The database server to run against | 217 | | `MOODLE_DOCKER_WWWROOT` | yes | path on your file system | none | The path to the Moodle codebase you intend to test | 218 | | `MOODLE_DOCKER_DB_VERSION` | no | Docker tag - see relevant database page on docker-hub | mysql: 8.0
pgsql: 13
mariadb: 10.7
mssql: 2017-latest
oracle: 21| The database server docker image tag | 219 | | `MOODLE_DOCKER_PHP_VERSION` | no | 8.4, 8.3, 8.2, 8.1, 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6| 8.2 | The php version to use | 220 | | `MOODLE_DOCKER_BROWSER` | no | firefox, chrome, firefox:<tag>, chrome:<tag> | firefox:3 | The browser to run Behat against. Supports a colon notation to specify a specific Selenium docker image version to use. e.g. firefox:2.53.1 can be used to run with older versions of Moodle (<3.5) | 221 | | `MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES` | no | any value | not set | If set, dependencies for memcached, redis, solr, and openldap are added | 222 | | `MOODLE_DOCKER_BBB_MOCK` | no | any value | not set | If set the BigBlueButton mock image is started and configured | 223 | | `MOODLE_DOCKER_MATRIX_MOCK` | no | any value | not set | If set the Matrix mock image is started and configured | 224 | | `MOODLE_DOCKER_MLBACKEND` | no | any value | not set | If set the Python Machine Learning image is started and configured | 225 | | `MOODLE_DOCKER_BEHAT_FAILDUMP` | no | Path on your file system | not set | Behat faildumps are already available at http://localhost:8000/_/faildumps/ by default, this allows for mapping a specific filesystem folder to retrieve the faildumps in bulk / automated ways | 226 | | `MOODLE_DOCKER_DB_PORT` | no | any integer value | none | If you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all). Username is "moodle" (or "sa" for mssql) and password is "m@0dl3ing". | 227 | | `MOODLE_DOCKER_WEB_HOST` | no | any valid hostname | localhost | The hostname for web | 228 | | `MOODLE_DOCKER_WEB_PORT` | no | any integer value (or bind_ip:integer)| 127.0.0.1:8000| The port number for web. If set to 0, no port is used.
If you want to bind to any host IP different from the default 127.0.0.1, you can specify it with the bind_ip:port format (0.0.0.0 means bind to all) | 229 | | `MOODLE_DOCKER_SELENIUM_VNC_PORT` | no | any integer value (or bind_ip:integer)| not set | If set, the selenium node will expose a vnc session on the port specified. Similar to MOODLE_DOCKER_WEB_PORT, you can optionally define the host IP to bind to. If you just set the port, VNC binds to 127.0.0.1 | 230 | | `MOODLE_DOCKER_APP_PATH` | no | path on your file system | not set | If set and the chrome browser is selected, it will start an instance of the Moodle app from your local codebase | 231 | | `MOODLE_DOCKER_APP_VERSION` | no | a valid [app docker image version](https://docs.moodle.org/dev/Moodle_App_Docker_images) | not set | If set will start an instance of the Moodle app if the chrome browser is selected | 232 | | `MOODLE_DOCKER_TIMEOUT_FACTOR` | no | any integer value | 1 | If set the timeouts in behat will be multiplied by the factor | 233 | 234 | In addition to that, `MOODLE_DOCKER_RUNNING=1` env variable is defined and available 235 | in the webserver container to flag being run by `moodle-docker`. Developer 236 | can use this to conditionally make changes in `config.php`. The common case is 237 | to load test-specific configuration: 238 | ``` 239 | // Load moodle-docker config file if we are in moodle-docker environment 240 | if (getenv('MOODLE_DOCKER_RUNNING')) { 241 | require_once(__DIR__ . '/config.docker-template.php'); 242 | } 243 | 244 | require_once(__DIR__ . '/lib/setup.php'); // Do not edit. 245 | ``` 246 | 247 | ## Local customisations 248 | 249 | In some situations you may wish to add local customisations, such as including additional containers, or changing existing containers. 250 | 251 | This can be accomplished by specifying a `local.yml`, which will be added in and loaded with the existing yml configuration files automatically. For example: 252 | 253 | ``` file="local.yml" 254 | version: "2" 255 | services: 256 | 257 | # Add the adminer image at the latest tag on port 8080:8080 258 | adminer: 259 | image: adminer:latest 260 | restart: always 261 | ports: 262 | - 8080:8080 263 | depends_on: 264 | - "db" 265 | 266 | # Modify the webserver image to add another volume: 267 | webserver: 268 | volumes: 269 | - "/opt/data:/opt/data:cached" 270 | ``` 271 | 272 | ## Using XDebug for live debugging 273 | 274 | The XDebug PHP Extension is not included in this setup and there are reasons not to include it by default. 275 | 276 | However, if you want to work with XDebug, especially for live debugging, you can add XDebug to a running webserver container easily: 277 | 278 | ``` 279 | # Install XDebug extension with PECL 280 | moodle-docker-compose exec webserver pecl install xdebug 281 | 282 | # Set some wise setting for live debugging - change this as needed 283 | read -r -d '' conf <<'EOF' 284 | ; Settings for Xdebug Docker configuration 285 | xdebug.mode = debug 286 | xdebug.client_host = host.docker.internal 287 | ; Some IDEs (eg PHPSTORM, VSCODE) may require configuring an IDE key, uncomment if needed 288 | ; xdebug.idekey=MY_FAV_IDE_KEY 289 | EOF 290 | moodle-docker-compose exec webserver bash -c "echo '$conf' >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini" 291 | 292 | # Enable XDebug extension in Apache and restart the webserver container 293 | moodle-docker-compose exec webserver docker-php-ext-enable xdebug 294 | moodle-docker-compose restart webserver 295 | ``` 296 | 297 | While setting these XDebug settings depending on your local need, please take special care of the value of `xdebug.client_host` which is needed to connect from the container to the host. The given value `host.docker.internal` is a special DNS name for this purpose within Docker for Windows and Docker for Mac. If you are running on another Docker environment, you might want to try the value `localhost` instead or even set the hostname/IP of the host directly. Please turn off the firewall or open the port used in the `xdebug.client_port`. 298 | 299 | Open the port (9003 is the default one) by using the example command for Linux Ubuntu: 300 | ``` 301 | sudo ufw allow 9003 302 | ``` 303 | 304 | 305 | After these commands, XDebug ist enabled and ready to be used in the webserver container. 306 | If you want to disable and re-enable XDebug during the lifetime of the webserver container, you can achieve this with these additional commands: 307 | 308 | ``` 309 | # Disable XDebug extension in Apache and restart the webserver container 310 | moodle-docker-compose exec webserver sed -i 's/^zend_extension=/; zend_extension=/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 311 | moodle-docker-compose restart webserver 312 | 313 | # Enable XDebug extension in Apache and restart the webserver container 314 | moodle-docker-compose exec webserver sed -i 's/^; zend_extension=/zend_extension=/' /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini 315 | moodle-docker-compose restart webserver 316 | ``` 317 | 318 | ## Advanced usage 319 | 320 | As can be seen in [bin/moodle-docker-compose](https://github.com/moodlehq/moodle-docker/blob/main/bin/moodle-docker-compose), 321 | this repo is just a series of Docker Compose configurations and light wrapper which make use of companion docker images. Each part 322 | is designed to be reusable and you are encouraged to use the docker [compose] commands as needed. 323 | 324 | ## Quick start with Gitpod 325 | 326 | Gitpod is a free, cloud-based, development environment providing VS Code and a suitable development environment right in your browser. 327 | 328 | When launching a workspace in Gitpod, it will automatically: 329 | 330 | * Clone the Moodle repo into the `/moodle` folder. 331 | * Initialise the Moodle database. 332 | * Start the Moodle webserver. 333 | 334 |

335 | 336 | Open in Gitpod 337 | 338 |

339 | 340 | > **IMPORTANT**: Gitpod is an alternative to local development and completely optional. We recommend setting up a local development environment if you plan to contribute regularly. 341 | 342 | The Moodle Gitpod template supports the following environment variables: 343 | 344 | * `MOODLE_REPOSITORY`. The Moodle repository to be cloned. The value should be URL encoded. If left undefined, the default repository `https://github.com/moodle/moodle.git` is used. 345 | * `MOODLE_BRANCH`. The Moodle branch to be cloned. If left undefined, the default branch `main` is employed. 346 | * `DATAFILE`. When specified, this feature URL initializes the Moodle site with essential data. The value should be URL encoded. The content of this file adheres to the [Behat generators format](https://moodledev.io/general/development/tools/generator#create-a-testing-scenario-using-behat-generators) for creating testing scenarios. 347 | * `INSTALLADMINER`. Add this variable, set to any value, to install [adminer](https://www.adminer.org/). 348 | * `CLONEALL`. If not set, a shallow clone is created, truncating the history to reduce the clone size. Set to `1` for a full clone. 349 | 350 | For a practical demonstration, launch a Gitpod workspace with the 'main' branch patch for [MDL-79912](https://tracker.moodle.org/browse/MDL-79912). Simply open the following URL in your web browser (note that MOODLE_REPOSITORY should be URL encoded). The password for the **admin** user is **test**: 351 | 352 | ``` 353 | https://gitpod.io/#MOODLE_REPOSITORY=https%3A%2F%2Fgithub.com%2Fsarjona%2Fmoodle.git,MOODLE_BRANCH=MDL-79912-main/https://github.com/moodlehq/moodle-docker 354 | ``` 355 | 356 | To optimize your browsing experience, consider integrating the [Tampermonkey extension](https://www.tampermonkey.net/) into your preferred web browser for added benefits. Afterward, install the Gitpod script, which can be accessed via the following URL: [Gitpod script](https://gist.githubusercontent.com/sarjona/9fc728eb2d2b41a783ea03afd6a6161e/raw/gitpod.js). This script efficiently incorporates a button adjacent to each branch within the Moodle tracker, facilitating the effortless initiation of a Gitpod workspace tailored to the corresponding patch for the issue you're currently viewing. 357 | 358 | ## Companion docker images 359 | 360 | The following Moodle customised docker images are close companions of this project: 361 | 362 | * [moodle-php-apache](https://github.com/moodlehq/moodle-php-apache): Apache/PHP Environment preconfigured for all Moodle environments 363 | * [moodle-db-mssql](https://github.com/moodlehq/moodle-db-mssql): Microsoft SQL Server for Linux configured for Moodle 364 | * [moodle-db-oracle](https://github.com/moodlehq/moodle-db-oracle): Oracle XE configured for Moodle 365 | 366 | ## Contributions 367 | 368 | Are extremely welcome! 369 | -------------------------------------------------------------------------------- /assets/appbehattests/app.feature: -------------------------------------------------------------------------------- 1 | @javascript @app @moodledocker 2 | Feature: The app starts in behat 3 | In order to test that the app it working properly 4 | As moodle-docker 5 | I need a way to verify this 6 | 7 | Scenario: Start the app 8 | Given the following "users" exist: 9 | | username | firstname | lastname | email | 10 | | student1 | Student | 1 | student1@example.com | 11 | And the following "courses" exist: 12 | | fullname | shortname | category | 13 | | Course 1 | C1 | 0 | 14 | And the following "course enrolments" exist: 15 | | user | course | role | 16 | | student1 | C1 | student | 17 | And the following "activities" exist: 18 | | activity | course | idnumber | name | intro | 19 | | label | C1 | label1 | Label 1 | It worked great | 20 | When I entered the course "Course 1" as "student1" in the app 21 | Then I should find "It worked great" in the app 22 | -------------------------------------------------------------------------------- /assets/exttests/apache2.conf: -------------------------------------------------------------------------------- 1 | 2 | # The ServerName directive sets the request scheme, hostname and port that 3 | # the server uses to identify itself. This is used when creating 4 | # redirection URLs. In the context of virtual hosts, the ServerName 5 | # specifies what hostname must appear in the request's Host: header to 6 | # match this virtual host. For the default virtual host (this file) this 7 | # value is not decisive as it is used as a last resort host regardless. 8 | # However, you must set it for any further virtual host explicitly. 9 | #ServerName www.example.com 10 | 11 | ServerAdmin webmaster@localhost 12 | DocumentRoot /var/www/html 13 | 14 | # Available loglevels: trace8, ..., trace1, debug, info, notice, warn, 15 | # error, crit, alert, emerg. 16 | # It is also possible to configure the loglevel for particular 17 | # modules, e.g. 18 | #LogLevel info ssl:warn 19 | 20 | ErrorLog ${APACHE_LOG_DIR}/error.log 21 | CustomLog ${APACHE_LOG_DIR}/access.log combined 22 | 23 | # For most configuration files from conf-available/, which are 24 | # enabled or disabled at a global level, it is possible to 25 | # include a line for only one particular virtual host. For example the 26 | # following line enables the CGI configuration for this host only 27 | # after it has been globally disabled with "a2disconf". 28 | #Include conf-available/serve-cgi-bin.conf 29 | 30 | 31 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 32 | -------------------------------------------------------------------------------- /assets/exttests/apache2_ports.conf: -------------------------------------------------------------------------------- 1 | # If you just change the port or add more ports here, you will likely also 2 | # have to change the VirtualHost statement in 3 | # /etc/apache2/sites-enabled/000-default.conf 4 | 5 | Listen 9000 6 | 7 | 8 | Listen 9443 9 | 10 | 11 | 12 | Listen 9443 13 | 14 | 15 | # vim: syntax=apache ts=4 sw=4 sts=4 sr noet 16 | -------------------------------------------------------------------------------- /assets/web/apache2_faildumps.conf: -------------------------------------------------------------------------------- 1 | 2 | Options +Indexes 3 | 4 | 5 | 6 | FallbackResource disabled 7 | 8 | 9 | Alias /_/faildumps /var/www/behatfaildumps 10 | 11 | # Set the handler to use for files whose extension ends in `.php`. 12 | # This is a workaround for https://github.com/docker-library/php/issues/1576 13 | # The FallbackResource is a default Handler action which is only used if a Handler has not already been applied. 14 | # The docker/php image sets the handler unconditionally for any file whose name matches `.php`. 15 | # This configuration block unsets the default handler, and instead only applies it if the file exists. 16 | 17 | SetHandler none 18 | 19 | SetHandler application/x-httpd-php 20 | 21 | 22 | -------------------------------------------------------------------------------- /assets/web/apache2_mailpit.conf: -------------------------------------------------------------------------------- 1 | 2 | LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so 3 | 4 | 5 | 6 | LoadModule proxy_http_module /usr/lib/apache2/modules/mod_proxy_http.so 7 | 8 | 9 | 10 | LoadModule proxy_wstunnel_module /usr/lib/apache2/modules/mod_proxy_wstunnel.so 11 | 12 | 13 | Redirect "/_/mail" "/_/mail/" 14 | 15 | ProxyPass "/_/mail/api/events" "ws://mailpit:8025/_/mail/api/events" 16 | ProxyPassReverse "/_/mail/api/events" "ws://mailpit:8025/_/mail/api/events" 17 | 18 | ProxyPass "/_/mail/" "http://mailpit:8025/_/mail/" 19 | ProxyPassReverse "/_/mail/" "http://mailpit:8025/_/mail/" 20 | -------------------------------------------------------------------------------- /base.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | image: "moodlehq/moodle-php-apache:${MOODLE_DOCKER_PHP_VERSION}" 4 | depends_on: 5 | - db 6 | volumes: 7 | - "${MOODLE_DOCKER_WWWROOT}:/var/www/html" 8 | - "${ASSETDIR}/web/apache2_faildumps.conf:/etc/apache2/conf-enabled/moodle-faildump.conf" 9 | environment: 10 | MOODLE_DOCKER_RUNNING: 1 11 | MOODLE_DOCKER_DBNAME: moodle 12 | MOODLE_DOCKER_DBUSER: moodle 13 | MOODLE_DOCKER_DBPASS: "m@0dl3ing" 14 | MOODLE_DOCKER_BROWSER: firefox 15 | MOODLE_DOCKER_WEB_HOST: "${MOODLE_DOCKER_WEB_HOST}" 16 | MOODLE_DOCKER_TIMEOUT_FACTOR: "${MOODLE_DOCKER_TIMEOUT_FACTOR}" 17 | exttests: 18 | image: moodlehq/moodle-exttests 19 | volumes: 20 | - "${ASSETDIR}/exttests/apache2_ports.conf:/etc/apache2/ports.conf" 21 | - "${ASSETDIR}/exttests/apache2.conf:/etc/apache2/sites-enabled/000-default.conf" 22 | selenium: 23 | image: "selenium/standalone-firefox${MOODLE_DOCKER_SELENIUM_SUFFIX:-}:${MOODLE_DOCKER_BROWSER_TAG}" 24 | volumes: 25 | - "${MOODLE_DOCKER_WWWROOT}:/var/www/html:ro" 26 | -------------------------------------------------------------------------------- /bbb-mock.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_BBB_MOCK: "true" 5 | bbbmock: 6 | image: moodlehq/bigbluebutton_mock 7 | -------------------------------------------------------------------------------- /behat-faildump.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | volumes: 4 | - "${MOODLE_DOCKER_BEHAT_FAILDUMP}:/var/www/behatfaildumps" 5 | environment: 6 | MOODLE_DOCKER_BEHAT_FAILDUMP: "${MOODLE_DOCKER_BEHAT_FAILDUMP}" 7 | -------------------------------------------------------------------------------- /bin/moodle-docker-compose: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | # First find out if this was called from symlink, 5 | # then find the real path of parent directory. 6 | # This is needed because macOS does not have GNU realpath. 7 | thisfile=$( readlink "${BASH_SOURCE[0]}" ) || thisfile="${BASH_SOURCE[0]}" 8 | basedir="$( cd "$( dirname "$thisfile" )/../" && pwd -P )" 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 21 | 22 | export ASSETDIR="${basedir}/assets" 23 | 24 | # Test if we have docker compose v2, and keep quiet if we don't. 25 | ver=$(docker compose version > /dev/null 2>&1 && docker compose version --short) || true 26 | if [[ $ver =~ ^v?2 ]]; then 27 | dockercompose="docker compose" 28 | else 29 | echo 'Compose v2 is not available in Docker CLI, falling back to use docker-compose script' 30 | dockercompose="docker-compose" 31 | fi 32 | dockercompose="${dockercompose} -f ${basedir}/base.yml" 33 | dockercompose="${dockercompose} -f ${basedir}/service.mail.yml" 34 | 35 | # PHP Version. 36 | export MOODLE_DOCKER_PHP_VERSION=${MOODLE_DOCKER_PHP_VERSION:-8.2} 37 | 38 | # Database flavour. 39 | dockercompose="${dockercompose} -f ${basedir}/db.${MOODLE_DOCKER_DB}.yml" 40 | 41 | # Add support for version specific database settings. 42 | if [ ! -z "$MOODLE_DOCKER_DB_VERSION" ]; 43 | then 44 | filename="${basedir}/db.${MOODLE_DOCKER_DB}.${MOODLE_DOCKER_DB_VERSION}.yml" 45 | if [ -f $filename ]; then 46 | dockercompose="${dockercompose} -f ${filename}" 47 | fi 48 | fi 49 | 50 | # Support PHP version overrides for DB not available any more. 51 | 52 | # Expose DB port if requested. 53 | if [[ $MOODLE_DOCKER_DB_PORT == *":"* ]] || [[ $MOODLE_DOCKER_DB_PORT -gt 0 ]] 54 | then 55 | # If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 56 | if [[ ! $MOODLE_DOCKER_DB_PORT == *":"* ]] 57 | then 58 | export MOODLE_DOCKER_DB_PORT=127.0.0.1:$MOODLE_DOCKER_DB_PORT 59 | fi 60 | filename="${basedir}/db.${MOODLE_DOCKER_DB}.port.yml" 61 | if [ -f $filename ]; 62 | then 63 | dockercompose="${dockercompose} -f ${filename}" 64 | fi 65 | fi 66 | 67 | # Guess mobile app runtime 68 | if [ -z "$MOODLE_DOCKER_APP_RUNTIME" ]; 69 | then 70 | if [[ ! -z "$MOODLE_DOCKER_APP_PATH" ]]; 71 | then 72 | appversion="$(cat $MOODLE_DOCKER_APP_PATH/package.json | sed -n -E 's/\s*"version": "([0-9]+\.[0-9]+\.[0-9]+)(.*)?",/\1/p')" 73 | elif [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]]; 74 | then 75 | appversion=$MOODLE_DOCKER_APP_VERSION 76 | fi 77 | 78 | if [[ ! -z $appversion ]]; 79 | then 80 | if [[ ! -z "$(echo $appversion | sed -n -E 's/([0-9]+\.[0-9]+\.[0-9]+)/\1/p')" ]]; 81 | then 82 | appmajorversion="$(echo $appversion | sed -n -E 's/([0-9]+)\.[0-9]+\.[0-9]+/\1/p')" 83 | appminorversion="$(echo $appversion | sed -n -E 's/[0-9]+\.([0-9]+)\.[0-9]+/\1/p')" 84 | 85 | if (( $appmajorversion > 4 || $appminorversion > 3)); 86 | then 87 | export MOODLE_DOCKER_APP_RUNTIME="ionic7" 88 | else 89 | export MOODLE_DOCKER_APP_RUNTIME="ionic5" 90 | fi 91 | else 92 | export MOODLE_DOCKER_APP_RUNTIME="ionic7" 93 | fi 94 | fi 95 | fi 96 | 97 | # Guess mobile app node version (only for local app development) 98 | if [[ -z "$MOODLE_DOCKER_APP_NODE_VERSION" ]] && [[ ! -z "$MOODLE_DOCKER_APP_PATH" ]]; 99 | then 100 | appnodeversion="$(cat $MOODLE_DOCKER_APP_PATH/.nvmrc | sed -E "s/v(([0-9]+\.?)+)/\1/" || true)" 101 | 102 | export MOODLE_DOCKER_APP_NODE_VERSION="$appnodeversion" 103 | fi 104 | 105 | # Guess mobile app port (only when using Docker app images) 106 | if [[ -z "$MOODLE_DOCKER_APP_PORT" ]] && [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]]; 107 | then 108 | if [[ "$MOODLE_DOCKER_APP_RUNTIME" = "ionic5" ]]; 109 | then 110 | export MOODLE_DOCKER_APP_PORT="80" 111 | else 112 | export MOODLE_DOCKER_APP_PORT="443" 113 | fi 114 | fi 115 | 116 | # Guess mobile app protocol 117 | if [[ -z "$MOODLE_DOCKER_APP_PROTOCOL" ]]; 118 | then 119 | if [[ "$MOODLE_DOCKER_APP_RUNTIME" = "ionic5" ]]; 120 | then 121 | export MOODLE_DOCKER_APP_PROTOCOL="http" 122 | else 123 | export MOODLE_DOCKER_APP_PROTOCOL="https" 124 | fi 125 | fi 126 | 127 | # Selenium browser 128 | browserparts=(${MOODLE_DOCKER_BROWSER//:/ }) 129 | export MOODLE_DOCKER_BROWSER_NAME=${browserparts[0]} 130 | export MOODLE_DOCKER_BROWSER_TAG=${browserparts[1]} 131 | 132 | if [[ -z "$MOODLE_DOCKER_BROWSER_NAME" ]]; 133 | then 134 | MOODLE_DOCKER_BROWSER_NAME=firefox 135 | fi 136 | 137 | if [[ -z "$MOODLE_DOCKER_BROWSER_TAG" ]]; 138 | then 139 | MOODLE_DOCKER_BROWSER_TAG=4 140 | fi 141 | 142 | # Mobile app for development 143 | if [[ "$MOODLE_DOCKER_BROWSER_NAME" == "chrome" ]]; 144 | then 145 | if [[ ! -z "$MOODLE_DOCKER_APP_PATH" ]]; 146 | then 147 | dockercompose="${dockercompose} -f ${basedir}/moodle-app-dev.yml" 148 | elif [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]]; 149 | then 150 | # Mobile app using a docker image 151 | dockercompose="${dockercompose} -f ${basedir}/moodle-app.yml" 152 | fi 153 | fi 154 | 155 | if [[ "$MOODLE_DOCKER_BROWSER_NAME" != "firefox" ]]; 156 | then 157 | dockercompose="${dockercompose} -f ${basedir}/selenium.${MOODLE_DOCKER_BROWSER_NAME}.yml" 158 | fi 159 | 160 | # Selenium VNC port 161 | export MOODLE_DOCKER_SELENIUM_SUFFIX="" 162 | if [[ $MOODLE_DOCKER_SELENIUM_VNC_PORT == *":"* ]] || [[ $MOODLE_DOCKER_SELENIUM_VNC_PORT -gt 0 ]] 163 | then 164 | if [[ $(echo $MOODLE_DOCKER_BROWSER_TAG | sed 's/[^0-9].*//g') -lt 4 ]] 165 | then 166 | export MOODLE_DOCKER_SELENIUM_SUFFIX="-debug" 167 | fi 168 | 169 | # If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 170 | if [[ ! $MOODLE_DOCKER_SELENIUM_VNC_PORT == *":"* ]] 171 | then 172 | MOODLE_DOCKER_SELENIUM_VNC_PORT=127.0.0.1:$MOODLE_DOCKER_SELENIUM_VNC_PORT 173 | fi 174 | dockercompose="${dockercompose} -f ${basedir}/selenium.debug.yml" 175 | fi 176 | 177 | # External services 178 | if [[ ! -z "$MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES" ]]; 179 | then 180 | dockercompose="${dockercompose} -f ${basedir}/phpunit-external-services.yml" 181 | fi 182 | 183 | # BBB Mock 184 | if [[ ! -z "$MOODLE_DOCKER_BBB_MOCK" ]]; 185 | then 186 | dockercompose="${dockercompose} -f ${basedir}/bbb-mock.yml" 187 | fi 188 | 189 | # Matrix Mock 190 | if [[ ! -z "$MOODLE_DOCKER_MATRIX_MOCK" ]]; 191 | then 192 | dockercompose="${dockercompose} -f ${basedir}/matrix-mock.yml" 193 | fi 194 | 195 | # Machine Learning backend 196 | if [[ ! -z "$MOODLE_DOCKER_MLBACKEND" ]]; 197 | then 198 | dockercompose="${dockercompose} -f ${basedir}/mlbackend.yml" 199 | fi 200 | 201 | # Faildump directory 202 | if [[ ! -z "$MOODLE_DOCKER_BEHAT_FAILDUMP" ]]; 203 | then 204 | if [ ! -d "$MOODLE_DOCKER_BEHAT_FAILDUMP" ]; 205 | then 206 | echo 'Error: $MOODLE_DOCKER_BEHAT_FAILDUMP is not an existing directory' 207 | exit 1 208 | fi 209 | dockercompose="${dockercompose} -f ${basedir}/behat-faildump.yml" 210 | fi 211 | 212 | # Webserver host 213 | export MOODLE_DOCKER_WEB_HOST=${MOODLE_DOCKER_WEB_HOST:-localhost} 214 | 215 | # Webserver port 216 | export MOODLE_DOCKER_WEB_PORT=${MOODLE_DOCKER_WEB_PORT:-8000} 217 | if [[ $MOODLE_DOCKER_WEB_PORT == *":"* ]] || [[ $MOODLE_DOCKER_WEB_PORT -gt 0 ]] 218 | then 219 | # If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 220 | if [[ ! $MOODLE_DOCKER_WEB_PORT == *":"* ]] 221 | then 222 | MOODLE_DOCKER_WEB_PORT=127.0.0.1:$MOODLE_DOCKER_WEB_PORT 223 | fi 224 | dockercompose="${dockercompose} -f ${basedir}/webserver.port.yml" 225 | fi 226 | 227 | # Behat test timeout factor 228 | export MOODLE_DOCKER_TIMEOUT_FACTOR=${MOODLE_DOCKER_TIMEOUT_FACTOR:-1} 229 | 230 | # Mac OS Compatbility 231 | if [[ "$(uname)" == "Darwin" ]]; then 232 | # Support https://docs.docker.com/docker-for-mac/osxfs-caching/ 233 | dockercompose="${dockercompose} -f ${basedir}/volumes-cached.yml" 234 | fi 235 | 236 | # Apply local customisations if a local.yml is found. 237 | # Note: This must be the final modification before the docker-compose command is called. 238 | localfile="${basedir}/local.yml" 239 | if [ -f "${localfile}" ] 240 | then 241 | echo "Including local options from ${localfile}" 242 | dockercompose="${dockercompose} -f ${localfile}" 243 | fi 244 | 245 | $dockercompose "$@" 246 | -------------------------------------------------------------------------------- /bin/moodle-docker-compose.cmd: -------------------------------------------------------------------------------- 1 | @ECHO OFF 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 | ) 12 | 13 | PUSHD %cd% 14 | CD %~dp0.. 15 | SET BASEDIR=%cd% 16 | POPD 17 | SET ASSETDIR=%BASEDIR%\assets 18 | 19 | SET COMPOSE_CONVERT_WINDOWS_PATHS=true 20 | 21 | SET DOCKERCOMPOSE=docker-compose -f "%BASEDIR%\base.yml" 22 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\service.mail.yml" 23 | 24 | IF "%MOODLE_DOCKER_PHP_VERSION%"=="" ( 25 | SET MOODLE_DOCKER_PHP_VERSION=8.2 26 | ) 27 | 28 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\db.%MOODLE_DOCKER_DB%.yml" 29 | 30 | SET filenamedbversion=%BASEDIR%\db.%MOODLE_DOCKER_DB%.%MOODLE_DOCKER_DB_VERSION%.yml 31 | IF EXIST "%filenamedbversion%" ( 32 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filenamedbversion%" 33 | ) 34 | 35 | REM Support PHP version overrides for DB not available any more. 36 | 37 | IF "%MOODLE_DOCKER_DB_PORT%"=="" ( 38 | SET MOODLE_DOCKER_DB_PORT= 39 | ) ELSE ( 40 | SET "TRUE=" 41 | IF NOT "%MOODLE_DOCKER_DB_PORT%"=="%MOODLE_DOCKER_DB_PORT::=%" SET TRUE=1 42 | IF NOT "%MOODLE_DOCKER_DB_PORT%"=="0" SET TRUE=1 43 | IF DEFINED TRUE ( 44 | REM If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 45 | IF "%MOODLE_DOCKER_DB_PORT%"=="%MOODLE_DOCKER_DB_PORT::=%" ( 46 | SET MOODLE_DOCKER_DB_PORT=127.0.0.1:%MOODLE_DOCKER_DB_PORT% 47 | ) 48 | SET filedbport=%BASEDIR%\db.%MOODLE_DOCKER_DB%.port.yml 49 | IF EXIST "%filedbport%" ( 50 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%filedbport%" 51 | ) 52 | ) 53 | ) 54 | 55 | IF "%MOODLE_DOCKER_APP_RUNTIME%"=="" ( 56 | SET MOODLE_DOCKER_APP_RUNTIME=ionic7 57 | ) 58 | 59 | REM Guess mobile app node version (only for local app development) 60 | IF "%MOODLE_DOCKER_APP_NODE_VERSION%"=="" ( 61 | IF NOT "%MOODLE_DOCKER_APP_PATH%"=="" ( 62 | SET filenvmrc=%MOODLE_DOCKER_APP_PATH%\.nvmrc 63 | IF EXIST "%filenvmrc%" ( 64 | SET /p NODE_VERSION=< "%filenvmrc%" 65 | SET NODE_VERSION=%NODE_VERSION:v=% 66 | ECHO %NODE_VERSION% | FINDSTR /r "[0-9.]*" >nul 2>&1 67 | IF ERRORLEVEL 0 ( 68 | SET MOODLE_DOCKER_APP_NODE_VERSION=%NODE_VERSION% 69 | ) 70 | ) 71 | ) 72 | ) 73 | 74 | REM Guess mobile app port (only when using Docker app images) 75 | IF "%MOODLE_DOCKER_APP_PORT%"=="" ( 76 | IF NOT "%MOODLE_DOCKER_APP_VERSION%"=="" ( 77 | IF "%MOODLE_DOCKER_APP_RUNTIME%"=="ionic5" ( 78 | SET MOODLE_DOCKER_APP_PORT=80 79 | ) ELSE ( 80 | SET MOODLE_DOCKER_APP_PORT=443 81 | ) 82 | ) 83 | ) 84 | 85 | REM Guess mobile app protocol 86 | IF "%MOODLE_DOCKER_APP_PROTOCOL%"=="" ( 87 | if "%MOODLE_DOCKER_APP_RUNTIME%"=="ionic5" ( 88 | SET MOODLE_DOCKER_APP_PROTOCOL=http 89 | ) ELSE ( 90 | SET MOODLE_DOCKER_APP_PROTOCOL=https 91 | ) 92 | ) 93 | 94 | IF NOT "%MOODLE_DOCKER_BROWSER%"=="" ( 95 | REM Split MOODLE_DOCKER_BROWSER by : to get selenium tag if sepecified 96 | FOR /f "tokens=1,2 delims=:" %%i in ("%MOODLE_DOCKER_BROWSER%") do ( 97 | SET MOODLE_DOCKER_BROWSER_NAME=%%i 98 | SET MOODLE_DOCKER_BROWSER_TAG=%%j 99 | ) 100 | ) 101 | 102 | IF "%MOODLE_DOCKER_BROWSER_NAME%"=="" ( 103 | SET MOODLE_DOCKER_BROWSER_NAME=firefox 104 | ) 105 | 106 | IF "%MOODLE_DOCKER_BROWSER_TAG%"=="" ( 107 | SET MOODLE_DOCKER_BROWSER_TAG=4 108 | ) 109 | 110 | IF "%MOODLE_DOCKER_BROWSER_NAME%"=="chrome" ( 111 | IF NOT "%MOODLE_DOCKER_APP_PATH%"=="" ( 112 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app-dev.yml" 113 | ) ELSE IF NOT "%MOODLE_DOCKER_APP_VERSION%"=="" ( 114 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\moodle-app.yml" 115 | ) 116 | ) 117 | 118 | IF NOT "%MOODLE_DOCKER_BROWSER_NAME%"=="firefox" ( 119 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\selenium.%MOODLE_DOCKER_BROWSER_NAME%.yml" 120 | ) 121 | 122 | IF NOT "%MOODLE_DOCKER_PHPUNIT_EXTERNAL_SERVICES%"=="" ( 123 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\phpunit-external-services.yml" 124 | ) 125 | 126 | IF NOT "%MOODLE_DOCKER_BBB_MOCK%"=="" ( 127 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\bbb-mock.yml" 128 | ) 129 | 130 | IF NOT "%MOODLE_DOCKER_MATRIX_MOCK%"=="" ( 131 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\matrix-mock.yml" 132 | ) 133 | 134 | IF NOT "%MOODLE_DOCKER_MLBACKEND%"=="" ( 135 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\mlbackend.yml" 136 | ) 137 | 138 | IF NOT "%MOODLE_DOCKER_BEHAT_FAILDUMP%"=="" ( 139 | IF NOT EXIST "%MOODLE_DOCKER_BEHAT_FAILDUMP%" ( 140 | ECHO Error: MOODLE_DOCKER_BEHAT_FAILDUMP is not an existing directory 141 | EXIT /B 1 142 | ) 143 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\behat-faildump.yml" 144 | ) 145 | 146 | IF "%MOODLE_DOCKER_WEB_HOST%"=="" ( 147 | SET MOODLE_DOCKER_WEB_HOST=localhost 148 | ) 149 | 150 | IF "%MOODLE_DOCKER_WEB_PORT%"=="" ( 151 | SET MOODLE_DOCKER_WEB_PORT=8000 152 | ) 153 | 154 | SET "TRUE=" 155 | IF NOT "%MOODLE_DOCKER_WEB_PORT%"=="%MOODLE_DOCKER_WEB_PORT::=%" SET TRUE=1 156 | IF NOT "%MOODLE_DOCKER_WEB_PORT%"=="0" SET TRUE=1 157 | IF DEFINED TRUE ( 158 | REM If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 159 | IF "%MOODLE_DOCKER_WEB_PORT%"=="%MOODLE_DOCKER_WEB_PORT::=%" ( 160 | SET MOODLE_DOCKER_WEB_PORT=127.0.0.1:%MOODLE_DOCKER_WEB_PORT% 161 | ) 162 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\webserver.port.yml" 163 | ) 164 | 165 | IF "%MOODLE_DOCKER_SELENIUM_VNC_PORT%"=="" ( 166 | SET MOODLE_DOCKER_SELENIUM_SUFFIX= 167 | ) ELSE ( 168 | SET "TRUE=" 169 | IF NOT "%MOODLE_DOCKER_SELENIUM_VNC_PORT%"=="%MOODLE_DOCKER_SELENIUM_VNC_PORT::=%" SET TRUE=1 170 | IF NOT "%MOODLE_DOCKER_SELENIUM_VNC_PORT%"=="0" SET TRUE=1 171 | IF DEFINED TRUE ( 172 | IF "%MOODLE_DOCKER_BROWSER_TAG%"=="3" ( 173 | SET MOODLE_DOCKER_SELENIUM_SUFFIX=-debug 174 | ) 175 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%BASEDIR%\selenium.debug.yml" 176 | REM If no bind ip has been configured (bind_ip:port), default to 127.0.0.1 177 | IF "%MOODLE_DOCKER_SELENIUM_VNC_PORT%"=="%MOODLE_DOCKER_SELENIUM_VNC_PORT::=%" ( 178 | SET MOODLE_DOCKER_SELENIUM_VNC_PORT=127.0.0.1:%MOODLE_DOCKER_SELENIUM_VNC_PORT% 179 | ) 180 | ) 181 | ) 182 | 183 | IF "%MOODLE_DOCKER_TIMEOUT_FACTOR%"=="" ( 184 | SET MOODLE_DOCKER_TIMEOUT_FACTOR=1 185 | ) 186 | 187 | REM Apply local customisations if a local.yml is found. 188 | REM Note: This must be the final modification before the docker-compose command is called. 189 | SET LOCALFILE=%BASEDIR%\local.yml 190 | IF EXIST %LOCALFILE% ( 191 | ECHO Including local options from %localfile% 192 | SET DOCKERCOMPOSE=%DOCKERCOMPOSE% -f "%LOCALFILE%" 193 | ) 194 | 195 | %DOCKERCOMPOSE% %* 196 | -------------------------------------------------------------------------------- /bin/moodle-docker-wait-for-app: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | thisfile=$( readlink "${BASH_SOURCE[0]}" ) || thisfile="${BASH_SOURCE[0]}" 5 | basedir="$( cd "$( dirname "$thisfile" )/../" && pwd -P )" 6 | 7 | if [[ ! -z "$MOODLE_DOCKER_BROWSER" ]] && [[ "$MOODLE_DOCKER_BROWSER" == "chrome" ]] && ([[ ! -z "$MOODLE_DOCKER_APP_PATH" ]] || [[ ! -z "$MOODLE_DOCKER_APP_VERSION" ]]); 8 | then 9 | 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'; 10 | do 11 | echo 'Waiting for Moodle app to come up...' 12 | sleep 15 13 | done 14 | fi 15 | -------------------------------------------------------------------------------- /bin/moodle-docker-wait-for-db: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | thisfile=$( readlink "${BASH_SOURCE[0]}" ) || thisfile="${BASH_SOURCE[0]}" 5 | basedir="$( cd "$( dirname "$thisfile" )/../" && pwd -P )" 6 | 7 | if [ -z "$MOODLE_DOCKER_DB" ]; 8 | then 9 | echo 'Error: $MOODLE_DOCKER_DB is not set' 10 | exit 1 11 | fi 12 | 13 | if [ "$MOODLE_DOCKER_DB" = "mssql" ]; 14 | then 15 | $basedir/bin/moodle-docker-compose exec -T db /wait-for-mssql-to-come-up.sh 16 | elif [ "$MOODLE_DOCKER_DB" = "oracle" ]; 17 | then 18 | until $basedir/bin/moodle-docker-compose logs db | grep -q 'DATABASE IS READY TO USE!'; 19 | do 20 | echo 'Waiting for oracle to come up...' 21 | sleep 15 22 | done 23 | else 24 | sleep 10 25 | fi 26 | -------------------------------------------------------------------------------- /config.docker-template.php: -------------------------------------------------------------------------------- 1 | dbtype = getenv('MOODLE_DOCKER_DBTYPE'); 8 | $CFG->dblibrary = 'native'; 9 | $CFG->dbhost = 'db'; 10 | $CFG->dbname = getenv('MOODLE_DOCKER_DBNAME'); 11 | $CFG->dbuser = getenv('MOODLE_DOCKER_DBUSER'); 12 | $CFG->dbpass = getenv('MOODLE_DOCKER_DBPASS'); 13 | $CFG->prefix = 'm_'; 14 | $CFG->dboptions = ['dbcollation' => getenv('MOODLE_DOCKER_DBCOLLATION')]; 15 | 16 | if (getenv('MOODLE_DOCKER_DBTYPE') === 'sqlsrv') { 17 | $CFG->dboptions['extrainfo'] = [ 18 | // Disable Encryption for now on sqlsrv. 19 | // It is on by default from msodbcsql18. 20 | 'Encrypt' => false, 21 | ]; 22 | } 23 | 24 | if (empty($_SERVER['HTTP_HOST'])) { 25 | $_SERVER['HTTP_HOST'] = 'localhost'; 26 | } 27 | if (strpos($_SERVER['HTTP_HOST'], '.gitpod.io') !== false) { 28 | // Gitpod.io deployment. 29 | $CFG->wwwroot = 'https://' . $_SERVER['HTTP_HOST']; 30 | $CFG->sslproxy = true; 31 | // To avoid registration form. 32 | $CFG->site_is_public = false; 33 | } else { 34 | // Docker deployment. 35 | $host = 'localhost'; 36 | if (!empty(getenv('MOODLE_DOCKER_WEB_HOST'))) { 37 | $host = getenv('MOODLE_DOCKER_WEB_HOST'); 38 | } 39 | $CFG->wwwroot = "http://{$host}"; 40 | $port = getenv('MOODLE_DOCKER_WEB_PORT'); 41 | if (!empty($port)) { 42 | // Extract port in case the format is bind_ip:port. 43 | $parts = explode(':', $port); 44 | $port = end($parts); 45 | if ((string)(int)$port === (string)$port) { // Only if it's int value. 46 | $CFG->wwwroot .= ":{$port}"; 47 | } 48 | } 49 | } 50 | 51 | $CFG->dataroot = '/var/www/moodledata'; 52 | $CFG->admin = 'admin'; 53 | $CFG->directorypermissions = 0777; 54 | $CFG->smtphosts = 'mailpit:1025'; 55 | $CFG->noreplyaddress = 'noreply@example.com'; 56 | 57 | // Debug options - possible to be controlled by flag in future.. 58 | $CFG->debug = (E_ALL); // DEBUG_DEVELOPER 59 | $CFG->debugdisplay = 1; 60 | $CFG->debugstringids = 1; // Add strings=1 to url to get string ids. 61 | $CFG->perfdebug = 15; 62 | $CFG->debugpageinfo = 1; 63 | $CFG->allowthemechangeonurl = 1; 64 | $CFG->passwordpolicy = 0; 65 | $CFG->cronclionly = 0; 66 | $CFG->pathtophp = '/usr/local/bin/php'; 67 | 68 | $CFG->phpunit_dataroot = '/var/www/phpunitdata'; 69 | $CFG->phpunit_prefix = 't_'; 70 | define('TEST_EXTERNAL_FILES_HTTP_URL', 'http://exttests:9000'); 71 | define('TEST_EXTERNAL_FILES_HTTPS_URL', 'http://exttests:9000'); 72 | 73 | $CFG->behat_wwwroot = 'http://webserver'; 74 | $CFG->behat_dataroot = '/var/www/behatdata'; 75 | $CFG->behat_prefix = 'b_'; 76 | $CFG->behat_profiles = array( 77 | 'default' => array( 78 | 'browser' => getenv('MOODLE_DOCKER_BROWSER'), 79 | 'wd_host' => 'http://selenium:4444/wd/hub', 80 | ), 81 | ); 82 | $CFG->behat_faildump_path = '/var/www/behatfaildumps'; 83 | $CFG->behat_increasetimeout = getenv('MOODLE_DOCKER_TIMEOUT_FACTOR'); 84 | 85 | define('PHPUNIT_LONGTEST', true); 86 | 87 | if (getenv('MOODLE_DOCKER_APP')) { 88 | $appport = getenv('MOODLE_DOCKER_APP_PORT') ?: 8100; 89 | $protocol = getenv('MOODLE_DOCKER_APP_PROTOCOL') ?: 'https'; 90 | 91 | $CFG->behat_ionic_wwwroot = "$protocol://moodleapp:$appport"; 92 | $CFG->behat_profiles['default']['capabilities'] = [ 93 | 'extra_capabilities' => [ 94 | 'chromeOptions' => ['args' => ['--ignore-certificate-errors', '--allow-running-insecure-content']], 95 | ], 96 | ]; 97 | } 98 | 99 | if (getenv('MOODLE_DOCKER_PHPUNIT_EXTRAS')) { 100 | define('TEST_SEARCH_SOLR_HOSTNAME', 'solr'); 101 | define('TEST_SEARCH_SOLR_INDEXNAME', 'test'); 102 | define('TEST_SEARCH_SOLR_PORT', 8983); 103 | 104 | define('TEST_SESSION_REDIS_HOST', 'redis'); 105 | define('TEST_CACHESTORE_REDIS_TESTSERVERS', 'redis'); 106 | 107 | define('TEST_CACHESTORE_MONGODB_TESTSERVER', 'mongodb://mongo:27017'); 108 | 109 | define('TEST_CACHESTORE_MEMCACHED_TESTSERVERS', "memcached0:11211\nmemcached1:11211"); 110 | define('TEST_CACHESTORE_MEMCACHE_TESTSERVERS', "memcached0:11211\nmemcached1:11211"); 111 | 112 | define('TEST_LDAPLIB_HOST_URL', 'ldap://ldap'); 113 | define('TEST_LDAPLIB_BIND_DN', 'cn=admin,dc=openstack,dc=org'); 114 | define('TEST_LDAPLIB_BIND_PW', 'password'); 115 | define('TEST_LDAPLIB_DOMAIN', 'ou=Users,dc=openstack,dc=org'); 116 | 117 | define('TEST_AUTH_LDAP_HOST_URL', 'ldap://ldap'); 118 | define('TEST_AUTH_LDAP_BIND_DN', 'cn=admin,dc=openstack,dc=org'); 119 | define('TEST_AUTH_LDAP_BIND_PW', 'password'); 120 | define('TEST_AUTH_LDAP_DOMAIN', 'ou=Users,dc=openstack,dc=org'); 121 | 122 | define('TEST_ENROL_LDAP_HOST_URL', 'ldap://ldap'); 123 | define('TEST_ENROL_LDAP_BIND_DN', 'cn=admin,dc=openstack,dc=org'); 124 | define('TEST_ENROL_LDAP_BIND_PW', 'password'); 125 | define('TEST_ENROL_LDAP_DOMAIN', 'ou=Users,dc=openstack,dc=org'); 126 | } 127 | 128 | if (property_exists($CFG, 'behat_wwwroot')) { 129 | $mockhash = sha1($CFG->behat_wwwroot); 130 | } else { 131 | $mockhash = sha1($CFG->wwwroot); 132 | } 133 | 134 | if (getenv('MOODLE_DOCKER_BBB_MOCK')) { 135 | define('TEST_MOD_BIGBLUEBUTTONBN_MOCK_SERVER', "http://bbbmock/{$mockhash}"); 136 | } 137 | 138 | if (getenv('MOODLE_DOCKER_MATRIX_MOCK')) { 139 | define('TEST_COMMUNICATION_MATRIX_MOCK_SERVER', "http://matrixmock/{$mockhash}"); 140 | } 141 | 142 | if (getenv('MOODLE_DOCKER_MLBACKEND')) { 143 | define('TEST_MLBACKEND_PYTHON_HOST', 'mlbackendpython'); 144 | define('TEST_MLBACKEND_PYTHON_PORT', 5000); 145 | define('TEST_MLBACKEND_PYTHON_USERNAME', 'default'); 146 | define('TEST_MLBACKEND_PYTHON_PASSWORD', 'sshhhh'); 147 | } 148 | 149 | require_once(__DIR__ . '/lib/setup.php'); 150 | -------------------------------------------------------------------------------- /db.mariadb.port.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | ports: 4 | - "${MOODLE_DOCKER_DB_PORT}:3306/tcp" 5 | -------------------------------------------------------------------------------- /db.mariadb.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_DBTYPE: mariadb 5 | MOODLE_DOCKER_DBCOLLATION: utf8mb4_bin 6 | db: 7 | image: mariadb:${MOODLE_DOCKER_DB_VERSION:-10.11} 8 | command: > 9 | --character-set-server=utf8mb4 10 | --collation-server=utf8mb4_bin 11 | --innodb_file_per_table=On 12 | --wait-timeout=28800 13 | --skip-log-bin 14 | environment: 15 | MYSQL_ROOT_PASSWORD: "m@0dl3ing" 16 | MYSQL_USER: moodle 17 | MYSQL_PASSWORD: "m@0dl3ing" 18 | MYSQL_DATABASE: moodle 19 | -------------------------------------------------------------------------------- /db.mssql.port.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | ports: 4 | - "${MOODLE_DOCKER_DB_PORT}:1433/tcp" 5 | -------------------------------------------------------------------------------- /db.mssql.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_DBTYPE: sqlsrv 5 | MOODLE_DOCKER_DBUSER: sa 6 | db: 7 | image: moodlehq/moodle-db-mssql:${MOODLE_DOCKER_DB_VERSION:-latest} 8 | environment: 9 | ACCEPT_EULA: "y" 10 | SA_PASSWORD: "m@0dl3ing" 11 | -------------------------------------------------------------------------------- /db.mysql.5.6.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | image: mysql:${MOODLE_DOCKER_DB_VERSION:-5.6} 4 | command: > 5 | --character-set-server=utf8mb4 6 | --collation-server=utf8mb4_bin 7 | --innodb_file_format=barracuda 8 | --innodb_file_per_table=On 9 | --innodb_large_prefix=On 10 | -------------------------------------------------------------------------------- /db.mysql.5.7.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | image: mysql:${MOODLE_DOCKER_DB_VERSION:-5.7} 4 | command: > 5 | --character-set-server=utf8mb4 6 | --collation-server=utf8mb4_bin 7 | --innodb_file_format=barracuda 8 | --innodb_file_per_table=On 9 | --innodb_large_prefix=On 10 | -------------------------------------------------------------------------------- /db.mysql.port.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | ports: 4 | - "${MOODLE_DOCKER_DB_PORT}:3306/tcp" 5 | -------------------------------------------------------------------------------- /db.mysql.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_DBTYPE: mysqli 5 | MOODLE_DOCKER_DBCOLLATION: utf8mb4_bin 6 | db: 7 | image: mysql:${MOODLE_DOCKER_DB_VERSION:-8.4} 8 | command: > 9 | --character-set-server=utf8mb4 10 | --collation-server=utf8mb4_bin 11 | --skip-log-bin 12 | environment: 13 | MYSQL_ROOT_PASSWORD: "m@0dl3ing" 14 | MYSQL_USER: moodle 15 | MYSQL_PASSWORD: "m@0dl3ing" 16 | MYSQL_DATABASE: moodle 17 | -------------------------------------------------------------------------------- /db.oracle.port.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | ports: 4 | - "${MOODLE_DOCKER_DB_PORT}:1521/tcp" 5 | -------------------------------------------------------------------------------- /db.oracle.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_DBTYPE: oci 5 | MOODLE_DOCKER_DBNAME: XE 6 | db: 7 | image: moodlehq/moodle-db-oracle-r2:${MOODLE_DOCKER_DB_VERSION:-21} 8 | -------------------------------------------------------------------------------- /db.pgsql.port.yml: -------------------------------------------------------------------------------- 1 | services: 2 | db: 3 | ports: 4 | - "${MOODLE_DOCKER_DB_PORT}:5432/tcp" 5 | -------------------------------------------------------------------------------- /db.pgsql.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_DBTYPE: pgsql 5 | db: 6 | image: postgres:${MOODLE_DOCKER_DB_VERSION:-14} 7 | environment: 8 | POSTGRES_USER: moodle 9 | POSTGRES_PASSWORD: "m@0dl3ing" 10 | POSTGRES_DB: moodle 11 | -------------------------------------------------------------------------------- /matrix-mock.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_MATRIX_MOCK: "true" 5 | matrixmock: 6 | image: moodlehq/matrixsynapse_mock 7 | -------------------------------------------------------------------------------- /mlbackend.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_MLBACKEND: "true" 5 | mlbackendpython: 6 | image: moodlehq/moodle-mlbackend-python:3.0.5-python3.7.5 7 | -------------------------------------------------------------------------------- /moodle-app-dev.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_APP: "true" 5 | MOODLE_DOCKER_APP_PROTOCOL: ${MOODLE_DOCKER_APP_PROTOCOL} 6 | moodleapp: 7 | image: node:${MOODLE_DOCKER_APP_NODE_VERSION} 8 | working_dir: /app 9 | command: [ "bash", "-c", "git config --global --add safe.directory /app && npm start -- --host 0.0.0.0"] 10 | volumes: 11 | - "${MOODLE_DOCKER_APP_PATH}:/app" 12 | expose: 13 | - 8100 14 | - 35729 15 | - 53703 16 | ports: 17 | - "8100:8100" 18 | - "35729:35729" 19 | - "53703:53703" 20 | -------------------------------------------------------------------------------- /moodle-app.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_APP: "true" 5 | MOODLE_DOCKER_APP_PORT: ${MOODLE_DOCKER_APP_PORT} 6 | MOODLE_DOCKER_APP_PROTOCOL: ${MOODLE_DOCKER_APP_PROTOCOL} 7 | moodleapp: 8 | image: "moodlehq/moodleapp:${MOODLE_DOCKER_APP_VERSION}" 9 | ports: 10 | - "8100:$MOODLE_DOCKER_APP_PORT" 11 | -------------------------------------------------------------------------------- /phpunit-external-services.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_PHPUNIT_EXTRAS: "true" 5 | memcached0: 6 | image: memcached:1.4 7 | memcached1: 8 | image: memcached:1.4 9 | mongo: 10 | image: mongo:4.0 11 | redis: 12 | image: redis:5 13 | solr: 14 | image: solr:6.5 15 | entrypoint: 16 | - docker-entrypoint.sh 17 | - solr-precreate 18 | - test 19 | ldap: 20 | image: larrycai/openldap 21 | -------------------------------------------------------------------------------- /selenium.chrome.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | environment: 4 | MOODLE_DOCKER_BROWSER: chrome 5 | selenium: 6 | image: "selenium/standalone-chrome${MOODLE_DOCKER_SELENIUM_SUFFIX:-}:${MOODLE_DOCKER_BROWSER_TAG}" 7 | volumes: 8 | - /dev/shm:/dev/shm 9 | -------------------------------------------------------------------------------- /selenium.debug.yml: -------------------------------------------------------------------------------- 1 | services: 2 | selenium: 3 | ports: 4 | - "${MOODLE_DOCKER_SELENIUM_VNC_PORT}:5900" 5 | environment: 6 | # Workaround for https://github.com/SeleniumHQ/docker-selenium/issues/227 7 | "no_proxy": localhost 8 | -------------------------------------------------------------------------------- /service.mail.yml: -------------------------------------------------------------------------------- 1 | services: 2 | webserver: 3 | volumes: 4 | - "${ASSETDIR}/web/apache2_mailpit.conf:/etc/apache2/conf-enabled/apache2_mailpit.conf" 5 | depends_on: 6 | - mailpit 7 | mailpit: 8 | image: axllent/mailpit:v1.10 9 | environment: 10 | MP_WEBROOT: /_/mail/ 11 | -------------------------------------------------------------------------------- /tests/app-setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 4 | initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/init.php" 5 | 6 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 7 | export MOODLE_DOCKER_BROWSER=chrome 8 | export MOODLE_DOCKER_DB=pgsql 9 | 10 | if [ "$SUITE" = "app-development" ]; 11 | then 12 | export MOODLE_DOCKER_APP_PATH="${basedir}/app" 13 | 14 | git clone --branch "$MOODLE_DOCKER_APP_VERSION" --depth 1 https://github.com/moodlehq/moodleapp $basedir/app 15 | git clone --branch "$MOODLE_DOCKER_APP_VERSION" --depth 1 https://github.com/moodlehq/moodle-local_moodleappbehat $basedir/moodle/local/moodleappbehat 16 | 17 | if [[ ! -f $basedir/app/.npmrc || -z "$(cat $basedir/app/.npmrc | grep unsafe-perm)" ]]; 18 | then 19 | echo -e "\nunsafe-perm=true" >> $basedir/app/.npmrc 20 | fi 21 | 22 | nodeversion="$(cat $MOODLE_DOCKER_APP_PATH/.nvmrc | grep -oP '(\d+\.?)+' || true)" 23 | 24 | docker run --volume $basedir/app:/app --workdir /app node:$nodeversion bash -c "npm ci" 25 | elif [ "$SUITE" = "app" ]; 26 | then 27 | branch=`echo $MOODLE_DOCKER_APP_VERSION | grep -P -o "next|latest|\d\.\d\.\d"` 28 | 29 | if [ "$branch" = "next" ]; 30 | then 31 | branch="main" 32 | elif [ "$branch" != "latest" ]; 33 | then 34 | branch="v$branch" 35 | fi 36 | 37 | git clone --branch "$branch" --depth 1 https://github.com/moodlehq/moodle-local_moodleappbehat $basedir/moodle/local/moodleappbehat 38 | else 39 | echo "Error, unknown suite '$SUITE'" 40 | exit 1 41 | fi 42 | 43 | cp $basedir/assets/appbehattests/app.feature $basedir/moodle/local/moodleappbehat/tests/behat/app.feature 44 | 45 | echo "Pulling docker images" 46 | $basedir/bin/moodle-docker-compose pull 47 | echo "Starting up container" 48 | $basedir/bin/moodle-docker-compose up -d 49 | echo "Waiting for DB to come up" 50 | $basedir/bin/moodle-docker-wait-for-db 51 | echo "Waiting for Moodle app to come up" 52 | $basedir/bin/moodle-docker-wait-for-app 53 | echo "Running: $initcmd" 54 | $basedir/$initcmd 55 | -------------------------------------------------------------------------------- /tests/app-teardown.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 4 | 5 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 6 | export MOODLE_DOCKER_BROWSER="chrome" 7 | export MOODLE_DOCKER_DB=pgsql 8 | 9 | if [ "$SUITE" = "app-development" ]; 10 | then 11 | export MOODLE_DOCKER_APP_PATH="${basedir}/app" 12 | elif [ "$SUITE" != "app" ]; 13 | then 14 | echo "Error, unknown suite '$SUITE'" 15 | exit 1 16 | fi 17 | 18 | echo "Stopping down container" 19 | $basedir/bin/moodle-docker-compose down 20 | -------------------------------------------------------------------------------- /tests/app-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 5 | 6 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 7 | export MOODLE_DOCKER_BROWSER=chrome 8 | export MOODLE_DOCKER_DB=pgsql 9 | 10 | if [ "$SUITE" = "app" ] || [ "$SUITE" = "app-development" ]; 11 | then 12 | testcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/run.php --tags=@app&&@moodledocker" 13 | else 14 | echo "Error, unknown suite '$SUITE'" 15 | exit 1 16 | fi 17 | 18 | echo "Running: $testcmd" 19 | $basedir/$testcmd 20 | -------------------------------------------------------------------------------- /tests/behat-setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 4 | 5 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 6 | 7 | if [ "$SUITE" = "behat" ]; 8 | then 9 | initcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/init.php" 10 | else 11 | echo "Error, unknown suite '$SUITE'" 12 | exit 1 13 | fi 14 | 15 | echo "Pulling docker images" 16 | $basedir/bin/moodle-docker-compose pull 17 | echo "Starting up container" 18 | $basedir/bin/moodle-docker-compose up -d 19 | echo "Waiting for DB to come up" 20 | $basedir/bin/moodle-docker-wait-for-db 21 | echo "Running: $initcmd" 22 | $basedir/$initcmd 23 | -------------------------------------------------------------------------------- /tests/behat-teardown.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 4 | 5 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 6 | 7 | if [ "$SUITE" = "behat" ]; 8 | then 9 | echo 10 | else 11 | echo "Error, unknown suite '$SUITE'" 12 | exit 1 13 | fi 14 | 15 | echo "Stopping down container" 16 | $basedir/bin/moodle-docker-compose down 17 | -------------------------------------------------------------------------------- /tests/behat-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 5 | 6 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 7 | 8 | if [ "$SUITE" = "behat" ]; 9 | then 10 | testcmd="bin/moodle-docker-compose exec -T webserver php admin/tool/behat/cli/run.php --tags=@auth_manual" 11 | else 12 | echo "Error, unknown suite '$SUITE'" 13 | exit 1 14 | fi 15 | 16 | echo "Running: $testcmd" 17 | $basedir/$testcmd 18 | -------------------------------------------------------------------------------- /tests/integration-setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 5 | 6 | export MOODLE_DOCKER_DB=pgsql 7 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 8 | 9 | echo "Pulling docker images" 10 | $basedir/bin/moodle-docker-compose pull 11 | echo "Starting up container" 12 | $basedir/bin/moodle-docker-compose up -d 13 | echo "Waiting for DB to come up" 14 | $basedir/bin/moodle-docker-wait-for-db 15 | -------------------------------------------------------------------------------- /tests/integration-teardown.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 5 | 6 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 7 | export MOODLE_DOCKER_DB=pgsql 8 | 9 | echo "Stopping down container" 10 | $basedir/bin/moodle-docker-compose down 11 | -------------------------------------------------------------------------------- /tests/integration-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | basedir="$( cd "$( dirname "${BASH_SOURCE[0]}" )/../" && pwd )" 5 | 6 | export MOODLE_DOCKER_WWWROOT="${basedir}/moodle" 7 | export MOODLE_DOCKER_DB=pgsql 8 | 9 | echo "Checking that PHP CLI is available" 10 | 11 | out=$("${basedir}/bin/moodle-docker-compose" exec -T webserver php -r 'echo "Up!";') 12 | if [[ ! "$out" =~ 'Up!' ]]; then 13 | echo "Error: PHP CLI isn't available" 14 | exit 1 15 | fi 16 | 17 | echo "Checking that the web server is up" 18 | 19 | if ! curl -s -f 'http://localhost:8000' > /dev/null; then 20 | echo "Error: Webserver not available in port 8000" 21 | exit 1 22 | fi 23 | 24 | echo "Checking that the Moodle site is ready to install" 25 | 26 | out=$(curl -s -L 'http://localhost:8000') 27 | if ! grep -qz 'Installation | Moodle ' <<< "$out"; then 28 | echo "Error: Moodle site not ready to install" 29 | exit 1 30 | fi 31 | 32 | echo "Checking that mailpit is up" 33 | 34 | if ! curl -s -f -L 'http://localhost:8000/_/mail' > /dev/null; then 35 | echo "Error: Mailpit not available @ http://localhost:8000/_/mail" 36 | exit 1 37 | fi 38 | 39 | echo "Checking that mailpit is using existing JS and CSS files" 40 | 41 | out=$(curl -s -L 'http://localhost:8000/_/mail') 42 | js=$(grep -oP '(?<=