https://github.com/erseco/alpine-moodle
Moodle docker image based on Alpine Linux
https://github.com/erseco/alpine-moodle
alpine docker hacktoberfest hacktoberfest2023 lightweight lms moodle nginx php8
Last synced: 28 days ago
JSON representation
Moodle docker image based on Alpine Linux
- Host: GitHub
- URL: https://github.com/erseco/alpine-moodle
- Owner: erseco
- License: mit
- Created: 2020-04-29T17:02:22.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-16T01:39:00.000Z (about 2 months ago)
- Last Synced: 2025-03-31T11:04:01.601Z (about 1 month ago)
- Topics: alpine, docker, hacktoberfest, hacktoberfest2023, lightweight, lms, moodle, nginx, php8
- Language: Shell
- Homepage: https://hub.docker.com/r/erseco/alpine-moodle
- Size: 148 KB
- Stars: 47
- Watchers: 6
- Forks: 35
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Moodle on Alpine Linux
[](https://hub.docker.com/r/erseco/alpine-moodle/)




Moodle setup for Docker, build on [Alpine Linux](http://www.alpinelinux.org/).
The image is only +/- 70MB large.Repository: https://github.com/erseco/alpine-moodle
* Built on the lightweight image https://github.com/erseco/alpine-php-webserver
* Very small Docker image size (+/-70MB)
* Uses PHP 8.4 for better performance, lower cpu usage & memory footprint
* Support for HA installations: php-redis, php-ldap (also with self-signed certs)
* Multi-arch support: 386, amd64, arm/v6, arm/v7, arm64, ppc64le, s390x
* Optimized for 100 concurrent users
* Optimized to only use resources when there's traffic (by using PHP-FPM's ondemand PM)
* Use of runit instead of supervisord to reduce memory footprint
* Configured cron to run as non-privileged user https://github.com/gliderlabs/docker-alpine/issues/381#issuecomment-621946699
* docker-compose sample with PostgreSQL and Redis
* Configuration via ENV variables
* Easily upgradable to new moodle versions
* The servers Nginx, PHP-FPM run under a non-privileged user (nobody) to make it more secure
* The logs of all the services are redirected to the output of the Docker container (visible with `docker logs -f `)
* Follows the KISS principle (Keep It Simple, Stupid) to make it easy to understand and adjust the image to your needs## Usage
Start the Docker containers:
docker-compose up
Login on the system using the provided credentials (ENV vars)
## Running Commands as Root
In certain situations, you might need to run commands as `root` within your Moodle container, for example, to install additional packages. You can do this using the `docker-compose exec` command with the `--user root` option. Here's how:
```bash
docker-compose exec --user root moodle sh
```## Configuration
Define the ENV variables in docker-compose.yml file| Variable Name | Default | Description |
|-----------------------------|----------------------|------------------------------------------------------------------------------------------------|
| LANG | en_US.UTF-8 | |
| LANGUAGE | en_US:en | |
| SITE_URL | http://localhost | Sets the public site url |
| REVERSEPROXY | false | Enable when setting up advanced reverse proxy |
| SSLPROXY | false | Disable SSL proxy to avoid site loop. Ej. Cloudfare |
| REDIS_HOST | | Set the host of the redis instance. Ej. redis |
| DB_TYPE | pgsql | mysqli - pgsql - mariadb |
| DB_HOST | postgres | DB_HOST Ej. db container name |
| DB_PORT | 5432 | Postgres=5432 - MySQL=3306 |
| DB_NAME | moodle | |
| DB_USER | moodle | |
| DB_FETCHBUFFERSIZE | | Set to 0 if using PostgresSQL poolers like PgBouncer in 'transaction' mode |
| DB_DBHANDLEOPTIONS | false | Set to true if using PostgresSQL poolers like PgBouncer which does not support sending options |
| DB_HOST_REPLICA | | Database hostname of the read-only replica database |
| DB_PORT_REPLICA | | Database port of replica, left it empty to be same as DB_PORT |
| DB_USER_REPLICA | | Database login username of replica, left it empty to be same as DB_USER |
| DB_PASS_REPLICA | | Database login password of replica, left it empty to be same as DB_PASS |
| DB_PREFIX | mdl_ | Database prefix. WARNING: don't use numeric values or moodle won't start |
| MY_CERTIFICATES | none | Trusted LDAP certificate or chain getting through base64 encode |
| MOODLE_EMAIL | [email protected] | |
| MOODLE_LANGUAGE | en | |
| MOODLE_SITENAME | New-Site | |
| MOODLE_USERNAME | moodleuser | |
| MOODLE_PASSWORD | PLEASE_CHANGEME | |
| SMTP_HOST | smtp.gmail.com | |
| SMTP_PORT | 587 | |
| SMTP_USER | [email protected] | |
| SMTP_PASSWORD | your_password | |
| SMTP_PROTOCOL | tls | |
| MOODLE_MAIL_NOREPLY_ADDRESS | noreply@localhost | |
| MOODLE_MAIL_PREFIX | [moodle] | |
| AUTO_UPDATE_MOODLE | true | Set to false to disable performing update of Moodle (e.g. plugins) at docker start |
| DEBUG | false | |
| client_max_body_size | 50M | |
| post_max_size | 50M | |
| upload_max_filesize | 50M | |
| max_input_vars | 5000 | |
| PRE_CONFIGURE_COMMANDS | | Commands to run before starting the configuration |
| POST_CONFIGURE_COMMANDS | | Commands to run after finished the configuration |## Pre and Post Configuration Commands
You can define commands to be executed before and after the configuration of Moodle using the `PRE_CONFIGURE_COMMANDS` and `POST_CONFIGURE_COMMANDS` environment variables. These can be useful for tasks such as installing additional packages or running scripts.
Example `docker-compose.yml` configuration:
```yaml
services:
moodle:
image: erseco/alpine-moodle
environment:
SITE_URL: "http://localhost"
DB_TYPE: "pgsql"
DB_HOST: "postgres"
DB_PORT: 5432
DB_NAME: "moodle"
DB_USER: "moodle"
MOODLE_USERNAME: "admin"
MOODLE_PASSWORD: "admin"
PRE_CONFIGURE_COMMANDS: "echo 'Running pre-configure commands'"
POST_CONFIGURE_COMMANDS: "echo 'Running post-configure commands'"
```## Specifying a Moodle Version
By default, this image uses the latest version of Moodle from the main branch. If you need to use a specific Moodle version, you can specify it using the `MOODLE_VERSION` build argument.
To use a specific version, edit your docker-compose.yml file and uncomment the build section for the moodle service:
```yaml
moodle:
# image: erseco/alpine-moodle
build:
context: .
args:
MOODLE_VERSION: v4.5.3 # Replace with your desired version
```
You can find the list of available version tags at: https://github.com/moodle/moodle/tags