From 9113611283910e627562ee6c42964cdc2cfa488e Mon Sep 17 00:00:00 2001 From: Valentin Gehrke Date: Thu, 7 Sep 2017 17:43:00 +0200 Subject: [PATCH] Initial commit. --- .gitignore | 1 + db/Dockerfile | 5 ++ db/innodb.cnf | 4 ++ docker-compose.yml.dist | 33 ++++++++++++ webservice/.Dockerfile.swp | Bin 0 -> 12288 bytes webservice/Dockerfile | 93 ++++++++++++++++++++++++++++++++++ webservice/crontab | 5 ++ webservice/nextcloud_php.ini | 8 +++ webservice/supervisord.conf | 13 +++++ webservice/update-htaccess.sh | 6 +++ 10 files changed, 168 insertions(+) create mode 100644 .gitignore create mode 100644 db/Dockerfile create mode 100644 db/innodb.cnf create mode 100644 docker-compose.yml.dist create mode 100644 webservice/.Dockerfile.swp create mode 100644 webservice/Dockerfile create mode 100644 webservice/crontab create mode 100644 webservice/nextcloud_php.ini create mode 100644 webservice/supervisord.conf create mode 100644 webservice/update-htaccess.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1120be9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +docker-compose.yml diff --git a/db/Dockerfile b/db/Dockerfile new file mode 100644 index 0000000..5ed26a0 --- /dev/null +++ b/db/Dockerfile @@ -0,0 +1,5 @@ +FROM mariadb:latest + +ADD innodb.cnf /etc/mysql/mariadb.conf.d/innodb.cnf + + diff --git a/db/innodb.cnf b/db/innodb.cnf new file mode 100644 index 0000000..0d2d032 --- /dev/null +++ b/db/innodb.cnf @@ -0,0 +1,4 @@ +[mysqld] +innodb_large_prefix=true +innodb_file_format=barracuda +innodb_file_per_table=1 diff --git a/docker-compose.yml.dist b/docker-compose.yml.dist new file mode 100644 index 0000000..2d98dba --- /dev/null +++ b/docker-compose.yml.dist @@ -0,0 +1,33 @@ +version: "2" + +services: + webservice: + build: ./webservice + volumes: + - "/nextcloud/config:/var/www/html/config" + - "/nextcloud/data:/var/www/html/data" + ports: + - "8000:80" + networks: + - web + - internal + + db: + build: ./db + volumes: + - "/nextcloud/db:/var/lib/mysql" + environment: + - MYSQL_ROOT_PASSWORD=toor + networks: + - internal + + redis: + image: redis + networks: + - internal + +networks: + web: + external: + name: proxy_web + internal: diff --git a/webservice/.Dockerfile.swp b/webservice/.Dockerfile.swp new file mode 100644 index 0000000000000000000000000000000000000000..30e922df8cd5997e7fb917b245ff38e59acea0da GIT binary patch literal 12288 zcmeI2PiP%Q9LJ~Cs{N}}Jtzp{i&U-d+cXKW7K+v;wZSGSX%Z~0hIza5-cGvzIy?Jb zURwW9(H;cx;?bMp#e-7o$%9w*RPi8!AcEpeLBxxQ-`PKToA;8o*UCKjWZ%yG<~P6j z{(du?kZlYvPEFH;^pI zN?p6d8wrdhqkvJsC}0%01r=Z}A>r+W{JRao1`ufbQ~1JD2roB==HNyx|G9l*gTxF6gH{=5Tg0`CI}&V!R+ z7CZ`Uhom-w_j>D6ro_K^DnV6u1 z?Hk%^(@IozJvX(va_nAf7Es--w78jFHjg8tP_afnrnn(P^oZ+L{8ARWRCm&RZG=#K zWI$~d#J$(m>WayFV|66!b-bt(QfrPv7fY}GQ2B+flZ)=#N6%&>f_9(3%?vTIC9%w^ z>OD6Ig08fe(Z6AE)H<5=^aePo^r;nXX74E#Cx>j?#d`dRx%IWz^Ppm2>-Y1xv?cdB zOL)>#!+PYx%;bynM^DTyOe`%<&YhZ?oq45{D4$)I!r46EYfhJ9FRqJFAl-?y{m5Z{ zmQOU7i5##k5{B0XB`Z>tN~Q!7rXpH6%#+4Oc&KYn@{SaWQy#Xniae`*I7+lpjWorg zESEP$$X!}5YcqG?X73?daB5*bi-)Y?bGUOwLPfw@!a0{^vrLjsLd=nqwLHh%@u>(C z#r#ZntGRx-)!>S)69~mdj~+X5ZJf+{2z?Yo4TxP*&2Z1BI zvFe4P+oITEj>n4v)GZ=Ze&rU`T)E3CB`;QO8@tg`&`r))2ds*?G5}FzGRsO^&`6XN zVXM-#oFG#@zXH3gUAb?$l^Zt-DtC_R#?|nBmzDExB1}F_UuV9pQ^_gjvaF6!p4F6` zYwwmTy!fa~v6zm=RlBb4k?)?y;8k)h{UB5-*5-OQvGh$KPP*NXE= zM~Z2+3zydN`qLS~zzHE$mwL>>L=km_bkd;BLq!{D3*qVWOssO+@r2`PA3CiRz8y}d zS(lCs9~dWOdwKrohlEy;#R}I%CHDUOq{l_~>GNqn(FuZu)#8deILX6a+I3g<>{}~@ ztVKUGdRrDVEH8q2LUKG>C?QiJWnN&6a$78ON)vOW?VT79+%BtM!v z$mn37KG(*qVtWjB$04?P{~B<#Z7_@8*&8&ow$&eJlDbhP>`dXFp1t2*3Y#)H<*u{3 zIEBKh>Z C`((!e literal 0 HcmV?d00001 diff --git a/webservice/Dockerfile b/webservice/Dockerfile new file mode 100644 index 0000000..2c6a7b5 --- /dev/null +++ b/webservice/Dockerfile @@ -0,0 +1,93 @@ +FROM php:apache + +ENV NEXTCLOUD_VERSION 12.0.2 + +RUN \ + apt-get update && \ + apt-get install -y --no-install-recommends \ + supervisor \ + cron \ + sudo \ + libav-tools \ + libldap2-dev \ + libxml2-dev \ + libpng-dev \ + libcurl4-openssl-dev \ + libmagickwand-dev \ + libbz2-dev \ + icu-devtools \ + libicu-dev \ + libmcrypt-dev \ + libfreetype6-dev \ + libssl-dev \ + libjpeg-dev \ + curl \ + cron && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* + +#Dirty hack to circumvent bug in phpize which is open since May 2016 +#Basically the "missing" config.m4 is named "config0.m4" +#This tries to install zlib and if it doesn't work then rename the file and try again" +RUN \ + docker-php-ext-install zlib || \ + ( mv /usr/src/php/ext/zlib/config0.m4 /usr/src/php/ext/zlib/config.m4 && \ + docker-php-ext-install zlib ) + +# See above +RUN \ + docker-php-ext-install openssl || \ + ( mv /usr/src/php/ext/openssl/config0.m4 /usr/src/php/ext/openssl/config.m4 && \ + docker-php-ext-install openssl ) + +RUN \ + docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu && \ + docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ && \ + docker-php-ext-install \ + ldap \ + ctype \ + dom \ + gd \ + iconv \ + json \ + mbstring \ + xmlwriter \ + zip \ + pdo_mysql \ + curl \ + bz2 \ + intl \ + opcache \ + mcrypt && \ + CFLAGS="-I/usr/src/php" docker-php-ext-install xmlreader + +RUN \ + pecl install -o -f redis imagick-beta && \ + rm -rf /tmp/pear && \ + docker-php-ext-enable redis imagick + +# Activate user-defined .htaccess +RUN \ + a2enmod rewrite env + +# Add extra configuration to php.ini +ADD nextcloud_php.ini /usr/local/etc/php/conf.d/nextcloud_php.ini + +RUN \ + curl -o /tmp/nextcloud.tar.bz2 https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2 && \ + tar xvjf /tmp/nextcloud.tar.bz2 -C /tmp && \ + rm -rf /var/www/html && \ + mv /tmp/nextcloud /var/www/html && \ + chown -R www-data:www-data /var/www/html && \ + rm /tmp/nextcloud.tar.bz2 + +# Add supervisor and cron config +ADD crontab /etc/crontab +ADD supervisord.conf /etc/supervisor/conf.d/supervisord.conf +ADD update-htaccess.sh /update-htaccess.sh + +RUN chmod +x /update-htaccess.sh + +VOLUME ["/var/www/html/config","/var/www/html/data"] + +ENTRYPOINT ["supervisord"] diff --git a/webservice/crontab b/webservice/crontab new file mode 100644 index 0000000..2c2e9fb --- /dev/null +++ b/webservice/crontab @@ -0,0 +1,5 @@ +# Running cron.php +SHELL=/bin/sh + +# Run cron.php every 15 minutes +*/15 * * * * cd /var/www/html && sudo -u www-data php ./cron.php diff --git a/webservice/nextcloud_php.ini b/webservice/nextcloud_php.ini new file mode 100644 index 0000000..a1839ee --- /dev/null +++ b/webservice/nextcloud_php.ini @@ -0,0 +1,8 @@ + +opcache.enable=1 +opcache.enable_cli=1 +opcache.interned_strings_buffer=8 +opcache.max_accelerated_files=10000 +opcache.memory_consumption=128 +opcache.save_comments=1 +opcache.revalidate_freq=1 diff --git a/webservice/supervisord.conf b/webservice/supervisord.conf new file mode 100644 index 0000000..bafe395 --- /dev/null +++ b/webservice/supervisord.conf @@ -0,0 +1,13 @@ +[supervisord] +nodaemon=true + +[program:htaccess-update] +command=/update-htaccess.sh +startsecs=0 + +[program:apache] +command=apache2-foreground + +[program:crond] +command = cron -f +startsecs = 5 diff --git a/webservice/update-htaccess.sh b/webservice/update-htaccess.sh new file mode 100644 index 0000000..c8c814c --- /dev/null +++ b/webservice/update-htaccess.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +[ -f "/var/www/html/config/config.php" ] || exit 0 + +cd /var/www/html +sudo -u www-data php occ maintenance:update:htaccess