Skip to content

Feature/ubuntu 20.04 #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.sh
102 changes: 51 additions & 51 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
FROM ubuntu:14.04
MAINTAINER Yannick Warnier <[email protected]>
FROM ubuntu:20.04
LABEL author="Yannick Warnier <[email protected]>"
LABEL contributor="Diego Bendlin <[email protected]>"

ARG MYSQL_ROOT_PASSWORD
ARG FQDN
ARG TZ
ARG APACHE_LOG_DIR
# Environment section
ENV FQDN ${FQDN}
ENV TZ ${TZ}
ENV APACHE_LOG_DIR ${APACHE_LOG_DIR}

# Configure Timezone
RUN ln -snf /usr/share/zoneinfo/${TZ} /etc/localtime && echo ${TZ} > /etc/timezone

# Keep upstart from complaining
RUN dpkg-divert --local --rename --add /sbin/initctl
RUN ln -sf /bin/true /sbin/initctl

# Update Ubuntu and install basic PHP stuff
RUN apt-get -y update && apt-get install -y \
curl \
git \
libapache2-mod-php5 \
php5-cli \
php5-curl \
php5-gd \
php5-intl \
php5-mysql \
wget

RUN apt-get install -y openssh-server
RUN mkdir -p /var/run/sshd

# Get Chamilo
RUN mkdir -p /var/www/chamilo
ADD https://github.com/chamilo/chamilo-lms/archive/v1.10.0-alpha.tar.gz /var/www/chamilo/chamilo.tar.gz
WORKDIR /var/www/chamilo
RUN tar zxf chamilo.tar.gz;rm chamilo.tar.gz;mv chamilo* www
WORKDIR www
RUN chown -R www-data:www-data \
app \
main/default_course_document/images \
main/lang \
vendor \
web

# Get Composer (putting the download in /root is discutible)
WORKDIR /root
RUN curl -sS https://getcomposer.org/installer | php
RUN chmod +x composer.phar
RUN mv composer.phar /usr/local/bin/composer

# Get Chash
RUN git clone https://github.com/chamilo/chash.git chash
WORKDIR chash
RUN composer update --no-dev
RUN php -d phar.readonly=0 createPhar.php
RUN chmod +x chash.phar && mv chash.phar /usr/local/bin/chash
# Update Ubuntu and install all required packages
RUN apt-get -y update && apt-get install -y apt-utils
RUN apt-get install -y apache2 mysql-client php \
libapache2-mod-php php-mysqlnd php-mysql \
php-xml php-json php-iconv php-gd php-intl php-mbstring \
php-ctype php-ldap php-curl php-xsl php-zip php-fpm \
git composer curl nano unzip debconf-utils gettext-base iputils-ping net-tools

# Configure MySQL
RUN echo "mysql-server mysql-server/root_password password ${MYSQL_ROOT_PASSWORD}" | debconf-set-selections
RUN echo "mysql-server mysql-server/root_password_again password ${MYSQL_ROOT_PASSWORD}" | debconf-set-selections

# Add datetime setting to php.ini
RUN echo "date.timezone = ${TZ}" >> /etc/php/7.4/apache2/php.ini
RUN echo "date.timezone = ${TZ}" >> /etc/php/7.4/cli/php.ini

# Get Chamilo from Github
WORKDIR /var/www
RUN git clone --depth=1 -b feature/improvedLdapIntegration https://github.com/dbendlin/chamilo-lms.git

# Go to Chamilo folder and update composer resources
WORKDIR /var/www/chamilo-lms
# Change permissions
RUN mkdir -p vendor && mkdir -p web
RUN chown -R www-data:www-data app main/default_course_document/images main/lang vendor web
RUN chmod 0775 -R app main/default_course_document/images main/lang web && chmod 0555 -R vendor
RUN composer update -n

# Configure and start Apache
ADD chamilo.conf /etc/apache2/sites-available/chamilo.conf
RUN a2ensite chamilo
RUN echo "ServerName ${FQDN}" >> /etc/apache2/apache2.conf
RUN echo "127.0.0.1 ${FQDN}" >> /etc/hosts
## Enable Rewrite module
RUN a2enmod rewrite
RUN /etc/init.d/apache2 restart
RUN echo "127.0.0.1 docker.chamilo.net" >> /etc/hosts
#RUN a2enmod rewrite headers expires ssl

# Go to Chamilo folder and install
# Soon... (this involves having a SQL server in a linked container)
## Enable Chamilo Site
ADD chamilo.conf /etc/apache2/sites-available/chamilo.conf
RUN a2ensite chamilo

WORKDIR /var/www/chamilo/www
EXPOSE 22 80
CMD ["/bin/bash"]
EXPOSE 80/tcp
ENTRYPOINT [ "/usr/sbin/apache2ctl", "-D", "FOREGROUND" ]
136 changes: 112 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,80 +1,168 @@
# docker-chamilo

Official Docker image for Chamilo LMS

This image is not ready yet. Please come back soon or watch the project for updates.

## Build docker image

This process will download chamilo-lms and other components from github and build an image on your cocker host machine.

Some values can be passed as --build-arg and later as environment variables.

```bash
docker build -t chamilo/docker-chamilo:1.11.12 \
--build-arg MYSQL_ROOT_PASSWORD="pass" \
--build-arg FQDN="chamilo.example.net" \
--build-arg TZ="Europe/Brussels" \
--build-arg APACHE_LOG_DIR="/var/log/apache2" \
.
```

## Launching

This image is currently based on Chamilo LMS 1.10 and requires a separate database container to run.
We suggest using the "mariadb" container, like so:

```
docker run --name mariadb -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_USER=chamilo -e MYSQL_PASSWORD=chamilo -e MYSQL_DATABASE=chamilo -d mariadb
```bash
docker run -d \
--name chamilo-db \
--hostname chamilo-db \
--domainname example.net \
-e MYSQL_ROOT_PASSWORD=pass \
-e MYSQL_USER=chamilo \
-e MYSQL_PASSWORD=chamilo \
-e MYSQL_DATABASE=chamilo \
mariadb
```

This will get you back on the command line of the Docker host. You can see the container running with ```docker ps```.
This will get you back on the command line of the Docker host. You can see the container running with:

```bash
docker ps
```

Then start the chamilo/docker-chamilo container:

```
docker run --link=mariadb:db --name chamilo -p 8080:80 -it chamilo/docker-chamilo
```bash
docker run -d \
--name chamilo \
--hostname chamilo \
--domainname example.net \
--link=chamilo-db \
-p 80 \
chamilo/docker-chamilo:1.11.12
```

At this point, the docker-chamilo image doesn't provide an installed version of Chamilo LMS, but this should be ready soon.

The configuration files assume the host will be "docker.chamilo.net", so you will have to define it in your host's /etc/hosts file, depending on the IP of the container.
The configuration files assume the host will be "chamilo.example.net", so you will have to define it in your host's /etc/hosts file, depending on the IP of the container.

```
72.17.0.10 docker.chamilo.net
```bash
72.17.0.10 chamilo.example.net
```

Now start your browser and load http://docker.chamilo.net.
Now start your browser and load <http://chamilo.example.net>

## Using with a load-balancer

If you want to use a more complex system with load balancing, you might want to try out the following suite of commands:

```bash
docker run -d \
--name=varwww \
ywarnier/varw
```
docker run --name varwww -d ywarnier/varw
```

This will provide a shared /var/www2 partition
This will provide a shared /var/www2 partition.

To avoid conflicts with the containers created above we will start a new database container

```bash
docker run -d \
--name=chamilo-db_lb \
--hostname=chamilo-db_lb \
--domainname=example.net \
-e MYSQL_ROOT_PASSWORD=pass \
-e MYSQL_USER=chamilo \
-e MYSQL_PASSWORD=chamilo \
-e MYSQL_DATABASE=chamilo \
mariadb
```
docker run --name mariadb -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_USER=chamilo -e MYSQL_PASSWORD=chamilo -e MYSQL_DATABASE=chamilo -d mariadb
docker run --link=mariadb:db --volumes-from=varwww --name chamilo -p 8080:80 -it chamilo/docker-chamilo
# Change all configuration to point to /var/www2/chamilo/www and change the Chamilo config file (root_web)
# Also, inside app/config/configuration.php, change "session_stored_in_db" to true
# configure Chamilo on this first container then take a snapshot

```bash
docker run -d \
--name=chamilo_lb-n1 \
--hostname=chamilo_lb-n1 \
--domainname=example.net \
--link=chamilo-db_lb \
--volumes-from=varwww \
-p 80 \
chamilo/docker-chamilo:1.11.12
```

### Some extra Configuration

Change all configuration to point to /var/www2/chamilo/www and change the Chamilo config file (root_web)
Also, inside app/config/configuration.php, change "session_stored_in_db" to true
configure Chamilo on this first container then take a snapshot

```bash
docker commit -m "Live running Chamilo connected to host 'db' with existing database" {container-hash} docker-chamilo:live
docker run --link=mariadb:db --volumes-from=varwww --name chamilo2 -p 8081:80 -it docker-chamilo:live
docker run --name lb --link=chamilo:w1 --link=chamilo4:w2 -e CHAMILO_1_PORT_80_TCP_ADDR=172.17.0.10 -e CHAMILO_2_PORT_80_TCP_ADDR=172.17.0.11 -e CHAMILO_HOSTNAME=docker.chamilo.net -e CHAMILO_PATH=/ -p 8082:80 -it jasonwyatt/nginx-loadbalancer
```

Sadly, there's something wrong at the moment in the nginx-loadbalancer image, and you have to connect to it to change the configuration of the reverse proxy (the last container you launched).
### Start another container

```bash
docker run -d \
--name=chamilo_lb-n2 \
--hostname=chamilo_lb-n2 \
--domainname=example.net \
--link=chamilo-db_lb \
--volumes-from=varwww \
-p 80 \
docker-chamilo:live
```

### Start the load-balancer

```bash
docker run -it \
--name lb \
--link=chamilo_lb-n1:w1 \
--link=chamilo_lb-n2:w2 \
-e CHAMILO_1_PORT_80_TCP_ADDR=172.17.0.10 \
-e CHAMILO_2_PORT_80_TCP_ADDR=172.17.0.11 \
-e CHAMILO_HOSTNAME=chamilo.example.net \
-e CHAMILO_PATH=/ \
-p 80 \
jasonwyatt/nginx-loadbalancer
```

Sadly, there's something wrong at the moment in the nginx-loadbalancer image, and you have to connect to it to change the configuration of the reverse proxy (the last container you launched).

```bash
docker ps
```

(to identify the hash of the image of the load balancer (lb))

```
docker exec -i -t {lb-container-hash} bash
```bash
docker exec -it {lb-container-hash} /bin/bash
cd /etc/nginx/sites-available/
vi proxy.conf
```

(add the following *just before* proxy_pass, in the two occurrences)

```
```bash
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
```

Now reload Nginx

```
```bash
service nginx reload
```

Expand Down
Loading