This is no longer mentained you can make your own deployments using the images from https://github.com/ellakcy/docker-moodle In order to make your own look at docker-compose documentation https://docs.docker.com/compose/
A recipe/boilerplate in order to get the images from community's moodle repo up and running.
Run the following commands:
cp .env.dist .env
git clone [email protected]:ellakcy/moodle-compose.git
ln -s ^correct_moodle_compose.yml^ docker-compose.yml
On the last command above replace the ^correct_moodle_compose.yml^
with one of the following table:
Database | apache | alpine fpm | lts |
---|---|---|---|
Mysql | docker-compose_mysql_apache.yml |
docker-compose_postgresql_alpine_fpm.yml |
no |
mariadb | docker-compose_maria_apache.yml |
docker-compose_maria_alpine_fpm.yml |
no |
postgresql | docker-compose_postgresql_apache.yml |
docker-compose_postgresql_alpine_fpm.yml |
no |
Then edit the .env
file accorditly, you will need to put some values in it please rest easy in in there are instructions in it regarding the values to fill. This can be done via a text editor:
nano .env
Or
vi .env
After that you can start the moodle via:
docker-compose up -d
And you stop with:
docker-compose stop
Look for username and password in the database:
For postgresql:
docker-compose exec moodle_db pg_dump -U ^MOODLE_DB_USER^ ^MOODLE_DB_NAME^ > db_dump.sql
For mariadb/mysql:
docker-compose exec moodle_db mysqldump -umoodle -punsafepasswd --databases moodle > db_dump.sql
In folder data/moodle
are located ann the moodle data and code.
In folder data/moodle/www
the moodle code is located whilst at the parent data/moodle
the rest of the data (images, cache etc etc) is located. In later versions we wont use a bind mount for the moodle's data. Check the volumes
section in order to understand whether we use bind mount or normal volume.
You may copy the ./data/moodle
to the folder of your destination. Keep in mind though because theese folder under linux environment will have either root
or www-data
user and group. So during restore you may want to set these permissions, use ls -l
in order to keep track of them.
Just run the following command:
docker-compose stop && docker-compose rm && docker-compose pull && docker-compose up -d
With that we stopped removed the old images we fetched the new ones and we rerun the new containers.
Most of the times the moodle may need to run behind an http reverse proxy. In this case set the value for the url that the end user will type in his/her browser. Otherwise set the value http://0.0.0.0:8082
You should edit the following files:
./conf/nginx.conf
(In case of fpm)docker-compose.yml
(As seen above we symlinked it into the appropriate file).env
In order to change the application's url (if the url something like http://0.0.0.0:^some_port^).
Please keep in mind that the nginx
container must listen to the very same port that is mapped into. In any other case it may cause redirect loop.
The recomended way to use it is using ssl and set the following:
server {
listen 80;
# Put the site's url
server_name ^site_url^;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
ssl_certificate ^path to certificate^;
ssl_certificate_key ^path to certificate key^;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5;
server_name ellak.org;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_cache_bypass $http_upgrade;
# In case or running another port please replace the value bellow.
proxy_pass http://0.0.0.0:8082;
}
}
Please replace the values that are between ^
with apropriate ones. For ssl certificate we recomend the letencrpypt's certbot. Also the reverse proxy should NEVER forward the Host
http header. For more info you can consult the nginx configuration delivered by us.
You can easily migrate from fpm ones into apache ones, but theese concers should be followed:
- The database layer should be the same eg. if you select
mysql
variant stick to that. - Remove the
docker-compse.yml
and link with the aqpache variant. - The opposite shoulde be plausible as well.
Is reccomended to link the appropriate yml file and replace the image
at moodle
section with your own. For example let suppose we a foo/moodle
image based on ellakcy/moodle:mysql_maria_apache
then we will run the following commands:
ln -s docker-compose_mysql_apache.yml docker-compose.yml
Then we will edit the docker-compose.yml
:
nano docker-compose.yml
And we will put the following content:
version: '2'
services:
moodle_db:
image: mysql
volumes:
- './data/db:/var/lib/mysql'
environment:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
MYSQL_ONETIME_PASSWORD: "yes"
MYSQL_DATABASE: $MOODLE_DB_NAME
MYSQL_USER: $MOODLE_DB_USER
MYSQL_PASSWORD: $MOODLE_DB_PASSWORD
moodle:
image: foo/moodle
volumes:
- './data/moodle:/var/moodledata'
ports:
- '8082:80'
links:
- moodle_db
environment:
MOODLE_URL: $MOODLE_URL
MOODLE_ADMIN: $MOODLE_ADMIN
MOODLE_ADMIN_PASSWORD: $MOODLE_ADMIN_PASSWORD
MOODLE_ADMIN_EMAIL: $MOODLE_ADMIN_EMAIL
MOODLE_DB_TYPE: "mariadb"
MOODLE_DB_HOST: "moodle_db"
MOODLE_DB_USER: $MOODLE_DB_USER
MOODLE_DB_PASSWORD: $MOODLE_DB_PASSWORD
MOODLE_DB_NAME: $MOODLE_DB_NAME
MOODLE_REVERSE_LB: $MOODLE_REVERSE_LB
MOODLE_SSL: $MOODLE_SSL
MOODLE_EMAIL_TYPE_QMAIL: $MOODLE_EMAIL_TYPE_QMAIL
MOODLE_EMAIL_HOST: $MOODLE_EMAIL_HOST