From 217deb826fee0f1da17ce0adb4b3b4aa256b7a46 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Tue, 4 Apr 2017 17:58:39 +0530 Subject: [PATCH 01/23] Added dockerfiles to create container for moodle. --- moodle/centos7/Dockerfile | 23 ++++++++++++ moodle/centos7/fix-permissions.sh | 8 ++++ moodle/centos7/install.sh | 62 +++++++++++++++++++++++++++++++ moodle/centos7/passwd.template | 14 +++++++ moodle/centos7/run.sh | 31 ++++++++++++++++ 5 files changed, 138 insertions(+) create mode 100644 moodle/centos7/Dockerfile create mode 100755 moodle/centos7/fix-permissions.sh create mode 100755 moodle/centos7/install.sh create mode 100644 moodle/centos7/passwd.template create mode 100755 moodle/centos7/run.sh diff --git a/moodle/centos7/Dockerfile b/moodle/centos7/Dockerfile new file mode 100644 index 00000000..bf4c5572 --- /dev/null +++ b/moodle/centos7/Dockerfile @@ -0,0 +1,23 @@ +FROM registry.centos.org/centos/centos:7 + +MAINTAINER Mohammed Zeeshan Ahmed + +# RUN yum -y update && yum clean all + +ENV MOODLE_VERSION="3.1" \ + MOODLE_NODOT_VERSION="stable31" + +RUN mkdir -p /opt/scripts + +ADD install.sh fix-permissions.sh run.sh passwd.template /opt/scripts/ + +RUN . /opt/scripts/install.sh + +EXPOSE 8080 8443 + +WORKDIR /var/www/html + +USER apache + +ENTRYPOINT ["/opt/scripts/run.sh"] +CMD ["moodle"] \ No newline at end of file diff --git a/moodle/centos7/fix-permissions.sh b/moodle/centos7/fix-permissions.sh new file mode 100755 index 00000000..a4f15b03 --- /dev/null +++ b/moodle/centos7/fix-permissions.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +# Fix permissions on the given directory to allow group read/write of +# regular files and execute of directories. +set -eux +find "$1" -exec chown ${2} {} \; +find "$1" -exec chgrp 0 {} \; +find "$1" -exec chmod g+rw {} \; +find "$1" -type d -exec chmod g+x {} + \ No newline at end of file diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh new file mode 100755 index 00000000..2f2fcb25 --- /dev/null +++ b/moodle/centos7/install.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash + +set -eux; + +# Initialize variables +HTTPD_CONF="/etc/httpd/conf/httpd.conf" +HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" +INSTALL_PKGS2="httpd nss_wrapper gettext"; +PHP_REQUIRED="php php-mysql php-pgsql php-xml php-xmlrpc php-gd" +PHP_GOOD_TO_HAVE="php-xcache php-intl php-soap php-xmlrpc php-mbstring" +PHP_PACKAGES="${PHP_REQUIRED} ${PHP_GOOD_TO_HAVE}" +INSTALL_PKGS1="wget"; +INSTALL_PKGS="${INSTALL_PKGS1} ${INSTALL_PKGS2} ${PHP_PACKAGES}" +MOODLE="moodle" +MOODLE_DOWNLOAD_BASE="https://download.moodle.org" +MOODLE_VERSION=${MOODLE_VERSION-"latest"} +MOODLE_NODOT_VERSION=${MOODLE_NODOT_VERSION:-"moodle"} +MOODLE_TAR="${MOODLE}-${MOODLE_VERSION}.tgz" +MOODLE_DOWNLOAD_URL="${MOODLE_DOWNLOAD_BASE}/${MOODLE_NODOT_VERSION}/${MOODLE_TAR}" +PHP_INI_LOC="/etc/php.ini" + +export MOODLE_DATA="/var/moodledata" + +# Setup necessary packages +yum -y install epel-release && yum -y install --skip-broken ${INSTALL_PKGS}; + +# Install moodle +pushd /var/www; +wget ${MOODLE_DOWNLOAD_URL} && tar zxvf ${MOODLE_TAR} && mv /var/www/${MOODLE}/* /var/www/html; +mkdir -p /var/moodledata +popd; + +# Fixup Configurations +rm -rf ${HTTPD_WELCOME}; +sed -i 's/^Listen 80/Listen 8080\\\nListen 8443/g' ${HTTPD_CONF}; +sed -i 's/^Listen 8080\\/Listen 8080/g' ${HTTPD_CONF}; +sed -i 's/^Group apache/Group root/g' ${HTTPD_CONF}; +mkdir -p /etc/httpd/logs && touch /etc/httpd/logs/error_log && touch /etc/httpd/logs/access_log; + +# Fix the permissions +for item in "/etc/httpd" "/var/www" "/var/moodledata"; do + . /opt/scripts/fix-permissions.sh ${item} apache; +done + +chmod -R 777 /etc/httpd/logs; + +# Enable opcache +cat <> ${PHP_INI_LOC} +[opcache] +opcache.enable=1 +opcache.enable_cli=1 +opcache.memory_consumption=128 +opcache.interned_strings_buffer=8 +opcache.max_accelerated_files=4000 +opcache.max_wasted_percentage=5 +opcache.use_cwd=1 +opcache.validate_timestamps=1 +opcache.fast_shutdown=1 +EOT + +# Cleanup +yum -y remove ${INSTALL_PKGS1} && yum clean all \ No newline at end of file diff --git a/moodle/centos7/passwd.template b/moodle/centos7/passwd.template new file mode 100644 index 00000000..744ecd84 --- /dev/null +++ b/moodle/centos7/passwd.template @@ -0,0 +1,14 @@ +root:x:0:0:root:/root:/bin/bash +bin:x:1:1:bin:/bin:/sbin/nologin +daemon:x:2:2:daemon:/sbin:/sbin/nologin +adm:x:3:4:adm:/var/adm:/sbin/nologin +lp:x:4:7:lp:/var/spool/lpd:/sbin/nologin +sync:x:5:0:sync:/sbin:/bin/sync +shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown +halt:x:7:0:halt:/sbin:/sbin/halt +mail:x:8:12:mail:/var/spool/mail:/sbin/nologin +operator:x:11:0:operator:/root:/sbin/nologin +games:x:12:100:games:/usr/games:/sbin/nologin +ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin +nobody:x:99:99:Nobody:/:/sbin/nologin +apache:x:${USER_ID}:${GROUP_ID}:Apache User:${HOME}:/bin/bash \ No newline at end of file diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh new file mode 100755 index 00000000..63d7a58b --- /dev/null +++ b/moodle/centos7/run.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +export USER_ID=$(id -u); +export GROUP_ID=$(id -g); +envsubst < /opt/scripts/passwd.template > /tmp/passwd; +export LD_PRELOAD=libnss_wrapper.so; +export NSS_WRAPPER_PASSWD=/tmp/passwd; +export NSS_WRAPPER_GROUP=/etc/group; + +DB_TYPE=${DB_TYPE:-"mysqli"}; +DB_LIBRARY=${DB_LIBRARY:-"native"}; +DB_HOST=${DB_HOST:-"localhost"}; +DB_NAME=${DB_NAME:-"moodle"}; +DB_USER=${DB_USER:-"moodle"}; +DB_PASSWD=${DB_PASSWD:-"moodle"}; +if [ -z ${MOODLE_HOST} ]; then + MOODLE_HOST="`hostname -i`"; +fi + +if [ $1 == "moodle" ]; then + sed -e "s/pgsql/${DB_TYPE}/ + s/username/${DB_USER}/ + s/password/${DB_PASSWD}/ + s/http:\/\/example.com\/moodle/http:\/\/${MOODLE_HOST}:8080/ + s/localhost/${DB_HOST}/ + s/\/home\/example\/moodledata/\/var\/moodledata/" /var/www/html/config-dist.php > /var/www/html/config.php; + + exec /usr/sbin/httpd -DFOREGROUND; +else + exec $@ +fi \ No newline at end of file From 4cb5480fe743d8fb0e3ddf2d52df1023a13fb0e2 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Tue, 4 Apr 2017 18:45:32 +0530 Subject: [PATCH 02/23] Updated to alter install zend opcache and configuration. --- moodle/centos7/install.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index 2f2fcb25..2a0488ab 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -7,7 +7,7 @@ HTTPD_CONF="/etc/httpd/conf/httpd.conf" HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" INSTALL_PKGS2="httpd nss_wrapper gettext"; PHP_REQUIRED="php php-mysql php-pgsql php-xml php-xmlrpc php-gd" -PHP_GOOD_TO_HAVE="php-xcache php-intl php-soap php-xmlrpc php-mbstring" +PHP_GOOD_TO_HAVE="php-pecl-zendopcache php-intl php-soap php-xmlrpc php-mbstring" PHP_PACKAGES="${PHP_REQUIRED} ${PHP_GOOD_TO_HAVE}" INSTALL_PKGS1="wget"; INSTALL_PKGS="${INSTALL_PKGS1} ${INSTALL_PKGS2} ${PHP_PACKAGES}" @@ -17,7 +17,7 @@ MOODLE_VERSION=${MOODLE_VERSION-"latest"} MOODLE_NODOT_VERSION=${MOODLE_NODOT_VERSION:-"moodle"} MOODLE_TAR="${MOODLE}-${MOODLE_VERSION}.tgz" MOODLE_DOWNLOAD_URL="${MOODLE_DOWNLOAD_BASE}/${MOODLE_NODOT_VERSION}/${MOODLE_TAR}" -PHP_INI_LOC="/etc/php.ini" +OPCACHE_INI_LOC="/etc/php.d/opcache.ini" export MOODLE_DATA="/var/moodledata" @@ -45,17 +45,18 @@ done chmod -R 777 /etc/httpd/logs; # Enable opcache -cat <> ${PHP_INI_LOC} +cat < ${OPCACHE_INI_LOC} [opcache] -opcache.enable=1 -opcache.enable_cli=1 -opcache.memory_consumption=128 -opcache.interned_strings_buffer=8 -opcache.max_accelerated_files=4000 -opcache.max_wasted_percentage=5 -opcache.use_cwd=1 -opcache.validate_timestamps=1 -opcache.fast_shutdown=1 +opcache.enable = 1 +opcache.memory_consumption = 64 +opcache.max_accelerated_files = 8000 +opcache.revalidate_freq = 60 + +; Required for Moodle +opcache.use_cwd = 1 +opcache.validate_timestamps = 1 +opcache.save_comments = 1 +opcache.enable_file_override = 0 EOT # Cleanup From 8d795c6663645673aa0bc4e23f1a179d88365232 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Tue, 4 Apr 2017 18:47:00 +0530 Subject: [PATCH 03/23] Added cccp.yml file to allow building on pipeline. --- moodle/centos7/cccp.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 moodle/centos7/cccp.yml diff --git a/moodle/centos7/cccp.yml b/moodle/centos7/cccp.yml new file mode 100644 index 00000000..9b1237e1 --- /dev/null +++ b/moodle/centos7/cccp.yml @@ -0,0 +1 @@ +job-id: moodle \ No newline at end of file From 70b1b733b56a9f37ab93ac03f31a99ac9552ed29 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Wed, 5 Apr 2017 12:18:22 +0530 Subject: [PATCH 04/23] Moodle container now functional on openshift. --- moodle/centos7/run.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index 63d7a58b..0995d773 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -17,15 +17,21 @@ if [ -z ${MOODLE_HOST} ]; then MOODLE_HOST="`hostname -i`"; fi +if [ -z ${MOODLE_HOST_NOPORT} ]; then + if [[ ${MOODLE_HOST} != *":"* ]]; then + MOODLE_HOST="${MOODLE_HOST}:8080" + fi +fi + if [ $1 == "moodle" ]; then sed -e "s/pgsql/${DB_TYPE}/ s/username/${DB_USER}/ s/password/${DB_PASSWD}/ - s/http:\/\/example.com\/moodle/http:\/\/${MOODLE_HOST}:8080/ + s/http:\/\/example.com\/moodle/http:\/\/${MOODLE_HOST}/ s/localhost/${DB_HOST}/ s/\/home\/example\/moodledata/\/var\/moodledata/" /var/www/html/config-dist.php > /var/www/html/config.php; exec /usr/sbin/httpd -DFOREGROUND; else exec $@ -fi \ No newline at end of file +fi From 76a1896e6a8dde4a0d496ece70ebefbe591e7f09 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Wed, 5 Apr 2017 16:01:34 +0530 Subject: [PATCH 05/23] Added few more packages to allow more options for datasources. Will continue to add as i keep figuring things out. --- moodle/centos7/install.sh | 18 ++++++++++++++---- moodle/centos7/run.sh | 2 +- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index 2a0488ab..45e5d621 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -5,12 +5,17 @@ set -eux; # Initialize variables HTTPD_CONF="/etc/httpd/conf/httpd.conf" HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" -INSTALL_PKGS2="httpd nss_wrapper gettext"; -PHP_REQUIRED="php php-mysql php-pgsql php-xml php-xmlrpc php-gd" -PHP_GOOD_TO_HAVE="php-pecl-zendopcache php-intl php-soap php-xmlrpc php-mbstring" -PHP_PACKAGES="${PHP_REQUIRED} ${PHP_GOOD_TO_HAVE}" + INSTALL_PKGS1="wget"; +INSTALL_PKGS2="httpd nss_wrapper gettext"; + +PHP_PACKAGES1="php php-mysql php-pgsql php-xml php-xmlrpc php-gd php-mongodb php-pecl-apcu mssql-tools redis freetds"; +PHP_PACKAGES2="php-pecl-zendopcache php-pecl-memcache php-pecl-memcached php-intl php-soap php-xmlrpc php-mbstring"; +PHP_PACKAGES3="php-pecl-solr php-pecl-solr2 " + +PHP_PACKAGES="${PHP_PACKAGES1} ${PHP_PACKAGES2} ${PHP_PACKAGES3}" INSTALL_PKGS="${INSTALL_PKGS1} ${INSTALL_PKGS2} ${PHP_PACKAGES}" + MOODLE="moodle" MOODLE_DOWNLOAD_BASE="https://download.moodle.org" MOODLE_VERSION=${MOODLE_VERSION-"latest"} @@ -18,9 +23,14 @@ MOODLE_NODOT_VERSION=${MOODLE_NODOT_VERSION:-"moodle"} MOODLE_TAR="${MOODLE}-${MOODLE_VERSION}.tgz" MOODLE_DOWNLOAD_URL="${MOODLE_DOWNLOAD_BASE}/${MOODLE_NODOT_VERSION}/${MOODLE_TAR}" OPCACHE_INI_LOC="/etc/php.d/opcache.ini" +MSSQL_REPODATA="https://packages.microsoft.com/config/rhel/7/prod.repo" +export ACCEPT_EULA="Y" export MOODLE_DATA="/var/moodledata" +# Setup repositories +pushd /etc/yum.repos.d && wget ${MSSQL_REPODATA} && popd + # Setup necessary packages yum -y install epel-release && yum -y install --skip-broken ${INSTALL_PKGS}; diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index 0995d773..7b20a394 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -7,7 +7,7 @@ export LD_PRELOAD=libnss_wrapper.so; export NSS_WRAPPER_PASSWD=/tmp/passwd; export NSS_WRAPPER_GROUP=/etc/group; -DB_TYPE=${DB_TYPE:-"mysqli"}; +DB_TYPE=${DB_TYPE:-"pgsql"}; DB_LIBRARY=${DB_LIBRARY:-"native"}; DB_HOST=${DB_HOST:-"localhost"}; DB_NAME=${DB_NAME:-"moodle"}; From 1e3848cbb26ad4f1cb371bc0a3570af131067c2e Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Wed, 5 Apr 2017 17:13:33 +0530 Subject: [PATCH 06/23] Added redis, solr apcu packages. --- moodle/centos7/install.sh | 35 +++++++++++++++++++---------------- moodle/centos7/run.sh | 29 +++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 16 deletions(-) diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index 45e5d621..051e0d47 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -9,30 +9,33 @@ HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" INSTALL_PKGS1="wget"; INSTALL_PKGS2="httpd nss_wrapper gettext"; -PHP_PACKAGES1="php php-mysql php-pgsql php-xml php-xmlrpc php-gd php-mongodb php-pecl-apcu mssql-tools redis freetds"; +PHP_PACKAGES1="php php-mysql php-pgsql php-xml php-xmlrpc php-gd php-mongodb php-pecl-apcu redis freetds"; PHP_PACKAGES2="php-pecl-zendopcache php-pecl-memcache php-pecl-memcached php-intl php-soap php-xmlrpc php-mbstring"; -PHP_PACKAGES3="php-pecl-solr php-pecl-solr2 " +PHP_PACKAGES3="php-pecl-solr php-pecl-solr2 php-pecl-redis" +PHP_MS_ORACLE_PACKAGES="mssql-tools" -PHP_PACKAGES="${PHP_PACKAGES1} ${PHP_PACKAGES2} ${PHP_PACKAGES3}" -INSTALL_PKGS="${INSTALL_PKGS1} ${INSTALL_PKGS2} ${PHP_PACKAGES}" +PHP_PACKAGES="${PHP_PACKAGES1} ${PHP_PACKAGES2} ${PHP_PACKAGES3}"; +INSTALL_PKGS="${INSTALL_PKGS1} ${INSTALL_PKGS2} ${PHP_PACKAGES}"; -MOODLE="moodle" -MOODLE_DOWNLOAD_BASE="https://download.moodle.org" -MOODLE_VERSION=${MOODLE_VERSION-"latest"} -MOODLE_NODOT_VERSION=${MOODLE_NODOT_VERSION:-"moodle"} -MOODLE_TAR="${MOODLE}-${MOODLE_VERSION}.tgz" -MOODLE_DOWNLOAD_URL="${MOODLE_DOWNLOAD_BASE}/${MOODLE_NODOT_VERSION}/${MOODLE_TAR}" -OPCACHE_INI_LOC="/etc/php.d/opcache.ini" -MSSQL_REPODATA="https://packages.microsoft.com/config/rhel/7/prod.repo" +MOODLE="moodle"; +MOODLE_DOWNLOAD_BASE="https://download.moodle.org"; +MOODLE_VERSION=${MOODLE_VERSION-"latest"}; +MOODLE_NODOT_VERSION=${MOODLE_NODOT_VERSION:-"moodle"}; +MOODLE_TAR="${MOODLE}-${MOODLE_VERSION}.tgz"; +MOODLE_DOWNLOAD_URL="${MOODLE_DOWNLOAD_BASE}/${MOODLE_NODOT_VERSION}/${MOODLE_TAR}"; +OPCACHE_INI_LOC="/etc/php.d/opcache.ini"; +MSSQL_REPODATA="https://packages.microsoft.com/config/rhel/7/prod.repo"; -export ACCEPT_EULA="Y" -export MOODLE_DATA="/var/moodledata" +export ACCEPT_EULA="Y"; +export MOODLE_DATA="/var/moodledata"; + +# INSTALL BEGINS # Setup repositories pushd /etc/yum.repos.d && wget ${MSSQL_REPODATA} && popd # Setup necessary packages -yum -y install epel-release && yum -y install --skip-broken ${INSTALL_PKGS}; +yum -y install epel-release && yum -y install --skip-broken ${INSTALL_PKGS} # Install moodle pushd /var/www; @@ -48,7 +51,7 @@ sed -i 's/^Group apache/Group root/g' ${HTTPD_CONF}; mkdir -p /etc/httpd/logs && touch /etc/httpd/logs/error_log && touch /etc/httpd/logs/access_log; # Fix the permissions -for item in "/etc/httpd" "/var/www" "/var/moodledata"; do +for item in "/etc/httpd" "/var/www" "/var/moodledata" "/etc/freetds.conf"; do . /opt/scripts/fix-permissions.sh ${item} apache; done diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index 7b20a394..d810e3a1 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# Permissions export USER_ID=$(id -u); export GROUP_ID=$(id -g); envsubst < /opt/scripts/passwd.template > /tmp/passwd; @@ -7,6 +8,7 @@ export LD_PRELOAD=libnss_wrapper.so; export NSS_WRAPPER_PASSWD=/tmp/passwd; export NSS_WRAPPER_GROUP=/etc/group; +# Initialize and validate variables DB_TYPE=${DB_TYPE:-"pgsql"}; DB_LIBRARY=${DB_LIBRARY:-"native"}; DB_HOST=${DB_HOST:-"localhost"}; @@ -23,7 +25,33 @@ if [ -z ${MOODLE_HOST_NOPORT} ]; then fi fi +FREETDS_FILE="/etc/freetds.conf"; +FREETDS_VERSION="4.2"; + +# Helpers + +mssql_freetds() { + +cat < ${FREETDS_FILE} +[global] + tds version = ${FREETDS_VERSION} + text size = 20971520 + host = ${DB_HOST} + port = 1433 + client charset = UTF-8 +EOT + +} + +# Main Begins + if [ $1 == "moodle" ]; then + + if [ ${DB_TYPE} == "mssql" ]; then + echo "The packages required for this require PHP 7, hence MSSQL is not currently supported"; + exit 1 + # mssql_freetds; + fi sed -e "s/pgsql/${DB_TYPE}/ s/username/${DB_USER}/ s/password/${DB_PASSWD}/ @@ -31,6 +59,7 @@ if [ $1 == "moodle" ]; then s/localhost/${DB_HOST}/ s/\/home\/example\/moodledata/\/var\/moodledata/" /var/www/html/config-dist.php > /var/www/html/config.php; + exec /usr/sbin/httpd -DFOREGROUND; else exec $@ From 19b39cb78e01dd49cfa2a6dd0b8cad1d429bbc42 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Thu, 6 Apr 2017 14:51:03 +0530 Subject: [PATCH 07/23] Updated to use remicolt repository for php 71. --- moodle/centos7/Dockerfile | 3 ++- moodle/centos7/README.md | 0 moodle/centos7/install.sh | 42 ++++++++++++++++----------------------- 3 files changed, 19 insertions(+), 26 deletions(-) create mode 100644 moodle/centos7/README.md diff --git a/moodle/centos7/Dockerfile b/moodle/centos7/Dockerfile index bf4c5572..d8a07e2e 100644 --- a/moodle/centos7/Dockerfile +++ b/moodle/centos7/Dockerfile @@ -5,7 +5,8 @@ MAINTAINER Mohammed Zeeshan Ahmed # RUN yum -y update && yum clean all ENV MOODLE_VERSION="3.1" \ - MOODLE_NODOT_VERSION="stable31" + MOODLE_NODOT_VERSION="stable31"\ + PHP_REMI_VERSION="php71" RUN mkdir -p /opt/scripts diff --git a/moodle/centos7/README.md b/moodle/centos7/README.md new file mode 100644 index 00000000..e69de29b diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index 051e0d47..4133115a 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -8,14 +8,21 @@ HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" INSTALL_PKGS1="wget"; INSTALL_PKGS2="httpd nss_wrapper gettext"; +REMI_REPO="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" +PHP_REMI_VERSION="${PHP_REMI_VERSION:-"php71"}" -PHP_PACKAGES1="php php-mysql php-pgsql php-xml php-xmlrpc php-gd php-mongodb php-pecl-apcu redis freetds"; -PHP_PACKAGES2="php-pecl-zendopcache php-pecl-memcache php-pecl-memcached php-intl php-soap php-xmlrpc php-mbstring"; -PHP_PACKAGES3="php-pecl-solr php-pecl-solr2 php-pecl-redis" -PHP_MS_ORACLE_PACKAGES="mssql-tools" +PHP1="${PHP_REMI_VERSION} ${PHP_REMI_VERSION}-php ${PHP_REMI_VERSION}-php-pgsql ${PHP_REMI_VERSION}-php-mysqlnd" +PHP2="${PHP_REMI_VERSION}-php-pecl-mysql ${PHP_REMI_VERSION}-php-xml ${PHP_REMI_VERSION}-php-xmlrpc " +PHP3="${PHP_REMI_VERSION}-php-gd ${PHP_REMI_VERSION}-php-pecl-mongodb ${PHP_REMI_VERSION}php-pecl-apcu" +PHP4="${PHP_REMI_VERSION}-php-pecl-apcu-bc ${PHP_REMI_VERSION}-php-pecl-redis ${PHP_REMI_VERSION}-php-phpiredis" +PHP5="${PHP_REMI_VERSION}-php-opcache ${PHP_REMI_VERSION}-php-pecl-memcache ${PHP_REMI_VERSION}-php-pecl-memcached" +PHP6="${PHP_REMI_VERSION}-php-intl ${PHP_REMI_VERSION}-php-mbstring ${PHP_REMI_VERSION}-php-pecl-solr2" +PHP7="${PHP_REMI_VERSION}-php-pecl-zip ${PHP_REMI_VERSION}-php-soap" -PHP_PACKAGES="${PHP_PACKAGES1} ${PHP_PACKAGES2} ${PHP_PACKAGES3}"; -INSTALL_PKGS="${INSTALL_PKGS1} ${INSTALL_PKGS2} ${PHP_PACKAGES}"; +#PHP_MS_ORACLE_PACKAGES="freetds mssql-tools" + +PHP_PACKAGES="${PHP1} ${PHP2} ${PHP3} ${PHP4} ${PHP5} ${PHP6} ${PHP7}"; +INSTALL_PKGS="${INSTALL_PKGS2} ${PHP_PACKAGES}"; MOODLE="moodle"; MOODLE_DOWNLOAD_BASE="https://download.moodle.org"; @@ -23,7 +30,6 @@ MOODLE_VERSION=${MOODLE_VERSION-"latest"}; MOODLE_NODOT_VERSION=${MOODLE_NODOT_VERSION:-"moodle"}; MOODLE_TAR="${MOODLE}-${MOODLE_VERSION}.tgz"; MOODLE_DOWNLOAD_URL="${MOODLE_DOWNLOAD_BASE}/${MOODLE_NODOT_VERSION}/${MOODLE_TAR}"; -OPCACHE_INI_LOC="/etc/php.d/opcache.ini"; MSSQL_REPODATA="https://packages.microsoft.com/config/rhel/7/prod.repo"; export ACCEPT_EULA="Y"; @@ -32,15 +38,16 @@ export MOODLE_DATA="/var/moodledata"; # INSTALL BEGINS # Setup repositories +yum -y install ${INSTALL_PKGS1} pushd /etc/yum.repos.d && wget ${MSSQL_REPODATA} && popd # Setup necessary packages -yum -y install epel-release && yum -y install --skip-broken ${INSTALL_PKGS} +yum -y install epel-release && yum -y install ${REMI_REPO} && yum -y install --skip-broken ${INSTALL_PKGS} # Install moodle pushd /var/www; wget ${MOODLE_DOWNLOAD_URL} && tar zxvf ${MOODLE_TAR} && mv /var/www/${MOODLE}/* /var/www/html; -mkdir -p /var/moodledata +mkdir -p /var/moodledata && rm -rf ${MOODLE_TAR} popd; # Fixup Configurations @@ -51,26 +58,11 @@ sed -i 's/^Group apache/Group root/g' ${HTTPD_CONF}; mkdir -p /etc/httpd/logs && touch /etc/httpd/logs/error_log && touch /etc/httpd/logs/access_log; # Fix the permissions -for item in "/etc/httpd" "/var/www" "/var/moodledata" "/etc/freetds.conf"; do +for item in "/etc/httpd" "/var/www" "/var/moodledata"; do . /opt/scripts/fix-permissions.sh ${item} apache; done chmod -R 777 /etc/httpd/logs; -# Enable opcache -cat < ${OPCACHE_INI_LOC} -[opcache] -opcache.enable = 1 -opcache.memory_consumption = 64 -opcache.max_accelerated_files = 8000 -opcache.revalidate_freq = 60 - -; Required for Moodle -opcache.use_cwd = 1 -opcache.validate_timestamps = 1 -opcache.save_comments = 1 -opcache.enable_file_override = 0 -EOT - # Cleanup yum -y remove ${INSTALL_PKGS1} && yum clean all \ No newline at end of file From dc9f31d65987ba27c45b2f64eba7fb3cdaeffd3b Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Thu, 6 Apr 2017 14:51:29 +0530 Subject: [PATCH 08/23] Added basic readme. Will fill in once container is ready. --- moodle/centos7/README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/moodle/centos7/README.md b/moodle/centos7/README.md index e69de29b..1cda0284 100644 --- a/moodle/centos7/README.md +++ b/moodle/centos7/README.md @@ -0,0 +1 @@ +# Openshift Ready Moodle Container From 21e94f045f3c3afb521164d2468de6bb683ce092 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Thu, 6 Apr 2017 17:09:14 +0530 Subject: [PATCH 09/23] Modified remicolt repo url and brought back mssql. Need to figure out how to factor this in. --- moodle/centos7/install.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index 4133115a..f6d7bdee 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -8,7 +8,7 @@ HTTPD_WELCOME="/etc/httpd/conf.d/welcome.conf" INSTALL_PKGS1="wget"; INSTALL_PKGS2="httpd nss_wrapper gettext"; -REMI_REPO="http://rpms.famillecollet.com/enterprise/remi-release-7.rpm" +REMI_REPO="https://rpms.remirepo.net/enterprise/remi-release-7.rpm" PHP_REMI_VERSION="${PHP_REMI_VERSION:-"php71"}" PHP1="${PHP_REMI_VERSION} ${PHP_REMI_VERSION}-php ${PHP_REMI_VERSION}-php-pgsql ${PHP_REMI_VERSION}-php-mysqlnd" @@ -19,9 +19,9 @@ PHP5="${PHP_REMI_VERSION}-php-opcache ${PHP_REMI_VERSION}-php-pecl-memcache ${PH PHP6="${PHP_REMI_VERSION}-php-intl ${PHP_REMI_VERSION}-php-mbstring ${PHP_REMI_VERSION}-php-pecl-solr2" PHP7="${PHP_REMI_VERSION}-php-pecl-zip ${PHP_REMI_VERSION}-php-soap" -#PHP_MS_ORACLE_PACKAGES="freetds mssql-tools" +PHP_MSSQL_PACKAGES="freetds mssql-tools" -PHP_PACKAGES="${PHP1} ${PHP2} ${PHP3} ${PHP4} ${PHP5} ${PHP6} ${PHP7}"; +PHP_PACKAGES="${PHP1} ${PHP2} ${PHP3} ${PHP4} ${PHP5} ${PHP6} ${PHP7} ${PHP_MSSQL_PACKAGES}"; INSTALL_PKGS="${INSTALL_PKGS2} ${PHP_PACKAGES}"; MOODLE="moodle"; From 221abf7123b45993b2d65ebc7fecc45926f534c6 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Thu, 6 Apr 2017 18:53:00 +0530 Subject: [PATCH 10/23] Added mssql php extensions for using mssql as backend. --- moodle/centos7/install.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index f6d7bdee..a1f07955 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -19,7 +19,8 @@ PHP5="${PHP_REMI_VERSION}-php-opcache ${PHP_REMI_VERSION}-php-pecl-memcache ${PH PHP6="${PHP_REMI_VERSION}-php-intl ${PHP_REMI_VERSION}-php-mbstring ${PHP_REMI_VERSION}-php-pecl-solr2" PHP7="${PHP_REMI_VERSION}-php-pecl-zip ${PHP_REMI_VERSION}-php-soap" -PHP_MSSQL_PACKAGES="freetds mssql-tools" +PHP_MSSQL_PACKAGES="mssql-tools ${PHP_REMI_VERSION}-php-sqlsrv" +PHP_ORACLE_PACKAGES="" PHP_PACKAGES="${PHP1} ${PHP2} ${PHP3} ${PHP4} ${PHP5} ${PHP6} ${PHP7} ${PHP_MSSQL_PACKAGES}"; INSTALL_PKGS="${INSTALL_PKGS2} ${PHP_PACKAGES}"; @@ -47,7 +48,7 @@ yum -y install epel-release && yum -y install ${REMI_REPO} && yum -y install --s # Install moodle pushd /var/www; wget ${MOODLE_DOWNLOAD_URL} && tar zxvf ${MOODLE_TAR} && mv /var/www/${MOODLE}/* /var/www/html; -mkdir -p /var/moodledata && rm -rf ${MOODLE_TAR} +mkdir -p /var/moodledata && rm -rf ${MOODLE_TAR}; popd; # Fixup Configurations From 2308f04ab7ba27088e8b644d7411d0544b6f72cc Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Thu, 6 Apr 2017 18:59:20 +0530 Subject: [PATCH 11/23] Removed freetds and updated to fail if oracle backend is requested. This is due to licensing issues with oracle client. --- moodle/centos7/run.sh | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index d810e3a1..7871450d 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -25,32 +25,13 @@ if [ -z ${MOODLE_HOST_NOPORT} ]; then fi fi -FREETDS_FILE="/etc/freetds.conf"; -FREETDS_VERSION="4.2"; - -# Helpers - -mssql_freetds() { - -cat < ${FREETDS_FILE} -[global] - tds version = ${FREETDS_VERSION} - text size = 20971520 - host = ${DB_HOST} - port = 1433 - client charset = UTF-8 -EOT - -} - # Main Begins if [ $1 == "moodle" ]; then - if [ ${DB_TYPE} == "mssql" ]; then - echo "The packages required for this require PHP 7, hence MSSQL is not currently supported"; + if [ ${DB_TYPE} == "oci" ]; then + echo "Oracle database is not currently supported due to licensing issues with their client"; exit 1 - # mssql_freetds; fi sed -e "s/pgsql/${DB_TYPE}/ s/username/${DB_USER}/ From 0f4df784f3ade10b3e3cfde648395ee1a75aac74 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Thu, 6 Apr 2017 19:21:25 +0530 Subject: [PATCH 12/23] Updated to single env for hostand fixed name. Fixed the spacing. --- moodle/centos7/run.sh | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index 7871450d..d7f7424c 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -15,15 +15,7 @@ DB_HOST=${DB_HOST:-"localhost"}; DB_NAME=${DB_NAME:-"moodle"}; DB_USER=${DB_USER:-"moodle"}; DB_PASSWD=${DB_PASSWD:-"moodle"}; -if [ -z ${MOODLE_HOST} ]; then - MOODLE_HOST="`hostname -i`"; -fi - -if [ -z ${MOODLE_HOST_NOPORT} ]; then - if [[ ${MOODLE_HOST} != *":"* ]]; then - MOODLE_HOST="${MOODLE_HOST}:8080" - fi -fi +MOODLE_URL=${MOODLE_URL:-"http://`hostname -i`:8080"} # Main Begins @@ -33,14 +25,14 @@ if [ $1 == "moodle" ]; then echo "Oracle database is not currently supported due to licensing issues with their client"; exit 1 fi + sed -e "s/pgsql/${DB_TYPE}/ s/username/${DB_USER}/ s/password/${DB_PASSWD}/ - s/http:\/\/example.com\/moodle/http:\/\/${MOODLE_HOST}/ + s/http:\/\/example.com\/moodle/${MOODLE_URL}/ s/localhost/${DB_HOST}/ s/\/home\/example\/moodledata/\/var\/moodledata/" /var/www/html/config-dist.php > /var/www/html/config.php; - exec /usr/sbin/httpd -DFOREGROUND; else exec $@ From f5dd91fdff271faf95b482fbb5c421ee4ba5b98b Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Thu, 6 Apr 2017 19:40:41 +0530 Subject: [PATCH 13/23] Updated readme with some information. --- moodle/centos7/README.md | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/moodle/centos7/README.md b/moodle/centos7/README.md index 1cda0284..662a217d 100644 --- a/moodle/centos7/README.md +++ b/moodle/centos7/README.md @@ -1 +1,36 @@ # Openshift Ready Moodle Container + +## Building the container: + +To build this container yourself, please navigate this this directory after cloning and run: + + $ docker build -t moodle -f Dockerfile . + +## Running the container (with postgresql backend): + +First start postgresql container: + + $ docker run -e POSTGRESQL_USER=moodle -e POSTGRESQL_PASSWORD=moodle -e POSTGRESQL_DATABASE=moodle -d registry.centos.org/postgresql/postgresql:9.6 + +Now find the hostname or ip of postgresql container: + + $ docker run -e DB_TYPE=pgsql -e DB_HOST= -d moodle + +## Mount Points: + + 1. /var/moodledata - This is where the moodle will store its caching data. Please ensure you mount a volume with appropriate permissions here. + +## Environment Variables: + +You can customize parts of moodle by passing certain values as environment variables when you run it. + + 1. DB_TYPE - pgsql | mariadb | mysqli | mssql | sqlsrv | oci : The type of database to use. The terms are self explanatory, however oci for oracle is currently not supported due to licensing issues with their client software. + 2. DB_HOST - The hostname or ip of the database that moodle will use. + 3. DB_NAME - The name of the moodle database in the DB. This assumes the database has already been setup with appropriate users and permissions. + 4. DB_USER - The username of the user who has permissions on DB_NAME in DB_HOST. + 5. DB_PASSWD - The password of DB_USER. + 6. MOODLE_URL - The URL of moodle endpoint. This should include the the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http://containerip:8080. + +### Notes: + + 1. For users of selinux based systems, if you try to volume mount, you might have permission issues even if you do `-v /somepath:/var/moodledata:rw`. You can get more information about that [here](http://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/ "SELinux with docker volumes"). \ No newline at end of file From 18227e1adf2e2a58f5e5a44ca72463bd79b103e8 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Fri, 7 Apr 2017 11:27:12 +0530 Subject: [PATCH 14/23] Fixed package name and added end of file newlines. --- moodle/centos7/Dockerfile | 3 ++- moodle/centos7/cccp.yml | 3 ++- moodle/centos7/fix-permissions.sh | 3 ++- moodle/centos7/install.sh | 5 +++-- moodle/centos7/passwd.template | 3 ++- moodle/centos7/run.sh | 1 + 6 files changed, 12 insertions(+), 6 deletions(-) diff --git a/moodle/centos7/Dockerfile b/moodle/centos7/Dockerfile index d8a07e2e..fa89dde1 100644 --- a/moodle/centos7/Dockerfile +++ b/moodle/centos7/Dockerfile @@ -21,4 +21,5 @@ WORKDIR /var/www/html USER apache ENTRYPOINT ["/opt/scripts/run.sh"] -CMD ["moodle"] \ No newline at end of file +CMD ["moodle"] + diff --git a/moodle/centos7/cccp.yml b/moodle/centos7/cccp.yml index 9b1237e1..80551ae6 100644 --- a/moodle/centos7/cccp.yml +++ b/moodle/centos7/cccp.yml @@ -1 +1,2 @@ -job-id: moodle \ No newline at end of file +job-id: moodle + diff --git a/moodle/centos7/fix-permissions.sh b/moodle/centos7/fix-permissions.sh index a4f15b03..7eaf8135 100755 --- a/moodle/centos7/fix-permissions.sh +++ b/moodle/centos7/fix-permissions.sh @@ -5,4 +5,5 @@ set -eux find "$1" -exec chown ${2} {} \; find "$1" -exec chgrp 0 {} \; find "$1" -exec chmod g+rw {} \; -find "$1" -type d -exec chmod g+x {} + \ No newline at end of file +find "$1" -type d -exec chmod g+x {} + + diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index a1f07955..8b2f13aa 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -13,7 +13,7 @@ PHP_REMI_VERSION="${PHP_REMI_VERSION:-"php71"}" PHP1="${PHP_REMI_VERSION} ${PHP_REMI_VERSION}-php ${PHP_REMI_VERSION}-php-pgsql ${PHP_REMI_VERSION}-php-mysqlnd" PHP2="${PHP_REMI_VERSION}-php-pecl-mysql ${PHP_REMI_VERSION}-php-xml ${PHP_REMI_VERSION}-php-xmlrpc " -PHP3="${PHP_REMI_VERSION}-php-gd ${PHP_REMI_VERSION}-php-pecl-mongodb ${PHP_REMI_VERSION}php-pecl-apcu" +PHP3="${PHP_REMI_VERSION}-php-gd ${PHP_REMI_VERSION}-php-pecl-mongodb ${PHP_REMI_VERSION}-php-pecl-apcu" PHP4="${PHP_REMI_VERSION}-php-pecl-apcu-bc ${PHP_REMI_VERSION}-php-pecl-redis ${PHP_REMI_VERSION}-php-phpiredis" PHP5="${PHP_REMI_VERSION}-php-opcache ${PHP_REMI_VERSION}-php-pecl-memcache ${PHP_REMI_VERSION}-php-pecl-memcached" PHP6="${PHP_REMI_VERSION}-php-intl ${PHP_REMI_VERSION}-php-mbstring ${PHP_REMI_VERSION}-php-pecl-solr2" @@ -66,4 +66,5 @@ done chmod -R 777 /etc/httpd/logs; # Cleanup -yum -y remove ${INSTALL_PKGS1} && yum clean all \ No newline at end of file +yum -y remove ${INSTALL_PKGS1} && yum clean all + diff --git a/moodle/centos7/passwd.template b/moodle/centos7/passwd.template index 744ecd84..64b8fd40 100644 --- a/moodle/centos7/passwd.template +++ b/moodle/centos7/passwd.template @@ -11,4 +11,5 @@ operator:x:11:0:operator:/root:/sbin/nologin games:x:12:100:games:/usr/games:/sbin/nologin ftp:x:14:50:FTP User:/var/ftp:/sbin/nologin nobody:x:99:99:Nobody:/:/sbin/nologin -apache:x:${USER_ID}:${GROUP_ID}:Apache User:${HOME}:/bin/bash \ No newline at end of file +apache:x:${USER_ID}:${GROUP_ID}:Apache User:${HOME}:/bin/bash + diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index d7f7424c..710b7475 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -37,3 +37,4 @@ if [ $1 == "moodle" ]; then else exec $@ fi + From 0d54f07971066ed5626e2a878fab01bc84030b03 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Fri, 7 Apr 2017 11:48:38 +0530 Subject: [PATCH 15/23] Removed mssql-tools setup as it interferes with php-sqlserv. --- moodle/centos7/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index 8b2f13aa..581c7785 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -19,7 +19,7 @@ PHP5="${PHP_REMI_VERSION}-php-opcache ${PHP_REMI_VERSION}-php-pecl-memcache ${PH PHP6="${PHP_REMI_VERSION}-php-intl ${PHP_REMI_VERSION}-php-mbstring ${PHP_REMI_VERSION}-php-pecl-solr2" PHP7="${PHP_REMI_VERSION}-php-pecl-zip ${PHP_REMI_VERSION}-php-soap" -PHP_MSSQL_PACKAGES="mssql-tools ${PHP_REMI_VERSION}-php-sqlsrv" +PHP_MSSQL_PACKAGES="${PHP_REMI_VERSION}-php-sqlsrv" PHP_ORACLE_PACKAGES="" PHP_PACKAGES="${PHP1} ${PHP2} ${PHP3} ${PHP4} ${PHP5} ${PHP6} ${PHP7} ${PHP_MSSQL_PACKAGES}"; From 269883553d5e2f8bf6b11cde10cf468b16b37041 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Fri, 7 Apr 2017 11:53:13 +0530 Subject: [PATCH 16/23] Fixed default pattern for MOODLE_URL and added readme notice. The MOODLE_URL is passed to a sed in run and hence a user must be aware that he must escape appropriate characters such as http:// which should actually be http:\/\/. --- moodle/centos7/README.md | 4 ++-- moodle/centos7/run.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/moodle/centos7/README.md b/moodle/centos7/README.md index 662a217d..62345868 100644 --- a/moodle/centos7/README.md +++ b/moodle/centos7/README.md @@ -29,8 +29,8 @@ You can customize parts of moodle by passing certain values as environment varia 3. DB_NAME - The name of the moodle database in the DB. This assumes the database has already been setup with appropriate users and permissions. 4. DB_USER - The username of the user who has permissions on DB_NAME in DB_HOST. 5. DB_PASSWD - The password of DB_USER. - 6. MOODLE_URL - The URL of moodle endpoint. This should include the the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http://containerip:8080. + 6. MOODLE_URL - The URL of moodle endpoint. This should include the the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http:\/\/containerip:8080. **Please ensure you escape any such slashes in your own hostname as it will be internally passed to a `sed` command to update the config.php** ### Notes: - 1. For users of selinux based systems, if you try to volume mount, you might have permission issues even if you do `-v /somepath:/var/moodledata:rw`. You can get more information about that [here](http://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/ "SELinux with docker volumes"). \ No newline at end of file + 1. For users of selinux based systems, if you try to volume mount, you might have permission issues even if you do `-v /somepath:/var/moodledata:rw`. You can get more information about that [here](http://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/ "SELinux with docker volumes"). diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index 710b7475..9a713273 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -15,7 +15,7 @@ DB_HOST=${DB_HOST:-"localhost"}; DB_NAME=${DB_NAME:-"moodle"}; DB_USER=${DB_USER:-"moodle"}; DB_PASSWD=${DB_PASSWD:-"moodle"}; -MOODLE_URL=${MOODLE_URL:-"http://`hostname -i`:8080"} +MOODLE_URL=${MOODLE_URL:-"http:\/\/`hostname -i`:8080"} # Main Begins From 90e007aa8495fdc6fcebaefb4d4a03fd2a12ebb9 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Fri, 7 Apr 2017 12:14:19 +0530 Subject: [PATCH 17/23] Updated README to indicate that protocol is compulsory. --- moodle/centos7/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moodle/centos7/README.md b/moodle/centos7/README.md index 62345868..15b8129c 100644 --- a/moodle/centos7/README.md +++ b/moodle/centos7/README.md @@ -29,7 +29,7 @@ You can customize parts of moodle by passing certain values as environment varia 3. DB_NAME - The name of the moodle database in the DB. This assumes the database has already been setup with appropriate users and permissions. 4. DB_USER - The username of the user who has permissions on DB_NAME in DB_HOST. 5. DB_PASSWD - The password of DB_USER. - 6. MOODLE_URL - The URL of moodle endpoint. This should include the the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http:\/\/containerip:8080. **Please ensure you escape any such slashes in your own hostname as it will be internally passed to a `sed` command to update the config.php** + 6. MOODLE_URL - The URL of moodle endpoint. This should include the the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http:\/\/containerip:8080. **Please ensure you escape any such slashes in your own hostname as it will be internally passed to a `sed` command to update the config.php. Its compulsory to either have http or https preceeding this URL.** ### Notes: From dea50f269582fd652822a68cbce3c74da508da79 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Sat, 8 Apr 2017 14:19:01 +0530 Subject: [PATCH 18/23] Updated readme with information on how to track updates. --- moodle/centos7/README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/moodle/centos7/README.md b/moodle/centos7/README.md index 15b8129c..634a4b92 100644 --- a/moodle/centos7/README.md +++ b/moodle/centos7/README.md @@ -31,6 +31,12 @@ You can customize parts of moodle by passing certain values as environment varia 5. DB_PASSWD - The password of DB_USER. 6. MOODLE_URL - The URL of moodle endpoint. This should include the the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http:\/\/containerip:8080. **Please ensure you escape any such slashes in your own hostname as it will be internally passed to a `sed` command to update the config.php. Its compulsory to either have http or https preceeding this URL.** +### Tracking Updates: + + 1. **PHP** : PHP updates can be tracked in remicolt repository. + 2. **Moodle** : For moodle, we will have track releases on from download.moodle.org or even on release + monitoring (https://release-monitoring.org/project/6384/) + ### Notes: 1. For users of selinux based systems, if you try to volume mount, you might have permission issues even if you do `-v /somepath:/var/moodledata:rw`. You can get more information about that [here](http://www.projectatomic.io/blog/2015/06/using-volumes-with-docker-can-cause-problems-with-selinux/ "SELinux with docker volumes"). From dbd5091d3bda33e0ac75d5bbe8a72e59e8e4e930 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Tue, 11 Apr 2017 12:08:56 +0530 Subject: [PATCH 19/23] Uncommented the yum update. --- moodle/centos7/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moodle/centos7/Dockerfile b/moodle/centos7/Dockerfile index fa89dde1..216ff8b0 100644 --- a/moodle/centos7/Dockerfile +++ b/moodle/centos7/Dockerfile @@ -2,7 +2,7 @@ FROM registry.centos.org/centos/centos:7 MAINTAINER Mohammed Zeeshan Ahmed -# RUN yum -y update && yum clean all +RUN yum -y update && yum clean all ENV MOODLE_VERSION="3.1" \ MOODLE_NODOT_VERSION="stable31"\ From 45036e919c53e0c00a90487882d312dca3ea523f Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Wed, 12 Apr 2017 18:31:30 +0530 Subject: [PATCH 20/23] Fixed typos in moodle readme. --- moodle/centos7/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moodle/centos7/README.md b/moodle/centos7/README.md index 634a4b92..8ebae091 100644 --- a/moodle/centos7/README.md +++ b/moodle/centos7/README.md @@ -29,7 +29,7 @@ You can customize parts of moodle by passing certain values as environment varia 3. DB_NAME - The name of the moodle database in the DB. This assumes the database has already been setup with appropriate users and permissions. 4. DB_USER - The username of the user who has permissions on DB_NAME in DB_HOST. 5. DB_PASSWD - The password of DB_USER. - 6. MOODLE_URL - The URL of moodle endpoint. This should include the the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http:\/\/containerip:8080. **Please ensure you escape any such slashes in your own hostname as it will be internally passed to a `sed` command to update the config.php. Its compulsory to either have http or https preceeding this URL.** + 6. MOODLE_URL - The URL of moodle endpoint. This should include the protocol and port, if any (unless your URL is internally mapped to port 8080 of container as can be done with openshift routes). Default value will be http:\/\/containerip:8080. **Please ensure you escape any such slashes in your own hostname as it will be internally passed to a `sed` command to update the config.php. It is compulsory to either have http or https preceeding this URL.** ### Tracking Updates: From a719455ce419bea1aa7a250c7b9d70be6b9cc09e Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Fri, 21 Apr 2017 13:36:31 +0530 Subject: [PATCH 21/23] Updated to tail log files. --- moodle/centos7/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index 9a713273..0a8802e0 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -33,7 +33,7 @@ if [ $1 == "moodle" ]; then s/localhost/${DB_HOST}/ s/\/home\/example\/moodledata/\/var\/moodledata/" /var/www/html/config-dist.php > /var/www/html/config.php; - exec /usr/sbin/httpd -DFOREGROUND; + /usr/sbin/httpd && tail -f /var/log/httpd/*; else exec $@ fi From 2a8a29f81214161ef09cd65e3ae7240335dd5964 Mon Sep 17 00:00:00 2001 From: mohammedzee1000 Date: Fri, 21 Apr 2017 19:35:28 +0530 Subject: [PATCH 22/23] Updated config to dump logs on stdout and stderr. --- moodle/centos7/install.sh | 2 ++ moodle/centos7/run.sh | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/moodle/centos7/install.sh b/moodle/centos7/install.sh index 581c7785..3f96c0c2 100755 --- a/moodle/centos7/install.sh +++ b/moodle/centos7/install.sh @@ -56,6 +56,8 @@ rm -rf ${HTTPD_WELCOME}; sed -i 's/^Listen 80/Listen 8080\\\nListen 8443/g' ${HTTPD_CONF}; sed -i 's/^Listen 8080\\/Listen 8080/g' ${HTTPD_CONF}; sed -i 's/^Group apache/Group root/g' ${HTTPD_CONF}; +sed -i 's/logs\/error_log/\/dev\/stderr/g' ${HTTPD_CONF}; +sed -i 's/logs\/access_log/\/dev\/stdout/g' ${HTTPD_CONF}; mkdir -p /etc/httpd/logs && touch /etc/httpd/logs/error_log && touch /etc/httpd/logs/access_log; # Fix the permissions diff --git a/moodle/centos7/run.sh b/moodle/centos7/run.sh index 0a8802e0..9a713273 100755 --- a/moodle/centos7/run.sh +++ b/moodle/centos7/run.sh @@ -33,7 +33,7 @@ if [ $1 == "moodle" ]; then s/localhost/${DB_HOST}/ s/\/home\/example\/moodledata/\/var\/moodledata/" /var/www/html/config-dist.php > /var/www/html/config.php; - /usr/sbin/httpd && tail -f /var/log/httpd/*; + exec /usr/sbin/httpd -DFOREGROUND; else exec $@ fi From 18e29724bff61b9acba0e34d74db5a71a288c865 Mon Sep 17 00:00:00 2001 From: Mohammed Zeeshan Ahmed Date: Thu, 5 Jul 2018 15:53:12 +0530 Subject: [PATCH 23/23] Adding 3.5 Dockerfile for moodle container. --- moodle/centos7/Dockerfile.3.5 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 moodle/centos7/Dockerfile.3.5 diff --git a/moodle/centos7/Dockerfile.3.5 b/moodle/centos7/Dockerfile.3.5 new file mode 100644 index 00000000..a06e9b26 --- /dev/null +++ b/moodle/centos7/Dockerfile.3.5 @@ -0,0 +1,25 @@ +FROM registry.centos.org/centos/centos:7 + +MAINTAINER Mohammed Zeeshan Ahmed + +RUN yum -y update && yum clean all + +ENV MOODLE_VERSION="3.5" \ + MOODLE_NODOT_VERSION="stable35"\ + PHP_REMI_VERSION="php73" + +RUN mkdir -p /opt/scripts + +ADD install.sh fix-permissions.sh run.sh passwd.template /opt/scripts/ + +RUN . /opt/scripts/install.sh + +EXPOSE 8080 8443 + +WORKDIR /var/www/html + +USER apache + +ENTRYPOINT ["/opt/scripts/run.sh"] +CMD ["moodle"] +