diff --git a/3.4/arm/Dockerfile b/3.4/arm/Dockerfile index 8b8f65b..12fb67d 100644 --- a/3.4/arm/Dockerfile +++ b/3.4/arm/Dockerfile @@ -1,26 +1,41 @@ -FROM arm32v7/ubuntu +FROM arm32v7/debian:stretch-slim LABEL MAINTAINER "Dashlorde " +LABEL MAINTAINER "Abdurrachman Mappuji " +LABEL MAINTAINER "dogi " ENV version '3.4.0' EXPOSE 80 -ADD ./start.sh /etc/apache2/start.sh +ADD ./start.sh /etc/nginx/ +COPY ./moodle /etc/nginx/sites-available/moodle RUN apt-get update && \ - apt-get -y install wget unzip apache2 php libapache2-mod-php7.0 php-xml php-zip \ - php7.0-pgsql php7.0-curl php7.0-xmlrpc php7.0-gd php7.0-intl php7.0-mysql + apt-get -y install \ + nginx php-fpm php-common \ + php-mbstring php-xmlrpc \ + php-soap php-gd php-xml \ + php-intl php-pgsql php-mysqlnd php-cli \ + php-mcrypt php-ldap php-zip php-curl \ + wget && \ + apt-get -y autoclean && \ + apt-get -y autoremove && \ + rm -rf /var/lib/apt/lists/* -RUN wget -O /var/www/moodle-${version}.tar.gz https://github.com/moodle/moodle/archive/v${version}.tar.gz && \ +RUN mkdir -p /var/www/html && \ + wget -O /var/www/moodle-${version}.tar.gz \ + https://github.com/moodle/moodle/archive/v${version}.tar.gz && \ rm -rf /var/www/html/ && \ cd /var/www && tar xvf moodle-${version}.tar.gz && \ - rm moodle-${version}.tar.gz && \ mv /var/www/moodle-${version} /var/www/html && \ + rm moodle-${version}.tar.gz && \ chown -R www-data:www-data /var/www/html && \ - chmod +x /etc/apache2/start.sh &&\ + chmod +x /etc/nginx/start.sh && \ mkdir -p /var/www/moodledata && chmod 777 /var/www/moodledata && \ - chown -R www-data:www-data /var/www/moodledata + chown -R www-data:www-data /var/www/moodledata && \ + ln -s /etc/nginx/sites-available/moodle /etc/nginx/sites-enabled/ && \ + unlink /etc/nginx/sites-enabled/default -COPY ./config.php /var/www/html/ +ADD ./config.php /var/www/html/ -CMD ["/etc/apache2/start.sh"] +CMD ["/etc/nginx/start.sh"] diff --git a/3.4/arm/build.sh b/3.4/arm/build.sh index a193eda..4376679 100644 --- a/3.4/arm/build.sh +++ b/3.4/arm/build.sh @@ -1 +1 @@ -docker build . -t treehouses/moodle:rpi-pgsql +docker build . -t treehouses/moodle:rpi-latest diff --git a/3.4/arm/docker-compose-ready.yml b/3.4/arm/docker-compose-ready.yml index ea4d850..007306b 100644 --- a/3.4/arm/docker-compose-ready.yml +++ b/3.4/arm/docker-compose-ready.yml @@ -13,13 +13,11 @@ services: container_name: moodle_rpi ports: - "80:80" - volumes: - - /home/pi/apache2:/var/run/apache2 environment: - MOODOLE_DB_URL=moodledb_rpi - MOODOLE_DB_NAME=moodle - MOODOLE_DB_USER=moodle - MOODOLE_DB_PASS=moodle - MOODOLE_DB_PORT=5432 - - MOODOLE_POST_MAX_SIZE=200M - - MOODOLE_UPLOAD_MAX_FILESIZE=200M + - MOODOLE_MAX_BODY_SIZE=200M + - MOODOLE_BODY_TIMEOUT=300s diff --git a/3.4/arm/docker-compose.yml b/3.4/arm/docker-compose.yml index 3988c81..37f5ffa 100644 --- a/3.4/arm/docker-compose.yml +++ b/3.4/arm/docker-compose.yml @@ -13,13 +13,11 @@ services: container_name: moodle_rpi ports: - "80:80" - volumes: - - /home/pi/apache2:/var/run/apache2 environment: - MOODOLE_DB_URL=moodledb_rpi - MOODOLE_DB_NAME=moodle - MOODOLE_DB_USER=moodle - MOODOLE_DB_PASS=moodle - MOODOLE_DB_PORT=5432 - - MOODOLE_POST_MAX_SIZE=200M - - MOODOLE_UPLOAD_MAX_FILESIZE=200M + - MOODOLE_MAX_BODY_SIZE=200M + - MOODOLE_BODY_TIMEOUT=300s diff --git a/3.4/arm/moodle b/3.4/arm/moodle new file mode 100644 index 0000000..6441300 --- /dev/null +++ b/3.4/arm/moodle @@ -0,0 +1,28 @@ +server { + listen 80; + listen [::]:80; + root /var/www/html; + index index.php index.html index.htm; + server_name _; + client_max_body_size 200M; + client_body_timeout 300s; + + location / { + try_files $uri $uri/ =404; + } + + location /dataroot/ { + internal; + alias /var/www/html/moodledata/; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; + include fastcgi_params; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + +} diff --git a/3.4/arm/start.sh b/3.4/arm/start.sh index 0dbf7ee..a276f55 100644 --- a/3.4/arm/start.sh +++ b/3.4/arm/start.sh @@ -1,15 +1,50 @@ #!bin/bash -source /etc/apache2/envvars +# populate environment first -if [ ! -z "${MOODOLE_POST_MAX_SIZE}" ] +# /etc/nginx/sites-available/moodle +NGINX_CONFIG="/etc/nginx/sites-available/moodle" + +if [ ! -z "${MOODOLE_MAX_BODY_SIZE}" ] +then + sed -i '/client_max_body_size/c\\tclient_max_body_size '$MOODOLE_MAX_BODY_SIZE';' $NGINX_CONFIG +fi + +if [ ! -z "${MOODOLE_BODY_TIMEOUT}" ] +then + sed -i '/client_body_timeout/c\\tclient_body_timeout '$MOODOLE_BODY_TIMEOUT';' $NGINX_CONFIG +fi + +# /etc/php/7.0/fpm/php-fpm.conf +PHP_FM_CONFIG="/etc/php/7.0/fpm/php-fpm.conf" +echo "[www]" >> $PHP_FM_CONFIG + +if [ ! -z "${MOODOLE_DB_URL}" ] +then + echo "env[MOODOLE_DB_URL] = '$MOODOLE_DB_URL'" >> $PHP_FM_CONFIG +fi + +if [ ! -z "${MOODOLE_DB_NAME}" ] +then + echo "env[MOODOLE_DB_NAME] = '$MOODOLE_DB_NAME'" >> $PHP_FM_CONFIG +fi + +if [ ! -z "${MOODOLE_DB_USER}" ] then - sed -i '/post_max_size/c\post_max_size = '$MOODOLE_POST_MAX_SIZE /etc/php/7.0/apache2/php.ini + echo "env[MOODOLE_DB_USER] = '$MOODOLE_DB_USER'" >> $PHP_FM_CONFIG fi -if [ ! -z "${MOODOLE_UPLOAD_MAX_FILESIZE}" ] +if [ ! -z "${MOODOLE_DB_PASS}" ] then - sed -i '/upload_max_filesize/c\upload_max_filesize = '$MOODOLE_UPLOAD_MAX_FILESIZE /etc/php/7.0/apache2/php.ini + echo "env[MOODOLE_DB_PASS] = '$MOODOLE_DB_PASS'" >> $PHP_FM_CONFIG fi -exec apache2 -D FOREGROUND +if [ ! -z "${MOODOLE_DB_PORT}" ] +then + echo "env[MOODOLE_DB_PORT] = '$MOODOLE_DB_PORT'" >> $PHP_FM_CONFIG +fi + +service php7.0-fpm start +service nginx start + +tail -f /var/log/nginx/access.log diff --git a/3.4/x86/Dockerfile b/3.4/x86/Dockerfile index c0b7017..016d88b 100644 --- a/3.4/x86/Dockerfile +++ b/3.4/x86/Dockerfile @@ -1,26 +1,41 @@ -FROM i386/ubuntu:16.04 +FROM debian:stretch-slim LABEL MAINTAINER "Dashlorde " +LABEL MAINTAINER "Abdurrachman Mappuji " +LABEL MAINTAINER "dogi " ENV version '3.4.0' EXPOSE 80 -ADD ./start.sh /etc/apache2/start.sh +ADD ./start.sh /etc/nginx/ +COPY ./moodle /etc/nginx/sites-available/moodle RUN apt-get update && \ - apt-get -y install wget unzip apache2 php libapache2-mod-php7.0 php-xml php-zip \ - php7.0-mysql php7.0-curl php7.0-xmlrpc php7.0-gd php7.0-intl php7.0-pgsql + apt-get -y install \ + nginx php-fpm php-common \ + php-mbstring php-xmlrpc \ + php-soap php-gd php-xml \ + php-intl php-pgsql php-mysqlnd php-cli \ + php-mcrypt php-ldap php-zip php-curl \ + wget && \ + apt-get -y autoclean && \ + apt-get -y autoremove && \ + rm -rf /var/lib/apt/lists/* -RUN wget -O /var/www/moodle-${version}.tar.gz https://github.com/moodle/moodle/archive/v${version}.tar.gz && \ +RUN mkdir -p /var/www/html && \ + wget -O /var/www/moodle-${version}.tar.gz \ + https://github.com/moodle/moodle/archive/v${version}.tar.gz && \ rm -rf /var/www/html/ && \ cd /var/www && tar xvf moodle-${version}.tar.gz && \ mv /var/www/moodle-${version} /var/www/html && \ rm moodle-${version}.tar.gz && \ chown -R www-data:www-data /var/www/html && \ - chmod +x /etc/apache2/start.sh && \ + chmod +x /etc/nginx/start.sh && \ mkdir -p /var/www/moodledata && chmod 777 /var/www/moodledata && \ - chown -R www-data:www-data /var/www/moodledata + chown -R www-data:www-data /var/www/moodledata && \ + ln -s /etc/nginx/sites-available/moodle /etc/nginx/sites-enabled/ && \ + unlink /etc/nginx/sites-enabled/default -COPY ./config.php /var/www/html/ +ADD ./config.php /var/www/html/ -CMD ["/etc/apache2/start.sh"] +CMD ["/etc/nginx/start.sh"] diff --git a/3.4/x86/build.sh b/3.4/x86/build.sh index 3b22406..97f0213 100644 --- a/3.4/x86/build.sh +++ b/3.4/x86/build.sh @@ -1 +1 @@ -docker build . -t treehouses/moodle:x86-pgsql +docker build . -t treehouses/moodle:latest diff --git a/3.4/x86/docker-compose-ready.yml b/3.4/x86/docker-compose-ready.yml index f9e9725..fd1770c 100644 --- a/3.4/x86/docker-compose-ready.yml +++ b/3.4/x86/docker-compose-ready.yml @@ -13,13 +13,11 @@ services: container_name: moodle ports: - "80:80" - volumes: - - /home/pi/apache2:/var/run/apache2 environment: - MOODOLE_DB_URL=moodledb - MOODOLE_DB_NAME=moodle - MOODOLE_DB_USER=moodle - MOODOLE_DB_PASS=moodle - MOODOLE_DB_PORT=5432 - - MOODOLE_POST_MAX_SIZE=200M - - MOODOLE_UPLOAD_MAX_FILESIZE=200M + - MOODOLE_MAX_BODY_SIZE=200M + - MOODOLE_BODY_TIMEOUT=300s diff --git a/3.4/x86/docker-compose.yml b/3.4/x86/docker-compose.yml index 13772bb..9f1695d 100644 --- a/3.4/x86/docker-compose.yml +++ b/3.4/x86/docker-compose.yml @@ -13,13 +13,11 @@ services: container_name: moodle ports: - "80:80" - volumes: - - /home/pi/apache2:/var/run/apache2 environment: - MOODOLE_DB_URL=moodledb - MOODOLE_DB_NAME=moodle - MOODOLE_DB_USER=moodle - MOODOLE_DB_PASS=moodle - MOODOLE_DB_PORT=5432 - - MOODOLE_POST_MAX_SIZE=200M - - MOODOLE_UPLOAD_MAX_FILESIZE=200M + - MOODOLE_MAX_BODY_SIZE=200M + - MOODOLE_BODY_TIMEOUT=300s diff --git a/3.4/x86/moodle b/3.4/x86/moodle new file mode 100644 index 0000000..6441300 --- /dev/null +++ b/3.4/x86/moodle @@ -0,0 +1,28 @@ +server { + listen 80; + listen [::]:80; + root /var/www/html; + index index.php index.html index.htm; + server_name _; + client_max_body_size 200M; + client_body_timeout 300s; + + location / { + try_files $uri $uri/ =404; + } + + location /dataroot/ { + internal; + alias /var/www/html/moodledata/; + } + + location ~ [^/]\.php(/|$) { + fastcgi_split_path_info ^(.+\.php)(/.+)$; + fastcgi_index index.php; + fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; + include fastcgi_params; + fastcgi_param PATH_INFO $fastcgi_path_info; + fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; + } + +} diff --git a/3.4/x86/start.sh b/3.4/x86/start.sh index 0dbf7ee..a276f55 100644 --- a/3.4/x86/start.sh +++ b/3.4/x86/start.sh @@ -1,15 +1,50 @@ #!bin/bash -source /etc/apache2/envvars +# populate environment first -if [ ! -z "${MOODOLE_POST_MAX_SIZE}" ] +# /etc/nginx/sites-available/moodle +NGINX_CONFIG="/etc/nginx/sites-available/moodle" + +if [ ! -z "${MOODOLE_MAX_BODY_SIZE}" ] +then + sed -i '/client_max_body_size/c\\tclient_max_body_size '$MOODOLE_MAX_BODY_SIZE';' $NGINX_CONFIG +fi + +if [ ! -z "${MOODOLE_BODY_TIMEOUT}" ] +then + sed -i '/client_body_timeout/c\\tclient_body_timeout '$MOODOLE_BODY_TIMEOUT';' $NGINX_CONFIG +fi + +# /etc/php/7.0/fpm/php-fpm.conf +PHP_FM_CONFIG="/etc/php/7.0/fpm/php-fpm.conf" +echo "[www]" >> $PHP_FM_CONFIG + +if [ ! -z "${MOODOLE_DB_URL}" ] +then + echo "env[MOODOLE_DB_URL] = '$MOODOLE_DB_URL'" >> $PHP_FM_CONFIG +fi + +if [ ! -z "${MOODOLE_DB_NAME}" ] +then + echo "env[MOODOLE_DB_NAME] = '$MOODOLE_DB_NAME'" >> $PHP_FM_CONFIG +fi + +if [ ! -z "${MOODOLE_DB_USER}" ] then - sed -i '/post_max_size/c\post_max_size = '$MOODOLE_POST_MAX_SIZE /etc/php/7.0/apache2/php.ini + echo "env[MOODOLE_DB_USER] = '$MOODOLE_DB_USER'" >> $PHP_FM_CONFIG fi -if [ ! -z "${MOODOLE_UPLOAD_MAX_FILESIZE}" ] +if [ ! -z "${MOODOLE_DB_PASS}" ] then - sed -i '/upload_max_filesize/c\upload_max_filesize = '$MOODOLE_UPLOAD_MAX_FILESIZE /etc/php/7.0/apache2/php.ini + echo "env[MOODOLE_DB_PASS] = '$MOODOLE_DB_PASS'" >> $PHP_FM_CONFIG fi -exec apache2 -D FOREGROUND +if [ ! -z "${MOODOLE_DB_PORT}" ] +then + echo "env[MOODOLE_DB_PORT] = '$MOODOLE_DB_PORT'" >> $PHP_FM_CONFIG +fi + +service php7.0-fpm start +service nginx start + +tail -f /var/log/nginx/access.log diff --git a/README.md b/README.md index b9a4f41..620ddf1 100644 --- a/README.md +++ b/README.md @@ -23,20 +23,18 @@ services: - POSTGRES_USER=moodle - POSTGRES_PASSWORD=moodle moodle: - image: treehouses/moodle:latest + build: . container_name: moodle ports: - "80:80" - volumes: - - /home/pi/apache2:/var/run/apache2 environment: - MOODOLE_DB_URL=moodledb - MOODOLE_DB_NAME=moodle - MOODOLE_DB_USER=moodle - MOODOLE_DB_PASS=moodle - MOODOLE_DB_PORT=5432 - - MOODOLE_POST_MAX_SIZE=200M - - MOODOLE_UPLOAD_MAX_FILESIZE=200M + - MOODOLE_MAX_BODY_SIZE=300M + - MOODOLE_BODY_TIMEOUT=700s ``` --- @@ -58,14 +56,13 @@ services: container_name: moodle_rpi ports: - "80:80" - volumes: - - /home/pi/apache2:/var/run/apache2 environment: - MOODOLE_DB_URL=moodledb_rpi - MOODOLE_DB_NAME=moodle - MOODOLE_DB_USER=moodle - MOODOLE_DB_PASS=moodle - MOODOLE_DB_PORT=5432 - - MOODOLE_POST_MAX_SIZE=200M - - MOODOLE_UPLOAD_MAX_FILESIZE=200M + - MOODOLE_MAX_BODY_SIZE=200M + - MOODOLE_BODY_TIMEOUT=300s + ``` diff --git a/package.json b/package.json index 394cc4c..a84ca8a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "moodole", - "version": "0.0.1", + "version": "0.0.2", "description": "Moodle Docker for x86 and Raspberry Pi", "scripts": { "test": "echo \"Error: no test specified\" && exit 1"