System Architecture
ipMoodle is built on a multi-container Docker architecture that separates concerns across four specialized services, orchestrated through Docker Compose. This design provides isolation, scalability, and maintainability for your Moodle deployment.Database Layer
PostgreSQL 16 Alpine for data persistence
Application Layer
PHP 8.2-FPM processing Moodle logic
Web Layer
Nginx reverse proxy and static file serving
Automation Layer
Dedicated cron container for scheduled tasks
Component Relationships
The architecture follows a layered approach with clear separation of responsibilities:Service Dependencies
The containers start in a specific order to ensure dependencies are available:- db - Database starts first (no dependencies)
- app - Application waits for database (
depends_on: db) - cron - Cron service waits for application (
depends_on: app) - web - Web server waits for application (
depends_on: app)
All services communicate through the
moodle-net bridge network, which provides service discovery and network isolation.Data Flow
User Request Flow
- User sends HTTP request to port 80
- Nginx receives request and routes based on file type:
- Static files served directly from
/var/www/html - PHP files forwarded to
app:9000via FastCGI
- Static files served directly from
- PHP-FPM processes request using Moodle code
- Application queries PostgreSQL database at
db:5432 - Response travels back through the chain to user
Cron Task Flow
- Cron container executes Moodle’s
admin/cli/cron.phpevery minute - Script performs maintenance tasks (notifications, cleanup, etc.)
- Tasks interact with database and filesystem
- Results logged to prevent accumulation
The cron container shares the same volumes as the app container, ensuring consistent access to Moodle code and data files.
Storage Architecture
Volume Mounts
ipMoodle uses three persistent volumes for data storage:Moodle Code
./html → /var/www/htmlApplication code and pluginsUser Data
./moodledata → /var/www/moodledataUploads, cache, sessionsDatabase
./db_data → /var/lib/postgresql/dataPostgreSQL data filesShared Filesystem
Theapp and cron containers share the same volume mounts with read-write access, while web mounts html as read-only for security:
Network Topology
All containers connect to a single user-defined bridge network (moodle-net) with the following benefits:
- Service Discovery: Containers can reference each other by service name (e.g.,
db,app) - Isolation: Traffic is isolated from other Docker networks
- DNS Resolution: Automatic DNS resolution for container names
- Security: No external port exposure except web server port 80
Only the
web service exposes a port to the host (80:80). All other services are accessible only within the Docker network.Build vs. Image Strategy
ipMoodle uses a mixed approach:- Custom Built Images:
appandcronuse the same Dockerfile for PHP 8.2-FPM with Moodle extensions - Official Images:
db(postgres:16-alpine) andweb(nginx:alpine) use official images
Configuration Management
Environment variables are injected at runtime through the.env file:
Database Configuration
Database Configuration
Application Configuration
Application Configuration
Next Steps
Service Details
Detailed breakdown of each service
Networking
Deep dive into network configuration