Skip to content

Commit 602c8e6

Browse files
committed
feat: implement build-time patching system and fix libdir bug
- Adds a generic RUN step to apply all .patch files in the patches/ directory - Includes 001--fix-moodle-5.1.3-libdir-initialization--20260307.patch - Adds 'less' utility to base system packages for easier debugging
1 parent 940ccd3 commit 602c8e6

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

Dockerfile

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ARG PHP_VERSION=8.4
22
ARG MOODLE_VERSION=5.1.3
33
ARG MOODLE_MAJOR_VERSION=501
4+
ARG ADDITIONAL_APT_PACKAGES=""
5+
ARG ADDITIONAL_PHP_EXTENSIONS=""
46

57
FROM php:${PHP_VERSION}-fpm
68

@@ -19,6 +21,9 @@ RUN apt-get update && apt-get install -y \
1921
libz-dev \
2022
curl \
2123
gettext-base \
24+
patch \
25+
less \
26+
${ADDITIONAL_APT_PACKAGES} \
2227
&& rm -rf /var/lib/apt/lists/*
2328

2429
# Install PHP extensions using mlocati/php-extension-installer
@@ -36,7 +41,8 @@ RUN install-php-extensions \
3641
calendar \
3742
sockets \
3843
sodium \
39-
redis
44+
redis \
45+
${ADDITIONAL_PHP_EXTENSIONS}
4046

4147
# Increase max_input_vars
4248
RUN echo "max_input_vars = 5000" >> /usr/local/etc/php/conf.d/docker-php-moodle.ini
@@ -57,12 +63,19 @@ RUN mkdir -p /var/www/moodledata \
5763

5864
WORKDIR /var/www/html
5965

60-
# Copy entrypoint, step scripts, helper scripts and templates to /opt/moodle
61-
# to prevent them from being shadowed by /var/www/html volume mounts
66+
# Copy entrypoint, step scripts, helper scripts, templates and patches to /opt/moodle
6267
COPY docker-entrypoint.sh /usr/local/bin/
6368
COPY scripts/ /opt/moodle/scripts/
6469
COPY entrypoint.d/ /docker-entrypoint.d/
6570
COPY templates/ /opt/moodle/templates/
71+
COPY patches/ /opt/moodle/patches/
72+
73+
# Apply patches
74+
RUN for p in /opt/moodle/patches/*.patch; do \
75+
[ -e "$p" ] || continue; \
76+
echo "Applying patch $p"; \
77+
patch -p0 < "$p"; \
78+
done
6679

6780
RUN chmod +x /usr/local/bin/docker-entrypoint.sh \
6881
&& chmod +x /docker-entrypoint.d/*.sh \
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--- lib/setup.php
2+
+++ lib/setup.php
3+
@@ -24,5 +24,5 @@
4+
*/
5+
6+
if (property_exists($CFG, 'dirroot') && !str_ends_with($CFG->dirroot, '/public')) {
7+
- $CFG->libdir = $CFG->libdir . '/lib';
8+
+ $CFG->libdir = $CFG->dirroot . '/lib';
9+
}

0 commit comments

Comments
 (0)