FROM moodlehq/moodle-php-apache:8.3-bullseye # Install git to clone Moodle RUN apt-get update && apt-get install -y git # Clone Moodle # Using MOODLE_501_STABLE as it's the latest stable branch found in research RUN rm -rf /var/www/html/* && \ git clone -b MOODLE_501_STABLE git://git.moodle.org/moodle.git /var/www/html # Configure Apache DocumentRoot for Moodle 5.1+ ENV APACHE_DOCUMENT_ROOT=/var/www/html/public RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf # Fix git detected dubious ownership RUN git config --global --add safe.directory /var/www/html # Set permissions RUN chown -R www-data:www-data /var/www/html # Copy config.php COPY config.php /var/www/html/config.php # Create dataroot RUN mkdir -p /var/www/moodledata && \ chown -R www-data:www-data /var/www/moodledata && \ chmod 777 /var/www/moodledata