Skip to content

Commit 918615b

Browse files
committed
First version with Moodle 3.2 and 3.3 dockenized
1 parent d492781 commit 918615b

File tree

9 files changed

+1284
-0
lines changed

9 files changed

+1284
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
moodle/**
2+
moodle_*/**

Dockerfile

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Dockerfile for Moodle instance with Postgres.
2+
# The source it's not included in the docker; it's mounted from a host's folder
3+
# Forked from Lorenzo Nicora <[email protected]>'s docker version. https://github.com/nicusX/dockerised-moodledev
4+
FROM ubuntu:16.04
5+
MAINTAINER Sara Arjona Tellez <[email protected]>
6+
7+
VOLUME ["/var/moodledata", "/var/www/html"]
8+
EXPOSE 80 443
9+
10+
# Let the container know that there is no tty
11+
ENV DEBIAN_FRONTEND noninteractive
12+
13+
# This should be overridden on running moodle container
14+
ENV MOODLE_URL http://127.0.0.1
15+
16+
ADD ./foreground_apache2.sh /etc/apache2/foreground.sh
17+
18+
RUN apt-get update && \
19+
apt-get -y install mysql-client pwgen python-setuptools curl git unzip apache2 php \
20+
php-gd libapache2-mod-php postfix wget supervisor php-pgsql curl libcurl3 \
21+
libcurl3-dev php-curl php-xmlrpc php-intl php-mysql git-core php-xml php-mbstring php-zip php-soap cron && \
22+
chown -R www-data:www-data /var/www/html && \
23+
chmod +x /etc/apache2/foreground.sh
24+
25+
26+
# Enable SSL, moodle requires it
27+
RUN a2enmod ssl && a2ensite default-ssl # if using proxy, don't need actually secure connection
28+
29+
# Cleanup, this is ran to reduce the resulting size of the image.
30+
RUN apt-get clean autoclean && apt-get autoremove -y
31+
32+
CMD ["/etc/apache2/foreground.sh"]

LICENSE

Lines changed: 340 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,62 @@
11
# docker-moodle-postgres
2+
3+
24
A Dockerfile that installs and runs Moodle from external source with Postgres Database.
5+
6+
The PHP code of Moodle is mounted from the host's subdirectory `./moodle`.
7+
8+
All the scripts must be run from the directory containing `Dockerfile` and `docker-compose.yml`.
9+
10+
11+
## Setup
12+
13+
Requires Docker to be installed and, optionally, Docker-compose as well.
14+
15+
Create a subdirectory named `moodle`, containing the moodle installation to be used. It's possible to clone from git:
16+
17+
```
18+
git clone -b MOODLE_33_STABLE git://git.moodle.org/moodle.git
19+
```
20+
21+
22+
## Installation
23+
24+
```
25+
git clone https://github.com/sarjona/docker-moodle-postgres
26+
cd docker-moodle-postgres
27+
./build-image.sh
28+
```
29+
30+
## Usage
31+
32+
When running locally or for a test deployment, use of localhost is acceptable.
33+
To spawn a new instance of Moodle it's necessary to create a folder with the Moodle source and create both container needed:
34+
35+
```
36+
./start-containers.sh
37+
```
38+
39+
The start-containers.sh script:
40+
- If it's first time, it will create both docker containers needed (PHP server and DB).
41+
- If the containers are created, it will start them.
42+
43+
In both cases, at the end of the execution are showed the instructions to access them. By default:
44+
45+
```
46+
To connect to PostgreSQL: host:port=127.0.0.1:32769, dbuser=moodle, dbpwd=secret
47+
To access Moodle: http://127.0.0.1:8000
48+
To enter shell in moodle container shell: docker exec -it moodle_core-php bash
49+
Admin account: admin/Abcd1234$
50+
```
51+
52+
53+
## Caveats
54+
The following aren't handled, considered, or need work:
55+
* moodle cronjob (should be called from cron container)
56+
* log handling (stdout?)
57+
* email (does it even send?)
58+
59+
60+
## Credits
61+
62+
This has been adapted from [Lorenzo Nicora](https://github.com/nicusX/dockerised-moodledev) and [Jonathan Hardison](https://github.com/jmhardison/docker-moodle) Dockerfiles.

build-image.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
# Build moodle image
3+
4+
docker build -t moodle-postgres .

docker-compose.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
moodle:
2+
image: moodle-postgres
3+
build: .
4+
container_name: moodle-postgres
5+
ports:
6+
- "8000:80"
7+
links:
8+
- postgres-moodle-db:db
9+
volumes:
10+
- ./moodle:/var/www/html
11+
environment:
12+
- MOODLE_URL=http://120.0.0.1:8000
13+
14+
moodledb:
15+
image: postgres
16+
container_name: postgres-moodle-db
17+
ports:
18+
- "32768:5432"
19+
environment:
20+
- POSTGRES_USER=moodle
21+
- POSTGRES_PASSWORD=secret

foreground_apache2.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
# This file is used by moodle container to start apache
3+
4+
echo "placeholder" > /var/moodledata/placeholder
5+
chown -R www-data:www-data /var/moodledata
6+
chmod 777 /var/moodledata
7+
8+
read pid cmd state ppid pgrp session tty_nr tpgid rest < /proc/self/stat
9+
trap "kill -TERM -$pgrp; exit" EXIT TERM KILL SIGKILL SIGTERM SIGQUIT
10+
11+
source /etc/apache2/envvars
12+
tail -F /var/log/apache2/* &
13+
exec apache2 -D FOREGROUND

0 commit comments

Comments
 (0)