Skip to content

Commit

Permalink
PM-45594 allow running arbitrary Moodle versions in docker setup
Browse files Browse the repository at this point in the history
This now allows running main as well as stable branches.

But it's not quite finished yet: Mounting the plugin folder is still missing.
  • Loading branch information
mk-kialo committed Oct 7, 2024
1 parent 89ed9ed commit cb53ea9
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 12 deletions.
34 changes: 22 additions & 12 deletions development/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,34 +1,44 @@
# https://hub.docker.com/r/bitnami/moodle
version: '2'
name: moodle-dev
services:
mariadb:
image: docker.io/bitnami/mariadb:10.6
image: docker.io/bitnami/mariadb:10.7
ports:
- '8833:3306'
- '8443:443'
environment:
# ALLOW_EMPTY_PASSWORD is recommended only for development.
- ALLOW_EMPTY_PASSWORD=yes
- MARIADB_USER=bn_moodle
- MARIADB_DATABASE=bitnami_moodle
- MARIADB_USER=moodle
- MARIADB_DATABASE=moodle
- MARIADB_CHARACTER_SET=utf8mb4
- MARIADB_COLLATE=utf8mb4_unicode_ci
# liveness probe
healthcheck:
test: ["CMD", "mysqladmin", "status", "-uroot"]
interval: 2s
timeout: 1s
retries: 10
moodle:
image: docker.io/bitnami/moodle:4.4
build:
dockerfile: Dockerfile
context: moodleimage
args:
# main (latest), MOODLE_405_STABLE etc, see https://github.com/moodle/moodle/branches
MOODLE_BRANCH: ${MOODLE_BRANCH:-main}
# 7.4, 8.0, 8.1, 8.3 etc., see https://moodledev.io/general/development/policies/php
PHP_VERSION: ${PHP_VERSION:-8.1}
ports:
- '8080:8080'
- '8080:80'
environment:
- MOODLE_DATABASE_HOST=mariadb
- MOODLE_DATABASE_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- ALLOW_EMPTY_PASSWORD=yes
- MOODLE_PASSWORD=kialo1234
# you can override the following by creating a .env file in the same directory as this file
- TARGET_KIALO_URL=${TARGET_KIALO_URL:-http://localhost:5000}
- MOODLE_HOST=${MOODLE_HOST:-localhost:8080}
volumes:
- './moodle:/bitnami/moodle'
- MOODLE_HOST=http://${MOODLE_HOST:-localhost:8080}
# volumes:
# - './moodle:/var/www/html'
depends_on:
- mariadb
moodleapp:
Expand Down
18 changes: 18 additions & 0 deletions development/moodleimage/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# See https://moodledev.io/general/development/policies/php for the list of available PHP versions.
# Different versions of Moodle require different versions of PHP.
ARG PHP_VERSION="8.1"

FROM moodlehq/moodle-php-apache:${PHP_VERSION}

# See https://moodledev.io/general/releases for the list of available versions.
# See https://github.com/moodle/moodle/branches for the available branches.
# Branch names follow the pattern MOODLE_XYZ_STABLE, e.g. MOODLE_404_STABLE for Moodle 4.4.
# main is the default and most up-to-date branch, it includes upcoming versions before they are stable.
ARG MOODLE_BRANCH="main"
ENV MOODLE_BRANCH=${MOODLE_BRANCH}

RUN git clone git://git.moodle.org/moodle.git /var/www/html --depth=1 --branch ${MOODLE_BRANCH}

COPY entrypoint.sh /usr/local/bin/entrypoint.sh
ENTRYPOINT ["entrypoint.sh"]
CMD ["apache2-foreground"]
9 changes: 9 additions & 0 deletions development/moodleimage/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# see https://docs.moodle.org/404/en/Installing_Moodle#Command_line_installer
chown -R www-data /var/www/html

# TODO: Make moodle default user "user" and not "admin"
su - www-data -s /bin/bash -c "php /var/www/html/admin/cli/install.php --non-interactive --agree-license --allow-unstable --wwwroot=$MOODLE_HOST --dataroot=/var/www/moodledata --dbtype=mariadb --dbhost=$MOODLE_DATABASE_HOST --dbname=moodle --dbuser=moodle --dbport=$MOODLE_DATABASE_PORT_NUMBER --fullname=Moodle --shortname=moodle --adminuser=user --adminpass=$MOODLE_PASSWORD [email protected] [email protected]"

exec /usr/local/bin/moodle-docker-php-entrypoint "$@"

0 comments on commit cb53ea9

Please sign in to comment.