diff --git a/Dockerfile b/Dockerfile index f851c5e..884f7f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,61 +1,30 @@ -FROM ubuntu:14.04 -MAINTAINER Yannick Warnier - -# 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 - -# Configure and start Apache -ADD chamilo.conf /etc/apache2/sites-available/chamilo.conf -RUN a2ensite chamilo -RUN a2enmod rewrite -RUN /etc/init.d/apache2 restart -RUN echo "127.0.0.1 docker.chamilo.net" >> /etc/hosts - -# Go to Chamilo folder and install -# Soon... (this involves having a SQL server in a linked container) - -WORKDIR /var/www/chamilo/www -EXPOSE 22 80 -CMD ["/bin/bash"] +from ubuntu:bionic + +ENV DEBIAN_FRONTEND=noninteractive + +# Install Apache and PHP + +RUN apt-get update && \ + apt-get install -y apache2 php libapache2-mod-php php-gd php-intl php-curl php-json php-mysql php-zip php-xml php-mbstring php-dom composer git && \ + apt-get clean && rm -rf /var/lib/apt/lists/* + +# Install Chamilo LMS +RUN mkdir /var/www/chamilo-template && \ + git clone -b 1.11.x --single-branch https://github.com/chamilo/chamilo-lms.git /var/www/chamilo-template && \ + cd /var/www/chamilo-template && composer update && \ + chown -R www-data:www-data app main/default_course_document/images main/lang web && \ + rm -rf /var/www/chamilo-template/.git + +# Prepare Apache and PHP configuration +RUN rm /var/www/html/* +COPY htaccessForChamilo.conf /etc/apache2/conf-available/ +COPY php-overrides.ini /etc/php/7.2/apache2/conf.d/20-php.ini +RUN a2enconf htaccessForChamilo && \ + a2enmod rewrite && \ + sed -ri -e 's!^(\s*ErrorLog)\s+\S+!\1 /proc/self/fd/2!g' /etc/apache2/sites-enabled/000-default.conf + +EXPOSE 80 + +COPY init-and-run.sh . + +CMD ["./init-and-run.sh"] diff --git a/README.md b/README.md index 47d2355..076d457 100644 --- a/README.md +++ b/README.md @@ -1,83 +1,60 @@ # docker-chamilo Official Docker image for Chamilo LMS -This image is not ready yet. Please come back soon or watch the project for updates. +The image is based on Chamilo LMS 1.11 and uses Apache as web server. -## Launching +## Launching for a quick demo -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 -``` +**Hint: You will loose data when stopping the containers.** -This will get you back on the command line of the Docker host. You can see the container running with ```docker ps```. +We need to start a MariaDB database and the Chamilo docker image. -Then start the chamilo/docker-chamilo container: +We suggest using the "mariadb" container, like so: ``` -docker run --link=mariadb:db --name chamilo -p 8080:80 -it chamilo/docker-chamilo +docker run --name chamilo-db -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_USER=chamilo -e MYSQL_PASSWORD=chamilo -e MYSQL_DATABASE=chamilo -d mariadb:10-bionic ``` -At this point, the docker-chamilo image doesn't provide an installed version of Chamilo LMS, but this should be ready soon. +See https://hub.docker.com/_/mariadb/ for more options. -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. +Now start the Chamilo image, linked to the database container. ``` -72.17.0.10 docker.chamilo.net +docker run --link=chamilo-db:db --name chamilo -p 8080:80 -d chamilo/docker-chamilo ``` -Now start your browser and load http://docker.chamilo.net. +Now start your browser and load http://my_docker_ip:8080. -## Using with a load-balancer +Hint: -If you want to use a more complex system with load balancing, you might want to try out the following suite of commands: +In the initial setup use the following values: -``` -docker run --name varwww -d ywarnier/varw -``` +* URL of the application is the IP of your docker server. +* host of the database is defined by the *--link* option: db +* username and password are defined in the docker run command of the database. See above. -This will provide a shared /var/www2 partition +## Launching with various options -``` -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 -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 -``` +**Persistent volumes for the database and the Chamilo configuration** -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). +Create a data directory on a suitable volume on your host system, e.g. + + mkdir /my/chamilo/db + mkdir /my/chamilo/web -``` -docker ps -``` -(to identify the hash of the image of the load balancer (lb)) +Start your mariadb container like this: ``` -docker exec -i -t {lb-container-hash} bash -cd /etc/nginx/sites-available/ -vi proxy.conf +docker run --name chamilo-db -e MYSQL_ROOT_PASSWORD=pass -e MYSQL_USER=chamilo -e MYSQL_PASSWORD=chamilo -e MYSQL_DATABASE=chamilo -v /my/chamilo/db:/var/lib/mysql -d mariadb:10-bionic ``` -(add the following *just before* proxy_pass, in the two occurrences) - ``` - proxy_set_header Host $host; - proxy_set_header X-Real-IP $remote_addr; +docker run --link=chamilo-db:db --name chamilo -p 8080:80 -d -v /my/chamilo/web:/var/www/html/ chamilo/docker-chamilo ``` -Now reload Nginx +**Using your own timezone** ``` -service nginx reload +docker run -e TZ=Europe/Berlin --link=chamilo-db:db --name chamilo -p 8080:80 -d chamilo/docker-chamilo ``` - -Now you should be good to go. - -Note that this will only work as long as you don't upload any file or object that needs to be stored on disk, as the two web servers will not share any disk space in the context presented above. diff --git a/chamilo.conf b/chamilo.conf deleted file mode 100644 index b899e42..0000000 --- a/chamilo.conf +++ /dev/null @@ -1,34 +0,0 @@ - - ServerAdmin webmaster@localhost - ServerName docker.chamilo.net - DocumentRoot /var/www/chamilo/www - - Options FollowSymLinks - AllowOverride None - - - Options Indexes FollowSymLinks MultiViews - AllowOverride All - # For Apache 2.2 - #Order allow,deny - #allow from all - # For Apache 2.4 - Require all granted - - LogLevel warn - ErrorLog ${APACHE_LOG_DIR}/docker.chamilo.net-error.log - CustomLog ${APACHE_LOG_DIR}/docker.chamilo.net-access.log combined - - php_value error_logging On - php_value error_reporting 6143 - php_value display_errors On - php_value memory_limit 128M - php_value upload_max_filesize 2000M - php_value post_max_size 2000M - php_value xdebug.enable On - php_value session.cookie_httponly 1 - php_value short_open_tag Off - php_value max_execution_time 240 - php_value allow_url_fopen Off - php_value date.timezone Europe/London - diff --git a/htaccessForChamilo.conf b/htaccessForChamilo.conf new file mode 100644 index 0000000..0ecf23b --- /dev/null +++ b/htaccessForChamilo.conf @@ -0,0 +1,3 @@ + + AllowOverride All + diff --git a/init-and-run.sh b/init-and-run.sh new file mode 100755 index 0000000..b811d10 --- /dev/null +++ b/init-and-run.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# copy template on first run +if [ ! -d "/var/www/html/main" ]; then + echo "First run: move Chamilo LMS to web folder. Wait ..." + cp -rT -p /var/www/chamilo-template /var/www/html + rm -rf /var/www/chamilo-template +fi + +echo "Starting Apache Webserver" + +apachectl -D FOREGROUND diff --git a/php-overrides.ini b/php-overrides.ini new file mode 100644 index 0000000..275f5f5 --- /dev/null +++ b/php-overrides.ini @@ -0,0 +1,4 @@ +post_max_size = 25M +upload_max_filesize = 25M +memory_limit = 256M +session.cookie_httponly = true