Overview
The ipMoodle Dockerfile is built onphp:8.2-fpm-alpine and includes essential PHP extensions for Moodle. You can extend this base image to add custom PHP extensions required for specific Moodle plugins or integrations.
Understanding the Extension Installation Pattern
The Dockerfile (source/Dockerfile:1-39) follows a three-step pattern for installing PHP extensions:Currently Installed Extensions
The base ipMoodle image includes these extensions:- intl - Internationalization support
- soap - SOAP protocol support
- zip - ZIP archive handling
- pgsql - PostgreSQL database driver
- pdo_pgsql - PDO driver for PostgreSQL
- exif - Image metadata reading
- opcache - PHP opcode caching
- bcmath - Arbitrary precision mathematics
- sockets - Socket communication
- mbstring - Multibyte string handling
- sodium - Modern cryptography
- gd - Image processing (with FreeType and JPEG support)
Adding a Simple PHP Extension
For extensions that don’t require external dependencies:Edit the Dockerfile
Open
source/Dockerfile and locate the extension installation block (line 26-27):The
-j$(nproc) flag enables parallel compilation using all available CPU cores, speeding up the build process.Adding Extensions with Dependencies
Extensions requiring system libraries need a two-step process:Example: Adding LDAP Extension
Adding Extensions Requiring Configuration
Some extensions need configuration before installation, similar to GD (line 22-23):Example: Adding IMAP Extension
Installing PECL Extensions
For extensions not bundled with PHP, use PECL:Example: Adding Redis Extension
Complete Redis example
Complete Redis example
Verifying Installed Extensions
After rebuilding, verify your extensions are loaded:Configuring Extension Settings
Add extension-specific settings to the PHP configuration (line 30-36):Common Moodle Extensions
Depending on your Moodle plugins, you may need:| Extension | Use Case | Dependencies |
|---|---|---|
ldap | LDAP authentication | openldap-dev |
imap | Email integration | imap-dev openssl-dev krb5-dev |
redis | Session/cache storage | PECL extension |
imagick | Advanced image processing | imagemagick-dev |
xsl | XML transformations | libxslt-dev |
curl | HTTP requests | Usually included |
ftp | FTP repository support | None |
Troubleshooting
Extension fails to compile
Check system dependencies
Check system dependencies
Ensure all required
-dev packages are installed in the Alpine dependency block. Search for the extension name + “alpine linux” to find required packages.Build cache issues
Build cache issues
Always use
--no-cache when testing new extensions:Extension not loading
Extension not loading
Check the PHP error log:
Extension loads but Moodle doesn’t recognize it
-
Verify the extension is enabled:
-
Restart the PHP-FPM service:
- Clear Moodle caches from Site administration > Development > Purge all caches
Some Moodle plugins check for specific PHP extensions during installation. Always verify extension requirements before installing plugins.