A recipe/boilerplate in order to get the images from community's moodle repo up and running.
Run the following commands:
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
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