diff --git a/.config/redis.config.php b/.config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/.config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/.examples/README.md b/.examples/README.md index d2183447..476832a9 100644 --- a/.examples/README.md +++ b/.examples/README.md @@ -21,48 +21,46 @@ Example | Description ### full The `full` Dockerfile example adds dependencies for all optional packages suggested by nextcloud that may be needed for some features (e.g. Video Preview Generation), as stated in the [Administration Manual](https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html). -NOTE: The Dockerfile does not install the LibreOffice package (line is commented), because it would increase the generated Image size by approximately 500 MB. In order to install it, simply uncomment the 13th line of the Dockerfile. +NOTE: The Dockerfile does not install the LibreOffice package (line is commented), because it would increase the generated Image size by approximately 500 MB. In order to install it, simply uncomment the appropriate line in the Dockerfile. -NOTE: Per default, only previews for BMP, GIF, JPEG, MarkDown, MP3, PNG, TXT, and XBitmap Files are generated. The configuration of the preview generation can be done in config.php, as explained in the [Administration Manual](https://docs.nextcloud.com/server/12/admin_manual/configuration_server/config_sample_php_parameters.html#previews) +NOTE: Per default, only previews for BMP, GIF, JPEG, MarkDown, MP3, PNG, TXT, and XBitmap Files are generated. The configuration of the preview generation can be done in config.php, as explained in the [Administration Manual](https://docs.nextcloud.com/server/12/admin_manual/configuration_server/config_sample_php_parameters.html#previews) -NOTE: Nextcloud recommends [disabling preview generation](https://docs.nextcloud.com/server/12/admin_manual/configuration_server/harden_server.html?highlight=enabledpreviewproviders#disable-preview-image-generation) for high security deployments, as preview generation opens your nextcloud instance to new possible attack vectors. +NOTE: Nextcloud recommends [disabling preview generation](https://docs.nextcloud.com/server/12/admin_manual/configuration_server/harden_server.html?highlight=enabledpreviewproviders#disable-preview-image-generation) for high security deployments, as preview generation opens your nextcloud instance to new possible attack vectors. -The required steps for each optional/recommended package that is not already in the Nextcloud image are listed here, so that the Dockerfile can easily be modified to only install the needed extra packages. Simply remove the steps for the unwanted packages from the Dockerfile. +The required steps for each optional/recommended package that is not already in the Nextcloud image are listed here, so that the Dockerfile can easily be modified to only install the needed extra packages. Simply remove the steps for the unwanted packages from the Dockerfile. #### PHP Module bz2 -`docker-php-ext-install bz2` - -#### PHP Module imagick -`apt install libmagickwand-dev` -`pecl install imagick` -`docker-php-ext-enable imagick` +`docker-php-ext-install bz2` #### PHP Module imap -`apt install libc-client-dev libkrb5-dev` -`docker-php-ext-configure imap --with-kerberos --with-imap-ssl` -`docker-php-ext-install imap` +`apt install libc-client-dev libkrb5-dev` +`docker-php-ext-configure imap --with-kerberos --with-imap-ssl` +`docker-php-ext-install imap` #### PHP Module gmp -`apt install libgmp3-dev` -`docker-php-ext-install gmp` +`apt install libgmp3-dev` +`docker-php-ext-install gmp` #### PHP Module smbclient -`apt install smbclient libsmbclient-dev` -`pecl install smbclient` -`docker-php-ext-enable smbclient` +`apt install smbclient libsmbclient-dev` +`pecl install smbclient` +`docker-php-ext-enable smbclient` #### ffmpeg -`apt install ffmpeg` +`apt install ffmpeg` + +#### imagemagick SVG support +`apt install libmagickcore-6.q16-3-extra` #### LibreOffice -`apt install libreoffice` +`apt install libreoffice` #### CRON via supervisor -`apt install supervisor` -`mkdir /var/log/supervisord /var/run/supervisord` -The following Dockerfile commands are also necessary for a sucessfull cron installation: -`COPY supervisord.conf /etc/supervisor/supervisord.conf` -`CMD ["/usr/bin/supervisord"]` +`apt install supervisor` +`mkdir /var/log/supervisord /var/run/supervisord` +The following Dockerfile commands are also necessary for a sucessfull cron installation: +`COPY supervisord.conf /etc/supervisor/supervisord.conf` +`CMD ["/usr/bin/supervisord"]` diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile deleted file mode 100644 index b55fb524..00000000 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM nextcloud:apache - -COPY redis.config.php /usr/src/nextcloud/config/redis.config.php diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/redis.config.php b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/redis.config.php deleted file mode 100644 index b0cebe31..00000000 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/app/redis.config.php +++ /dev/null @@ -1,8 +0,0 @@ - '\OC\Memcache\Redis', - 'redis' => array( - 'host' => 'redis', - 'port' => 6379, - ), -); diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml index 64c0570f..600c609f 100644 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/apache/docker-compose.yml @@ -17,7 +17,7 @@ services: restart: always app: - build: ./app + image: nextcloud:apache restart: always ports: - 8080:80 @@ -25,6 +25,7 @@ services: - nextcloud:/var/www/html environment: - MYSQL_HOST=db + - REDIS_HOST=redis env_file: - db.env depends_on: @@ -32,7 +33,7 @@ services: - redis cron: - build: ./app + image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/Dockerfile b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/Dockerfile deleted file mode 100644 index 0436d37d..00000000 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM nextcloud:fpm-alpine - -COPY redis.config.php /usr/src/nextcloud/config/redis.config.php diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/redis.config.php b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/redis.config.php deleted file mode 100644 index b0cebe31..00000000 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/app/redis.config.php +++ /dev/null @@ -1,8 +0,0 @@ - '\OC\Memcache\Redis', - 'redis' => array( - 'host' => 'redis', - 'port' => 6379, - ), -); diff --git a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml index 424ef057..5ac5b3b1 100644 --- a/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml +++ b/.examples/docker-compose/insecure/mariadb-cron-redis/fpm/docker-compose.yml @@ -17,12 +17,13 @@ services: restart: always app: - build: ./app + image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html environment: - MYSQL_HOST=db + - REDIS_HOST=redis env_file: - db.env depends_on: @@ -40,7 +41,7 @@ services: - app cron: - build: ./app + image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html diff --git a/.examples/docker-compose/with-nginx-proxy-self-signed-ssl/mariadb/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy-self-signed-ssl/mariadb/fpm/web/nginx.conf index 26660646..eca9db99 100644 --- a/.examples/docker-compose/with-nginx-proxy-self-signed-ssl/mariadb/fpm/web/nginx.conf +++ b/.examples/docker-compose/with-nginx-proxy-self-signed-ssl/mariadb/fpm/web/nginx.conf @@ -125,7 +125,7 @@ http { # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff|svg|gif)$ { + location ~ \.(?:css|js|woff2?|svg|gif)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; # Add headers to serve security related headers (It is intended to diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/Dockerfile deleted file mode 100644 index b55fb524..00000000 --- a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM nextcloud:apache - -COPY redis.config.php /usr/src/nextcloud/config/redis.config.php diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/redis.config.php b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/redis.config.php deleted file mode 100644 index b0cebe31..00000000 --- a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/app/redis.config.php +++ /dev/null @@ -1,8 +0,0 @@ - '\OC\Memcache\Redis', - 'redis' => array( - 'host' => 'redis', - 'port' => 6379, - ), -); diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml index aaec5a2e..39ab2bef 100644 --- a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/apache/docker-compose.yml @@ -17,7 +17,7 @@ services: restart: always app: - build: ./app + image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html @@ -26,6 +26,7 @@ services: - LETSENCRYPT_HOST= - LETSENCRYPT_EMAIL= - MYSQL_HOST=db + - REDIS_HOST=redis env_file: - db.env depends_on: @@ -36,7 +37,7 @@ services: - default cron: - build: ./app + image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/app/Dockerfile b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/app/Dockerfile deleted file mode 100644 index 0436d37d..00000000 --- a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/app/Dockerfile +++ /dev/null @@ -1,3 +0,0 @@ -FROM nextcloud:fpm-alpine - -COPY redis.config.php /usr/src/nextcloud/config/redis.config.php diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/app/redis.config.php b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/app/redis.config.php deleted file mode 100644 index b0cebe31..00000000 --- a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/app/redis.config.php +++ /dev/null @@ -1,8 +0,0 @@ - '\OC\Memcache\Redis', - 'redis' => array( - 'host' => 'redis', - 'port' => 6379, - ), -); diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml index 30aee4d9..d5763620 100644 --- a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/docker-compose.yml @@ -17,12 +17,13 @@ services: restart: always app: - build: ./app + image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html environment: - MYSQL_HOST=db + - REDIS_HOST=redis env_file: - db.env depends_on: @@ -45,7 +46,7 @@ services: - default cron: - build: ./app + image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/web/nginx.conf index 26660646..eca9db99 100644 --- a/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/web/nginx.conf +++ b/.examples/docker-compose/with-nginx-proxy/mariadb-cron-redis/fpm/web/nginx.conf @@ -125,7 +125,7 @@ http { # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff|svg|gif)$ { + location ~ \.(?:css|js|woff2?|svg|gif)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; # Add headers to serve security related headers (It is intended to diff --git a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf index 26660646..eca9db99 100644 --- a/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf +++ b/.examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf @@ -125,7 +125,7 @@ http { # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff|svg|gif)$ { + location ~ \.(?:css|js|woff2?|svg|gif)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; # Add headers to serve security related headers (It is intended to diff --git a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf index 26660646..eca9db99 100644 --- a/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf +++ b/.examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf @@ -125,7 +125,7 @@ http { # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block - location ~ \.(?:css|js|woff|svg|gif)$ { + location ~ \.(?:css|js|woff2?|svg|gif)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; # Add headers to serve security related headers (It is intended to diff --git a/.examples/dockerfiles/cron/fpm-alpine/Dockerfile b/.examples/dockerfiles/cron/fpm-alpine/Dockerfile new file mode 100644 index 00000000..820b3f9a --- /dev/null +++ b/.examples/dockerfiles/cron/fpm-alpine/Dockerfile @@ -0,0 +1,10 @@ +FROM nextcloud:fpm-alpine + +RUN apk add --no-cache supervisor \ + && mkdir /var/log/supervisord /var/run/supervisord + +COPY supervisord.conf /etc/supervisor/supervisord.conf + +ENV NEXTCLOUD_UPDATE=1 + +CMD ["/usr/bin/supervisord"] diff --git a/.examples/dockerfiles/cron/fpm-alpine/supervisord.conf b/.examples/dockerfiles/cron/fpm-alpine/supervisord.conf new file mode 100644 index 00000000..4f762592 --- /dev/null +++ b/.examples/dockerfiles/cron/fpm-alpine/supervisord.conf @@ -0,0 +1,22 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisord/supervisord.log +pidfile=/var/run/supervisord/supervisord.pid +childlogdir=/var/log/supervisord/ +logfile_maxbytes=50MB ; maximum size of logfile before rotation +logfile_backups=10 ; number of backed up logfiles +loglevel=error + +[program:php-fpm] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=php-fpm + +[program:cron] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=/cron.sh diff --git a/.examples/dockerfiles/full/apache/Dockerfile b/.examples/dockerfiles/full/apache/Dockerfile index 5e10ba1a..30ce59ad 100644 --- a/.examples/dockerfiles/full/apache/Dockerfile +++ b/.examples/dockerfiles/full/apache/Dockerfile @@ -1,34 +1,63 @@ -FROM nextcloud:14.0.4-apache +FROM nextcloud:apache -RUN mkdir -p /usr/share/man/man1 \ - && apt-get update && apt-get install -y \ - supervisor \ +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ ffmpeg \ - libmagickwand-dev \ - libgmp3-dev \ - libc-client-dev \ - libkrb5-dev \ + libmagickcore-6.q16-3-extra \ smbclient \ - libsmbclient-dev \ + supervisor \ # libreoffice \ - && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && ln -s "/usr/include/$(dpkg-architecture --query DEB_BUILD_MULTIARCH)/gmp.h" /usr/include/gmp.h \ - && docker-php-ext-install bz2 gmp imap \ - && pecl install imagick smbclient \ - && docker-php-ext-enable imagick smbclient \ -#### BEGIN Blackfire - && version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \ - && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \ - && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp \ - && mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \ - && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \ -#### END Blackfire - && mkdir /var/log/supervisord /var/run/supervisord \ - && echo '*/10 * * * * php -f /var/www/html/occ preview:pre-generate' >> /var/spool/cron/crontabs/www-data + ; \ + rm -rf /var/lib/apt/lists/* + +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libbz2-dev \ + libc-client-dev \ + libgmp3-dev \ + libkrb5-dev \ + libsmbclient-dev \ + ; \ + \ + docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ + ln -s "/usr/include/$(dpkg-architecture --query DEB_BUILD_MULTIARCH)/gmp.h" /usr/include/gmp.h; \ + docker-php-ext-install \ + bz2 \ + gmp \ + imap \ + ; \ + pecl install smbclient; \ + docker-php-ext-enable smbclient; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/*; \ + echo '*/10 * * * * php -f /var/www/html/occ preview:pre-generate' >> /var/spool/cron/crontabs/www-data + +RUN mkdir -p \ + /var/log/supervisord \ + /var/run/supervisord \ +; COPY supervisord.conf /etc/supervisor/supervisord.conf ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord"] + diff --git a/.examples/dockerfiles/full/fpm-alpine/Dockerfile b/.examples/dockerfiles/full/fpm-alpine/Dockerfile new file mode 100644 index 00000000..37029c8e --- /dev/null +++ b/.examples/dockerfiles/full/fpm-alpine/Dockerfile @@ -0,0 +1,52 @@ +FROM nextcloud:fpm-alpine + +RUN set -ex; \ + \ + apk add --no-cache \ + ffmpeg \ + imagemagick \ + samba-client \ + supervisor \ +# libreoffice \ + ; + +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + imap-dev \ + krb5-dev \ + libressl-dev \ + samba-dev \ + bzip2-dev \ + gmp-dev \ + ; \ + \ + docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ + docker-php-ext-install \ + bz2 \ + gmp \ + imap \ + ; \ + pecl install smbclient; \ + docker-php-ext-enable smbclient; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .nextcloud-phpext-rundeps $runDeps; \ + apk del .build-deps + +RUN mkdir -p \ + /var/log/supervisord \ + /var/run/supervisord \ +; + +COPY supervisord.conf /etc/supervisor/supervisord.conf + +ENV NEXTCLOUD_UPDATE=1 + +CMD ["/usr/bin/supervisord"] diff --git a/.examples/dockerfiles/full/fpm-alpine/supervisord.conf b/.examples/dockerfiles/full/fpm-alpine/supervisord.conf new file mode 100644 index 00000000..4f762592 --- /dev/null +++ b/.examples/dockerfiles/full/fpm-alpine/supervisord.conf @@ -0,0 +1,22 @@ +[supervisord] +nodaemon=true +logfile=/var/log/supervisord/supervisord.log +pidfile=/var/run/supervisord/supervisord.pid +childlogdir=/var/log/supervisord/ +logfile_maxbytes=50MB ; maximum size of logfile before rotation +logfile_backups=10 ; number of backed up logfiles +loglevel=error + +[program:php-fpm] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=php-fpm + +[program:cron] +stdout_logfile=/dev/stdout +stdout_logfile_maxbytes=0 +stderr_logfile=/dev/stderr +stderr_logfile_maxbytes=0 +command=/cron.sh diff --git a/.examples/dockerfiles/full/fpm/Dockerfile b/.examples/dockerfiles/full/fpm/Dockerfile index b7311258..5172e3f2 100644 --- a/.examples/dockerfiles/full/fpm/Dockerfile +++ b/.examples/dockerfiles/full/fpm/Dockerfile @@ -1,23 +1,58 @@ FROM nextcloud:fpm -RUN mkdir -p /usr/share/man/man1 \ - && apt-get update && apt-get install -y \ - supervisor \ +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ ffmpeg \ - libmagickwand-dev \ - libgmp3-dev \ - libc-client-dev \ - libkrb5-dev \ + libmagickcore-6.q16-3-extra \ smbclient \ - libsmbclient-dev \ + supervisor \ # libreoffice \ - && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && ln -s "/usr/include/$(dpkg-architecture --query DEB_BUILD_MULTIARCH)/gmp.h" /usr/include/gmp.h \ - && docker-php-ext-install bz2 gmp imap \ - && pecl install imagick smbclient \ - && docker-php-ext-enable imagick smbclient \ - && mkdir /var/log/supervisord /var/run/supervisord + ; \ + rm -rf /var/lib/apt/lists/* + +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libbz2-dev \ + libc-client-dev \ + libgmp3-dev \ + libkrb5-dev \ + libsmbclient-dev \ + ; \ + \ + docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ + ln -s "/usr/include/$(dpkg-architecture --query DEB_BUILD_MULTIARCH)/gmp.h" /usr/include/gmp.h; \ + docker-php-ext-install \ + bz2 \ + gmp \ + imap \ + ; \ + pecl install smbclient; \ + docker-php-ext-enable smbclient; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +RUN mkdir -p \ + /var/log/supervisord \ + /var/run/supervisord \ +; COPY supervisord.conf /etc/supervisor/supervisord.conf diff --git a/.examples/dockerfiles/imap/apache/Dockerfile b/.examples/dockerfiles/imap/apache/Dockerfile index f7958c08..5f24c756 100644 --- a/.examples/dockerfiles/imap/apache/Dockerfile +++ b/.examples/dockerfiles/imap/apache/Dockerfile @@ -1,7 +1,28 @@ FROM nextcloud:apache -RUN apt-get update \ - && apt-get install -y libc-client-dev libkrb5-dev \ - && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && docker-php-ext-install imap +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libc-client-dev \ + libkrb5-dev \ + ; \ + \ + docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ + docker-php-ext-install imap; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* diff --git a/.examples/dockerfiles/imap/fpm-alpine/Dockerfile b/.examples/dockerfiles/imap/fpm-alpine/Dockerfile new file mode 100644 index 00000000..289c2a99 --- /dev/null +++ b/.examples/dockerfiles/imap/fpm-alpine/Dockerfile @@ -0,0 +1,22 @@ +FROM nextcloud:fpm-alpine + +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + imap-dev \ + krb5-dev \ + libressl-dev \ + ; \ + \ + docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ + docker-php-ext-install imap; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .nextcloud-phpext-rundeps $runDeps; \ + apk del .build-deps diff --git a/.examples/dockerfiles/imap/fpm/Dockerfile b/.examples/dockerfiles/imap/fpm/Dockerfile index b403de66..f692fd7a 100644 --- a/.examples/dockerfiles/imap/fpm/Dockerfile +++ b/.examples/dockerfiles/imap/fpm/Dockerfile @@ -1,7 +1,28 @@ FROM nextcloud:fpm -RUN apt-get update \ - && apt-get install -y libc-client-dev libkrb5-dev \ - && rm -rf /var/lib/apt/lists/* \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ - && docker-php-ext-install imap +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libc-client-dev \ + libkrb5-dev \ + ; \ + \ + docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ + docker-php-ext-install imap; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* diff --git a/.examples/dockerfiles/smb/fpm-alpine/Dockerfile b/.examples/dockerfiles/smb/fpm-alpine/Dockerfile new file mode 100644 index 00000000..a66cd93a --- /dev/null +++ b/.examples/dockerfiles/smb/fpm-alpine/Dockerfile @@ -0,0 +1,3 @@ +FROM nextcloud:fpm-alpine + +RUN apk add --no-cache samba-client diff --git a/.travis.yml b/.travis.yml index 6e36fdcd..c7bdc606 100644 --- a/.travis.yml +++ b/.travis.yml @@ -50,7 +50,25 @@ jobs: - ./generate-stackbrew-library.sh - stage: test images - env: VERSION=13.0 VARIANT=fpm-alpine ARCH=amd64 + env: VERSION=13.0-rc VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=13.0-rc VARIANT=fpm-alpine ARCH=i386 + - env: VERSION=13.0-rc VARIANT=fpm ARCH=amd64 + - env: VERSION=13.0-rc VARIANT=fpm ARCH=i386 + - env: VERSION=13.0-rc VARIANT=apache ARCH=amd64 + - env: VERSION=13.0-rc VARIANT=apache ARCH=i386 + - env: VERSION=14.0-rc VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=14.0-rc VARIANT=fpm-alpine ARCH=i386 + - env: VERSION=14.0-rc VARIANT=fpm ARCH=amd64 + - env: VERSION=14.0-rc VARIANT=fpm ARCH=i386 + - env: VERSION=14.0-rc VARIANT=apache ARCH=amd64 + - env: VERSION=14.0-rc VARIANT=apache ARCH=i386 + - env: VERSION=15.0-rc VARIANT=fpm-alpine ARCH=amd64 + - env: VERSION=15.0-rc VARIANT=fpm-alpine ARCH=i386 + - env: VERSION=15.0-rc VARIANT=fpm ARCH=amd64 + - env: VERSION=15.0-rc VARIANT=fpm ARCH=i386 + - env: VERSION=15.0-rc VARIANT=apache ARCH=amd64 + - env: VERSION=15.0-rc VARIANT=apache ARCH=i386 + - env: VERSION=13.0 VARIANT=fpm-alpine ARCH=amd64 - env: VERSION=13.0 VARIANT=fpm-alpine ARCH=i386 - env: VERSION=13.0 VARIANT=fpm ARCH=amd64 - env: VERSION=13.0 VARIANT=fpm ARCH=i386 diff --git a/13.0-rc/apache/Dockerfile b/13.0-rc/apache/Dockerfile new file mode 100644 index 00000000..dd602c64 --- /dev/null +++ b/13.0-rc/apache/Dockerfile @@ -0,0 +1,146 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template +FROM php:7.2-apache-stretch + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev \ + libevent-dev \ + libfreetype6-dev \ + libicu-dev \ + libjpeg-dev \ + libldap2-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libpq-dev \ + libxml2-dev \ + libmagickwand-dev \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +RUN a2enmod rewrite remoteip ;\ + {\ + echo RemoteIPHeader X-Real-IP ;\ + echo RemoteIPTrustedProxy 10.0.0.0/8 ;\ + echo RemoteIPTrustedProxy 172.16.0.0/12 ;\ + echo RemoteIPTrustedProxy 192.168.0.0/16 ;\ + } > /etc/apache2/conf-available/remoteip.conf;\ + a2enconf remoteip + +ENV NEXTCLOUD_VERSION 13.0.12RC1 + +RUN set -ex; \ + fetchDeps=" \ + gnupg \ + dirmngr \ + "; \ + apt-get update; \ + apt-get install -y --no-install-recommends $fetchDeps; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ + rm -rf /var/lib/apt/lists/* + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["apache2-foreground"] diff --git a/13.0-rc/apache/config/apache-pretty-urls.config.php b/13.0-rc/apache/config/apache-pretty-urls.config.php new file mode 100644 index 00000000..72da1d8c --- /dev/null +++ b/13.0-rc/apache/config/apache-pretty-urls.config.php @@ -0,0 +1,4 @@ + '/', +); diff --git a/13.0-rc/apache/config/apcu.config.php b/13.0-rc/apache/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/13.0-rc/apache/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/13.0-rc/apache/config/apps.config.php b/13.0-rc/apache/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/13.0-rc/apache/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/13.0-rc/apache/config/autoconfig.php b/13.0-rc/apache/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/13.0-rc/apache/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/13.0-rc/apache/cron.sh b/13.0-rc/apache/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/13.0-rc/apache/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/13.0-rc/apache/entrypoint.sh b/13.0-rc/apache/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/13.0-rc/apache/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/13.0-rc/apache/upgrade.exclude b/13.0-rc/apache/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/13.0-rc/apache/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/13.0-rc/fpm-alpine/Dockerfile b/13.0-rc/fpm-alpine/Dockerfile new file mode 100644 index 00000000..989f7fb9 --- /dev/null +++ b/13.0-rc/fpm-alpine/Dockerfile @@ -0,0 +1,123 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template +FROM php:7.2-fpm-alpine3.9 + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apk add --no-cache \ + rsync \ + ; \ + \ + rm /var/spool/cron/crontabs/root; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + autoconf \ + freetype-dev \ + icu-dev \ + libevent-dev \ + libjpeg-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + libmemcached-dev \ + libxml2-dev \ + openldap-dev \ + pcre-dev \ + postgresql-dev \ + imagemagick-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .nextcloud-phpext-rundeps $runDeps; \ + apk del .build-deps + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + + +ENV NEXTCLOUD_VERSION 13.0.12RC1 + +RUN set -ex; \ + apk add --no-cache --virtual .fetch-deps \ + bzip2 \ + gnupg \ + ; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + apk del .fetch-deps + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] diff --git a/13.0-rc/fpm-alpine/config/apcu.config.php b/13.0-rc/fpm-alpine/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/13.0-rc/fpm-alpine/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/13.0-rc/fpm-alpine/config/apps.config.php b/13.0-rc/fpm-alpine/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/13.0-rc/fpm-alpine/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/13.0-rc/fpm-alpine/config/autoconfig.php b/13.0-rc/fpm-alpine/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/13.0-rc/fpm-alpine/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/13.0-rc/fpm-alpine/cron.sh b/13.0-rc/fpm-alpine/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/13.0-rc/fpm-alpine/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/13.0-rc/fpm-alpine/entrypoint.sh b/13.0-rc/fpm-alpine/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/13.0-rc/fpm-alpine/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/13.0-rc/fpm-alpine/upgrade.exclude b/13.0-rc/fpm-alpine/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/13.0-rc/fpm-alpine/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/13.0-rc/fpm/Dockerfile b/13.0-rc/fpm/Dockerfile new file mode 100644 index 00000000..17d93c4d --- /dev/null +++ b/13.0-rc/fpm/Dockerfile @@ -0,0 +1,138 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template +FROM php:7.2-fpm-stretch + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev \ + libevent-dev \ + libfreetype6-dev \ + libicu-dev \ + libjpeg-dev \ + libldap2-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libpq-dev \ + libxml2-dev \ + libmagickwand-dev \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + + +ENV NEXTCLOUD_VERSION 13.0.12RC1 + +RUN set -ex; \ + fetchDeps=" \ + gnupg \ + dirmngr \ + "; \ + apt-get update; \ + apt-get install -y --no-install-recommends $fetchDeps; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ + rm -rf /var/lib/apt/lists/* + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] diff --git a/13.0-rc/fpm/config/apcu.config.php b/13.0-rc/fpm/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/13.0-rc/fpm/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/13.0-rc/fpm/config/apps.config.php b/13.0-rc/fpm/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/13.0-rc/fpm/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/13.0-rc/fpm/config/autoconfig.php b/13.0-rc/fpm/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/13.0-rc/fpm/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/13.0-rc/fpm/cron.sh b/13.0-rc/fpm/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/13.0-rc/fpm/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/13.0-rc/fpm/entrypoint.sh b/13.0-rc/fpm/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/13.0-rc/fpm/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/13.0-rc/fpm/upgrade.exclude b/13.0-rc/fpm/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/13.0-rc/fpm/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/13.0/apache/Dockerfile b/13.0/apache/Dockerfile index 2a3ba93e..5f189daf 100644 --- a/13.0/apache/Dockerfile +++ b/13.0/apache/Dockerfile @@ -24,6 +24,7 @@ RUN set -ex; \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ + libevent-dev \ libfreetype6-dev \ libicu-dev \ libjpeg-dev \ @@ -33,6 +34,7 @@ RUN set -ex; \ libpng-dev \ libpq-dev \ libxml2-dev \ + libmagickwand-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ @@ -51,14 +53,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies @@ -106,7 +110,7 @@ RUN a2enmod rewrite remoteip ;\ } > /etc/apache2/conf-available/remoteip.conf;\ a2enconf remoteip -ENV NEXTCLOUD_VERSION 13.0.8 +ENV NEXTCLOUD_VERSION 13.0.11 RUN set -ex; \ fetchDeps=" \ diff --git a/13.0/apache/config/redis.config.php b/13.0/apache/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/13.0/apache/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/13.0/apache/entrypoint.sh b/13.0/apache/entrypoint.sh index 045227e8..07644c04 100755 --- a/13.0/apache/entrypoint.sh +++ b/13.0/apache/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/13.0/fpm-alpine/Dockerfile b/13.0/fpm-alpine/Dockerfile index 9f22e0f2..05ec096a 100644 --- a/13.0/fpm-alpine/Dockerfile +++ b/13.0/fpm-alpine/Dockerfile @@ -1,5 +1,5 @@ # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template -FROM php:7.2-fpm-alpine3.8 +FROM php:7.2-fpm-alpine3.9 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ @@ -20,6 +20,7 @@ RUN set -ex; \ autoconf \ freetype-dev \ icu-dev \ + libevent-dev \ libjpeg-turbo-dev \ libmcrypt-dev \ libpng-dev \ @@ -28,6 +29,7 @@ RUN set -ex; \ openldap-dev \ pcre-dev \ postgresql-dev \ + imagemagick-dev \ ; \ \ docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ @@ -45,14 +47,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ runDeps="$( \ @@ -87,7 +91,7 @@ RUN { \ VOLUME /var/www/html -ENV NEXTCLOUD_VERSION 13.0.8 +ENV NEXTCLOUD_VERSION 13.0.11 RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ diff --git a/13.0/fpm-alpine/config/redis.config.php b/13.0/fpm-alpine/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/13.0/fpm-alpine/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/13.0/fpm-alpine/entrypoint.sh b/13.0/fpm-alpine/entrypoint.sh index 045227e8..07644c04 100755 --- a/13.0/fpm-alpine/entrypoint.sh +++ b/13.0/fpm-alpine/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/13.0/fpm/Dockerfile b/13.0/fpm/Dockerfile index 8ec966da..70623522 100644 --- a/13.0/fpm/Dockerfile +++ b/13.0/fpm/Dockerfile @@ -24,6 +24,7 @@ RUN set -ex; \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ + libevent-dev \ libfreetype6-dev \ libicu-dev \ libjpeg-dev \ @@ -33,6 +34,7 @@ RUN set -ex; \ libpng-dev \ libpq-dev \ libxml2-dev \ + libmagickwand-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ @@ -51,14 +53,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies @@ -98,7 +102,7 @@ RUN { \ VOLUME /var/www/html -ENV NEXTCLOUD_VERSION 13.0.8 +ENV NEXTCLOUD_VERSION 13.0.11 RUN set -ex; \ fetchDeps=" \ diff --git a/13.0/fpm/config/redis.config.php b/13.0/fpm/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/13.0/fpm/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/13.0/fpm/entrypoint.sh b/13.0/fpm/entrypoint.sh index 045227e8..07644c04 100755 --- a/13.0/fpm/entrypoint.sh +++ b/13.0/fpm/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/14.0-rc/apache/Dockerfile b/14.0-rc/apache/Dockerfile new file mode 100644 index 00000000..41ea6879 --- /dev/null +++ b/14.0-rc/apache/Dockerfile @@ -0,0 +1,146 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template +FROM php:7.2-apache-stretch + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev \ + libevent-dev \ + libfreetype6-dev \ + libicu-dev \ + libjpeg-dev \ + libldap2-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libpq-dev \ + libxml2-dev \ + libmagickwand-dev \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +RUN a2enmod rewrite remoteip ;\ + {\ + echo RemoteIPHeader X-Real-IP ;\ + echo RemoteIPTrustedProxy 10.0.0.0/8 ;\ + echo RemoteIPTrustedProxy 172.16.0.0/12 ;\ + echo RemoteIPTrustedProxy 192.168.0.0/16 ;\ + } > /etc/apache2/conf-available/remoteip.conf;\ + a2enconf remoteip + +ENV NEXTCLOUD_VERSION 14.0.8RC2 + +RUN set -ex; \ + fetchDeps=" \ + gnupg \ + dirmngr \ + "; \ + apt-get update; \ + apt-get install -y --no-install-recommends $fetchDeps; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ + rm -rf /var/lib/apt/lists/* + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["apache2-foreground"] diff --git a/14.0-rc/apache/config/apache-pretty-urls.config.php b/14.0-rc/apache/config/apache-pretty-urls.config.php new file mode 100644 index 00000000..72da1d8c --- /dev/null +++ b/14.0-rc/apache/config/apache-pretty-urls.config.php @@ -0,0 +1,4 @@ + '/', +); diff --git a/14.0-rc/apache/config/apcu.config.php b/14.0-rc/apache/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/14.0-rc/apache/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/14.0-rc/apache/config/apps.config.php b/14.0-rc/apache/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/14.0-rc/apache/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/14.0-rc/apache/config/autoconfig.php b/14.0-rc/apache/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/14.0-rc/apache/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/14.0-rc/apache/cron.sh b/14.0-rc/apache/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/14.0-rc/apache/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/14.0-rc/apache/entrypoint.sh b/14.0-rc/apache/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/14.0-rc/apache/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/14.0-rc/apache/upgrade.exclude b/14.0-rc/apache/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/14.0-rc/apache/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/14.0-rc/fpm-alpine/Dockerfile b/14.0-rc/fpm-alpine/Dockerfile new file mode 100644 index 00000000..c1e88632 --- /dev/null +++ b/14.0-rc/fpm-alpine/Dockerfile @@ -0,0 +1,123 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template +FROM php:7.2-fpm-alpine3.9 + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apk add --no-cache \ + rsync \ + ; \ + \ + rm /var/spool/cron/crontabs/root; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + autoconf \ + freetype-dev \ + icu-dev \ + libevent-dev \ + libjpeg-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + libmemcached-dev \ + libxml2-dev \ + openldap-dev \ + pcre-dev \ + postgresql-dev \ + imagemagick-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .nextcloud-phpext-rundeps $runDeps; \ + apk del .build-deps + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + + +ENV NEXTCLOUD_VERSION 14.0.8RC2 + +RUN set -ex; \ + apk add --no-cache --virtual .fetch-deps \ + bzip2 \ + gnupg \ + ; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + apk del .fetch-deps + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] diff --git a/14.0-rc/fpm-alpine/config/apcu.config.php b/14.0-rc/fpm-alpine/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/14.0-rc/fpm-alpine/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/14.0-rc/fpm-alpine/config/apps.config.php b/14.0-rc/fpm-alpine/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/14.0-rc/fpm-alpine/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/14.0-rc/fpm-alpine/config/autoconfig.php b/14.0-rc/fpm-alpine/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/14.0-rc/fpm-alpine/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/14.0-rc/fpm-alpine/cron.sh b/14.0-rc/fpm-alpine/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/14.0-rc/fpm-alpine/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/14.0-rc/fpm-alpine/entrypoint.sh b/14.0-rc/fpm-alpine/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/14.0-rc/fpm-alpine/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/14.0-rc/fpm-alpine/upgrade.exclude b/14.0-rc/fpm-alpine/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/14.0-rc/fpm-alpine/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/14.0-rc/fpm/Dockerfile b/14.0-rc/fpm/Dockerfile new file mode 100644 index 00000000..fc12146b --- /dev/null +++ b/14.0-rc/fpm/Dockerfile @@ -0,0 +1,138 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template +FROM php:7.2-fpm-stretch + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev \ + libevent-dev \ + libfreetype6-dev \ + libicu-dev \ + libjpeg-dev \ + libldap2-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libpq-dev \ + libxml2-dev \ + libmagickwand-dev \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + + +ENV NEXTCLOUD_VERSION 14.0.8RC2 + +RUN set -ex; \ + fetchDeps=" \ + gnupg \ + dirmngr \ + "; \ + apt-get update; \ + apt-get install -y --no-install-recommends $fetchDeps; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ + rm -rf /var/lib/apt/lists/* + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] diff --git a/14.0-rc/fpm/config/apcu.config.php b/14.0-rc/fpm/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/14.0-rc/fpm/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/14.0-rc/fpm/config/apps.config.php b/14.0-rc/fpm/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/14.0-rc/fpm/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/14.0-rc/fpm/config/autoconfig.php b/14.0-rc/fpm/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/14.0-rc/fpm/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/14.0-rc/fpm/cron.sh b/14.0-rc/fpm/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/14.0-rc/fpm/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/14.0-rc/fpm/entrypoint.sh b/14.0-rc/fpm/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/14.0-rc/fpm/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/14.0-rc/fpm/upgrade.exclude b/14.0-rc/fpm/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/14.0-rc/fpm/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/14.0/apache/Dockerfile b/14.0/apache/Dockerfile index 9ac1e34a..3775aa72 100644 --- a/14.0/apache/Dockerfile +++ b/14.0/apache/Dockerfile @@ -24,6 +24,7 @@ RUN set -ex; \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ + libevent-dev \ libfreetype6-dev \ libicu-dev \ libjpeg-dev \ @@ -33,6 +34,7 @@ RUN set -ex; \ libpng-dev \ libpq-dev \ libxml2-dev \ + libmagickwand-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ @@ -51,14 +53,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies @@ -106,7 +110,7 @@ RUN a2enmod rewrite remoteip ;\ } > /etc/apache2/conf-available/remoteip.conf;\ a2enconf remoteip -ENV NEXTCLOUD_VERSION 14.0.4 +ENV NEXTCLOUD_VERSION 14.0.7 RUN set -ex; \ fetchDeps=" \ diff --git a/14.0/apache/config/redis.config.php b/14.0/apache/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/14.0/apache/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/14.0/apache/entrypoint.sh b/14.0/apache/entrypoint.sh index 045227e8..07644c04 100755 --- a/14.0/apache/entrypoint.sh +++ b/14.0/apache/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/14.0/fpm-alpine/Dockerfile b/14.0/fpm-alpine/Dockerfile index 87dd98ce..b0a4f24b 100644 --- a/14.0/fpm-alpine/Dockerfile +++ b/14.0/fpm-alpine/Dockerfile @@ -1,5 +1,5 @@ # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template -FROM php:7.2-fpm-alpine3.8 +FROM php:7.2-fpm-alpine3.9 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ @@ -20,6 +20,7 @@ RUN set -ex; \ autoconf \ freetype-dev \ icu-dev \ + libevent-dev \ libjpeg-turbo-dev \ libmcrypt-dev \ libpng-dev \ @@ -28,6 +29,7 @@ RUN set -ex; \ openldap-dev \ pcre-dev \ postgresql-dev \ + imagemagick-dev \ ; \ \ docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ @@ -45,14 +47,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ runDeps="$( \ @@ -87,7 +91,7 @@ RUN { \ VOLUME /var/www/html -ENV NEXTCLOUD_VERSION 14.0.4 +ENV NEXTCLOUD_VERSION 14.0.7 RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ diff --git a/14.0/fpm-alpine/config/redis.config.php b/14.0/fpm-alpine/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/14.0/fpm-alpine/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/14.0/fpm-alpine/entrypoint.sh b/14.0/fpm-alpine/entrypoint.sh index 045227e8..07644c04 100755 --- a/14.0/fpm-alpine/entrypoint.sh +++ b/14.0/fpm-alpine/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/14.0/fpm/Dockerfile b/14.0/fpm/Dockerfile index 966c4be3..c7d608fa 100644 --- a/14.0/fpm/Dockerfile +++ b/14.0/fpm/Dockerfile @@ -24,6 +24,7 @@ RUN set -ex; \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ + libevent-dev \ libfreetype6-dev \ libicu-dev \ libjpeg-dev \ @@ -33,6 +34,7 @@ RUN set -ex; \ libpng-dev \ libpq-dev \ libxml2-dev \ + libmagickwand-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ @@ -51,14 +53,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies @@ -98,7 +102,7 @@ RUN { \ VOLUME /var/www/html -ENV NEXTCLOUD_VERSION 14.0.4 +ENV NEXTCLOUD_VERSION 14.0.7 RUN set -ex; \ fetchDeps=" \ diff --git a/14.0/fpm/config/redis.config.php b/14.0/fpm/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/14.0/fpm/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/14.0/fpm/entrypoint.sh b/14.0/fpm/entrypoint.sh index 045227e8..07644c04 100755 --- a/14.0/fpm/entrypoint.sh +++ b/14.0/fpm/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/15.0-rc/apache/Dockerfile b/15.0-rc/apache/Dockerfile new file mode 100644 index 00000000..e22fc96c --- /dev/null +++ b/15.0-rc/apache/Dockerfile @@ -0,0 +1,146 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template +FROM php:7.2-apache-stretch + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev \ + libevent-dev \ + libfreetype6-dev \ + libicu-dev \ + libjpeg-dev \ + libldap2-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libpq-dev \ + libxml2-dev \ + libmagickwand-dev \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + +RUN a2enmod rewrite remoteip ;\ + {\ + echo RemoteIPHeader X-Real-IP ;\ + echo RemoteIPTrustedProxy 10.0.0.0/8 ;\ + echo RemoteIPTrustedProxy 172.16.0.0/12 ;\ + echo RemoteIPTrustedProxy 192.168.0.0/16 ;\ + } > /etc/apache2/conf-available/remoteip.conf;\ + a2enconf remoteip + +ENV NEXTCLOUD_VERSION 15.0.5RC2 + +RUN set -ex; \ + fetchDeps=" \ + gnupg \ + dirmngr \ + "; \ + apt-get update; \ + apt-get install -y --no-install-recommends $fetchDeps; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ + rm -rf /var/lib/apt/lists/* + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["apache2-foreground"] diff --git a/15.0-rc/apache/config/apache-pretty-urls.config.php b/15.0-rc/apache/config/apache-pretty-urls.config.php new file mode 100644 index 00000000..72da1d8c --- /dev/null +++ b/15.0-rc/apache/config/apache-pretty-urls.config.php @@ -0,0 +1,4 @@ + '/', +); diff --git a/15.0-rc/apache/config/apcu.config.php b/15.0-rc/apache/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/15.0-rc/apache/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/15.0-rc/apache/config/apps.config.php b/15.0-rc/apache/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/15.0-rc/apache/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/15.0-rc/apache/config/autoconfig.php b/15.0-rc/apache/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/15.0-rc/apache/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/15.0-rc/apache/cron.sh b/15.0-rc/apache/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/15.0-rc/apache/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/15.0-rc/apache/entrypoint.sh b/15.0-rc/apache/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/15.0-rc/apache/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/15.0-rc/apache/upgrade.exclude b/15.0-rc/apache/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/15.0-rc/apache/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/15.0-rc/fpm-alpine/Dockerfile b/15.0-rc/fpm-alpine/Dockerfile new file mode 100644 index 00000000..d1970f7e --- /dev/null +++ b/15.0-rc/fpm-alpine/Dockerfile @@ -0,0 +1,123 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-alpine.template +FROM php:7.2-fpm-alpine3.9 + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apk add --no-cache \ + rsync \ + ; \ + \ + rm /var/spool/cron/crontabs/root; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + apk add --no-cache --virtual .build-deps \ + $PHPIZE_DEPS \ + autoconf \ + freetype-dev \ + icu-dev \ + libevent-dev \ + libjpeg-turbo-dev \ + libmcrypt-dev \ + libpng-dev \ + libmemcached-dev \ + libxml2-dev \ + openldap-dev \ + pcre-dev \ + postgresql-dev \ + imagemagick-dev \ + ; \ + \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ + runDeps="$( \ + scanelf --needed --nobanner --format '%n#p' --recursive /usr/local/lib/php/extensions \ + | tr ',' '\n' \ + | sort -u \ + | awk 'system("[ -e /usr/local/lib/" $1 " ]") == 0 { next } { print "so:" $1 }' \ + )"; \ + apk add --virtual .nextcloud-phpext-rundeps $runDeps; \ + apk del .build-deps + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + + +ENV NEXTCLOUD_VERSION 15.0.5RC2 + +RUN set -ex; \ + apk add --no-cache --virtual .fetch-deps \ + bzip2 \ + gnupg \ + ; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + apk del .fetch-deps + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] diff --git a/15.0-rc/fpm-alpine/config/apcu.config.php b/15.0-rc/fpm-alpine/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/15.0-rc/fpm-alpine/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/15.0-rc/fpm-alpine/config/apps.config.php b/15.0-rc/fpm-alpine/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/15.0-rc/fpm-alpine/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/15.0-rc/fpm-alpine/config/autoconfig.php b/15.0-rc/fpm-alpine/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/15.0-rc/fpm-alpine/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/15.0-rc/fpm-alpine/cron.sh b/15.0-rc/fpm-alpine/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/15.0-rc/fpm-alpine/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/15.0-rc/fpm-alpine/entrypoint.sh b/15.0-rc/fpm-alpine/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/15.0-rc/fpm-alpine/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/15.0-rc/fpm-alpine/upgrade.exclude b/15.0-rc/fpm-alpine/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/15.0-rc/fpm-alpine/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/15.0-rc/fpm/Dockerfile b/15.0-rc/fpm/Dockerfile new file mode 100644 index 00000000..48f094fc --- /dev/null +++ b/15.0-rc/fpm/Dockerfile @@ -0,0 +1,138 @@ +# DO NOT EDIT: created by update.sh from Dockerfile-debian.template +FROM php:7.2-fpm-stretch + +# entrypoint.sh and cron.sh dependencies +RUN set -ex; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + rsync \ + bzip2 \ + busybox-static \ + ; \ + rm -rf /var/lib/apt/lists/*; \ + \ + mkdir -p /var/spool/cron/crontabs; \ + echo '*/15 * * * * php -f /var/www/html/cron.php' > /var/spool/cron/crontabs/www-data + +# install the PHP extensions we need +# see https://docs.nextcloud.com/server/12/admin_manual/installation/source_installation.html +RUN set -ex; \ + \ + savedAptMark="$(apt-mark showmanual)"; \ + \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + libcurl4-openssl-dev \ + libevent-dev \ + libfreetype6-dev \ + libicu-dev \ + libjpeg-dev \ + libldap2-dev \ + libmcrypt-dev \ + libmemcached-dev \ + libpng-dev \ + libpq-dev \ + libxml2-dev \ + libmagickwand-dev \ + ; \ + \ + debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ + docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ + docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ + docker-php-ext-install \ + exif \ + gd \ + intl \ + ldap \ + opcache \ + pcntl \ + pdo_mysql \ + pdo_pgsql \ + zip \ + ; \ + \ +# pecl will claim success even if one install fails, so we need to perform each install separately + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ + pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ + \ + docker-php-ext-enable \ + apcu \ + memcached \ + redis \ + imagick \ + ; \ + \ +# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies + apt-mark auto '.*' > /dev/null; \ + apt-mark manual $savedAptMark; \ + ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \ + | awk '/=>/ { print $3 }' \ + | sort -u \ + | xargs -r dpkg-query -S \ + | cut -d: -f1 \ + | sort -u \ + | xargs -rt apt-mark manual; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ + rm -rf /var/lib/apt/lists/* + +# set recommended PHP.ini settings +# see https://docs.nextcloud.com/server/12/admin_manual/configuration_server/server_tuning.html#enable-php-opcache +RUN { \ + echo 'opcache.enable=1'; \ + echo 'opcache.enable_cli=1'; \ + echo 'opcache.interned_strings_buffer=8'; \ + echo 'opcache.max_accelerated_files=10000'; \ + echo 'opcache.memory_consumption=128'; \ + echo 'opcache.save_comments=1'; \ + echo 'opcache.revalidate_freq=1'; \ + } > /usr/local/etc/php/conf.d/opcache-recommended.ini; \ + \ + echo 'apc.enable_cli=1' >> /usr/local/etc/php/conf.d/docker-php-ext-apcu.ini; \ + \ + echo 'memory_limit=512M' > /usr/local/etc/php/conf.d/memory-limit.ini; \ + \ + mkdir /var/www/data; \ + chown -R www-data:root /var/www; \ + chmod -R g=u /var/www + +VOLUME /var/www/html + + +ENV NEXTCLOUD_VERSION 15.0.5RC2 + +RUN set -ex; \ + fetchDeps=" \ + gnupg \ + dirmngr \ + "; \ + apt-get update; \ + apt-get install -y --no-install-recommends $fetchDeps; \ + \ + curl -fsSL -o nextcloud.tar.bz2 \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ + curl -fsSL -o nextcloud.tar.bz2.asc \ + "https://download.nextcloud.com/server/prereleases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ + export GNUPGHOME="$(mktemp -d)"; \ +# gpg key from https://nextcloud.com/nextcloud.asc + gpg --batch --keyserver ha.pool.sks-keyservers.net --recv-keys 28806A878AE423A28372792ED75899B9A724937A; \ + gpg --batch --verify nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + tar -xjf nextcloud.tar.bz2 -C /usr/src/; \ + gpgconf --kill all; \ + rm -r "$GNUPGHOME" nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ + rm -rf /usr/src/nextcloud/updater; \ + mkdir -p /usr/src/nextcloud/data; \ + mkdir -p /usr/src/nextcloud/custom_apps; \ + chmod +x /usr/src/nextcloud/occ; \ + \ + apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ + rm -rf /var/lib/apt/lists/* + +COPY *.sh upgrade.exclude / +COPY config/* /usr/src/nextcloud/config/ + +ENTRYPOINT ["/entrypoint.sh"] +CMD ["php-fpm"] diff --git a/15.0-rc/fpm/config/apcu.config.php b/15.0-rc/fpm/config/apcu.config.php new file mode 100644 index 00000000..69fed876 --- /dev/null +++ b/15.0-rc/fpm/config/apcu.config.php @@ -0,0 +1,4 @@ + '\OC\Memcache\APCu', +); diff --git a/15.0-rc/fpm/config/apps.config.php b/15.0-rc/fpm/config/apps.config.php new file mode 100644 index 00000000..a4bed833 --- /dev/null +++ b/15.0-rc/fpm/config/apps.config.php @@ -0,0 +1,15 @@ + array ( + 0 => array ( + "path" => OC::$SERVERROOT."/apps", + "url" => "/apps", + "writable" => false, + ), + 1 => array ( + "path" => OC::$SERVERROOT."/custom_apps", + "url" => "/custom_apps", + "writable" => true, + ), + ), +); diff --git a/15.0-rc/fpm/config/autoconfig.php b/15.0-rc/fpm/config/autoconfig.php new file mode 100644 index 00000000..85e02212 --- /dev/null +++ b/15.0-rc/fpm/config/autoconfig.php @@ -0,0 +1,29 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/15.0-rc/fpm/cron.sh b/15.0-rc/fpm/cron.sh new file mode 100755 index 00000000..4dfa4118 --- /dev/null +++ b/15.0-rc/fpm/cron.sh @@ -0,0 +1,4 @@ +#!/bin/sh +set -eu + +exec busybox crond -f -l 0 -L /dev/stdout diff --git a/15.0-rc/fpm/entrypoint.sh b/15.0-rc/fpm/entrypoint.sh new file mode 100755 index 00000000..07644c04 --- /dev/null +++ b/15.0-rc/fpm/entrypoint.sh @@ -0,0 +1,132 @@ +#!/bin/sh +set -eu + +# version_greater A B returns whether A > B +version_greater() { + [ "$(printf '%s\n' "$@" | sort -t '.' -n -k1,1 -k2,2 -k3,3 -k4,4 | head -n 1)" != "$1" ] +} + +# return true if specified directory is empty +directory_empty() { + [ -z "$(ls -A "$1/")" ] +} + +run_as() { + if [ "$(id -u)" = 0 ]; then + su -p www-data -s /bin/sh -c "$1" + else + sh -c "$1" + fi +} + +if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then + installed_version="0.0.0.0" + if [ -f /var/www/html/version.php ]; then + # shellcheck disable=SC2016 + installed_version="$(php -r 'require "/var/www/html/version.php"; echo implode(".", $OC_Version);')" + fi + # shellcheck disable=SC2016 + image_version="$(php -r 'require "/usr/src/nextcloud/version.php"; echo implode(".", $OC_Version);')" + + if version_greater "$installed_version" "$image_version"; then + echo "Can't start Nextcloud because the version of the data ($installed_version) is higher than the docker image version ($image_version) and downgrading is not supported. Are you sure you have pulled the newest image version?" + exit 1 + fi + + if version_greater "$image_version" "$installed_version"; then + echo "Initializing nextcloud $image_version ..." + if [ "$installed_version" != "0.0.0.0" ]; then + echo "Upgrading nextcloud from $installed_version ..." + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_before + fi + if [ "$(id -u)" = 0 ]; then + rsync_options="-rlDog --chown www-data:root" + else + rsync_options="-rlD" + fi + rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/ + + for dir in config data custom_apps themes; do + if [ ! -d "/var/www/html/$dir" ] || directory_empty "/var/www/html/$dir"; then + rsync $rsync_options --include "/$dir/" --exclude '/*' /usr/src/nextcloud/ /var/www/html/ + fi + done + echo "Initializing finished" + + #install + if [ "$installed_version" = "0.0.0.0" ]; then + echo "New nextcloud instance" + + if [ -n "${NEXTCLOUD_ADMIN_USER+x}" ] && [ -n "${NEXTCLOUD_ADMIN_PASSWORD+x}" ]; then + # shellcheck disable=SC2016 + install_options='-n --admin-user "$NEXTCLOUD_ADMIN_USER" --admin-pass "$NEXTCLOUD_ADMIN_PASSWORD"' + if [ -n "${NEXTCLOUD_TABLE_PREFIX+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --database-table-prefix "$NEXTCLOUD_TABLE_PREFIX"' + else + install_options=$install_options' --database-table-prefix ""' + fi + if [ -n "${NEXTCLOUD_DATA_DIR+x}" ]; then + # shellcheck disable=SC2016 + install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' + fi + + install=false + if [ -n "${SQLITE_DATABASE+x}" ]; then + echo "Installing with SQLite database" + # shellcheck disable=SC2016 + install_options=$install_options' --database-name "$SQLITE_DATABASE"' + install=true + elif [ -n "${MYSQL_DATABASE+x}" ] && [ -n "${MYSQL_USER+x}" ] && [ -n "${MYSQL_PASSWORD+x}" ] && [ -n "${MYSQL_HOST+x}" ]; then + echo "Installing with MySQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database mysql --database-name "$MYSQL_DATABASE" --database-user "$MYSQL_USER" --database-pass "$MYSQL_PASSWORD" --database-host "$MYSQL_HOST"' + install=true + elif [ -n "${POSTGRES_DB+x}" ] && [ -n "${POSTGRES_USER+x}" ] && [ -n "${POSTGRES_PASSWORD+x}" ] && [ -n "${POSTGRES_HOST+x}" ]; then + echo "Installing with PostgreSQL database" + # shellcheck disable=SC2016 + install_options=$install_options' --database pgsql --database-name "$POSTGRES_DB" --database-user "$POSTGRES_USER" --database-pass "$POSTGRES_PASSWORD" --database-host "$POSTGRES_HOST"' + install=true + fi + + if [ "$install" = true ]; then + echo "starting nextcloud installation" + max_retries=10 + try=0 + until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] + do + echo "retrying install..." + try=$((try+1)) + sleep 3s + done + if [ "$try" -gt "$max_retries" ]; then + echo "installing of nextcloud failed!" + exit 1 + fi + if [ -n "${NEXTCLOUD_TRUSTED_DOMAINS+x}" ]; then + echo "setting trusted domains…" + NC_TRUSTED_DOMAIN_IDX=1 + for DOMAIN in $NEXTCLOUD_TRUSTED_DOMAINS ; do + DOMAIN=$(echo "$DOMAIN" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//') + run_as "php /var/www/html/occ config:system:set trusted_domains $NC_TRUSTED_DOMAIN_IDX --value=$DOMAIN" + NC_TRUSTED_DOMAIN_IDX=$(($NC_TRUSTED_DOMAIN_IDX+1)) + done + fi + else + echo "running web-based installer on first connect!" + fi + fi + #upgrade + else + run_as 'php /var/www/html/occ upgrade' + + run_as 'php /var/www/html/occ app:list' | sed -n "/Enabled:/,/Disabled:/p" > /tmp/list_after + echo "The following apps have been disabled:" + diff /tmp/list_before /tmp/list_after | grep '<' | cut -d- -f2 | cut -d: -f1 + rm -f /tmp/list_before /tmp/list_after + + fi + fi +fi + +exec "$@" diff --git a/15.0-rc/fpm/upgrade.exclude b/15.0-rc/fpm/upgrade.exclude new file mode 100644 index 00000000..a1f2de95 --- /dev/null +++ b/15.0-rc/fpm/upgrade.exclude @@ -0,0 +1,4 @@ +/config/ +/data/ +/custom_apps/ +/themes/ diff --git a/15.0/apache/Dockerfile b/15.0/apache/Dockerfile index 48f1195b..35420f32 100644 --- a/15.0/apache/Dockerfile +++ b/15.0/apache/Dockerfile @@ -24,6 +24,7 @@ RUN set -ex; \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ + libevent-dev \ libfreetype6-dev \ libicu-dev \ libjpeg-dev \ @@ -33,6 +34,7 @@ RUN set -ex; \ libpng-dev \ libpq-dev \ libxml2-dev \ + libmagickwand-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ @@ -51,14 +53,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies @@ -106,7 +110,7 @@ RUN a2enmod rewrite remoteip ;\ } > /etc/apache2/conf-available/remoteip.conf;\ a2enconf remoteip -ENV NEXTCLOUD_VERSION 15.0.0 +ENV NEXTCLOUD_VERSION 15.0.4 RUN set -ex; \ fetchDeps=" \ diff --git a/15.0/apache/config/redis.config.php b/15.0/apache/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/15.0/apache/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/15.0/apache/entrypoint.sh b/15.0/apache/entrypoint.sh index 045227e8..07644c04 100755 --- a/15.0/apache/entrypoint.sh +++ b/15.0/apache/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/15.0/fpm-alpine/Dockerfile b/15.0/fpm-alpine/Dockerfile index d015b235..946e2ebd 100644 --- a/15.0/fpm-alpine/Dockerfile +++ b/15.0/fpm-alpine/Dockerfile @@ -1,5 +1,5 @@ # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template -FROM php:7.2-fpm-alpine3.8 +FROM php:7.2-fpm-alpine3.9 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ @@ -20,6 +20,7 @@ RUN set -ex; \ autoconf \ freetype-dev \ icu-dev \ + libevent-dev \ libjpeg-turbo-dev \ libmcrypt-dev \ libpng-dev \ @@ -28,6 +29,7 @@ RUN set -ex; \ openldap-dev \ pcre-dev \ postgresql-dev \ + imagemagick-dev \ ; \ \ docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ @@ -45,14 +47,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ runDeps="$( \ @@ -87,7 +91,7 @@ RUN { \ VOLUME /var/www/html -ENV NEXTCLOUD_VERSION 15.0.0 +ENV NEXTCLOUD_VERSION 15.0.4 RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ diff --git a/15.0/fpm-alpine/config/redis.config.php b/15.0/fpm-alpine/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/15.0/fpm-alpine/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/15.0/fpm-alpine/entrypoint.sh b/15.0/fpm-alpine/entrypoint.sh index 045227e8..07644c04 100755 --- a/15.0/fpm-alpine/entrypoint.sh +++ b/15.0/fpm-alpine/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/15.0/fpm/Dockerfile b/15.0/fpm/Dockerfile index 6b2c696a..c292d513 100644 --- a/15.0/fpm/Dockerfile +++ b/15.0/fpm/Dockerfile @@ -24,6 +24,7 @@ RUN set -ex; \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ + libevent-dev \ libfreetype6-dev \ libicu-dev \ libjpeg-dev \ @@ -33,6 +34,7 @@ RUN set -ex; \ libpng-dev \ libpq-dev \ libxml2-dev \ + libmagickwand-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ @@ -51,14 +53,16 @@ RUN set -ex; \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately - pecl install APCu-5.1.15; \ - pecl install memcached-3.0.4; \ + pecl install APCu-5.1.17; \ + pecl install memcached-3.1.3; \ pecl install redis-4.2.0; \ + pecl install imagick-3.4.3; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies @@ -98,7 +102,7 @@ RUN { \ VOLUME /var/www/html -ENV NEXTCLOUD_VERSION 15.0.0 +ENV NEXTCLOUD_VERSION 15.0.4 RUN set -ex; \ fetchDeps=" \ diff --git a/15.0/fpm/config/redis.config.php b/15.0/fpm/config/redis.config.php new file mode 100644 index 00000000..5df799f2 --- /dev/null +++ b/15.0/fpm/config/redis.config.php @@ -0,0 +1,12 @@ + '\OC\Memcache\Redis', + 'memcache.locking' => '\OC\Memcache\Redis', + 'redis' => array( + 'host' => getenv('REDIS_HOST'), + 'port' => getenv('REDIS_HOST_PORT') ?: 6379, + ), + ); +} + diff --git a/15.0/fpm/entrypoint.sh b/15.0/fpm/entrypoint.sh index 045227e8..07644c04 100755 --- a/15.0/fpm/entrypoint.sh +++ b/15.0/fpm/entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/Dockerfile-alpine.template b/Dockerfile-alpine.template index 6683f2b1..a92701c0 100644 --- a/Dockerfile-alpine.template +++ b/Dockerfile-alpine.template @@ -1,4 +1,4 @@ -FROM php:%%PHP_VERSION%%-%%VARIANT%%3.8 +FROM php:%%PHP_VERSION%%-%%VARIANT%%3.9 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ @@ -19,14 +19,17 @@ RUN set -ex; \ autoconf \ freetype-dev \ icu-dev \ + libevent-dev \ libjpeg-turbo-dev \ libmcrypt-dev \ libpng-dev \ libmemcached-dev \ libxml2-dev \ + libzip-dev \ openldap-dev \ pcre-dev \ postgresql-dev \ + imagemagick-dev \ ; \ \ docker-php-ext-configure gd --with-freetype-dir=/usr --with-png-dir=/usr --with-jpeg-dir=/usr; \ @@ -47,11 +50,13 @@ RUN set -ex; \ pecl install APCu-%%APCU_VERSION%%; \ pecl install memcached-%%MEMCACHED_VERSION%%; \ pecl install redis-%%REDIS_VERSION%%; \ + pecl install imagick-%%IMAGICK_VERSION%%; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ runDeps="$( \ diff --git a/Dockerfile-debian.template b/Dockerfile-debian.template index 7f451512..c4c01814 100644 --- a/Dockerfile-debian.template +++ b/Dockerfile-debian.template @@ -23,6 +23,7 @@ RUN set -ex; \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ + libevent-dev \ libfreetype6-dev \ libicu-dev \ libjpeg-dev \ @@ -32,6 +33,8 @@ RUN set -ex; \ libpng-dev \ libpq-dev \ libxml2-dev \ + libmagickwand-dev \ + libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ @@ -53,11 +56,13 @@ RUN set -ex; \ pecl install APCu-%%APCU_VERSION%%; \ pecl install memcached-%%MEMCACHED_VERSION%%; \ pecl install redis-%%REDIS_VERSION%%; \ + pecl install imagick-%%IMAGICK_VERSION%%; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ + imagick \ ; \ \ # reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies diff --git a/README.md b/README.md index 0d712c01..175b6143 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Now you can access Nextcloud at http://localhost:8080/ from your host system. ## Using the fpm image To use the fpm image you need an additional web server that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. In most cases you might want use another container or your host as proxy. If you use your host you can address your Nextcloud container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via `docker run --network ...` or a `docker-compose` file). -In both cases you don't want to map the fpm port to you host. +In both cases you don't want to map the fpm port to your host. ```console $ docker run -d nextcloud:fpm @@ -43,7 +43,7 @@ By default this container uses SQLite for data storage, but the Nextcloud setup ## Persistent data The Nextcloud installation and all data beyond what lives in the database (file uploads, etc) is stored in the [unnamed docker volume](https://docs.docker.com/engine/tutorials/dockervolumes/#adding-a-data-volume) volume `/var/www/html`. The docker daemon will store that data within the docker directory `/var/lib/docker/volumes/...`. That means your data is saved even if the container crashes, is stopped or deleted. -To make your data persistent to upgrading and get access for backups is using named docker volume or mount a host folder. To achieve this you need one volume for your database container and Nextcloud. +A named Docker volume or a mounted host directory should be used for upgrades and backups. To achieve this you need one volume for your database container and one for Nextcloud. Nextcloud: - `/var/www/html/` folder where all nextcloud data lives @@ -71,7 +71,7 @@ Overview of the folders that can be mounted as volumes: - `/var/www/html/custom_apps` installed / modified apps - `/var/www/html/config` local configuration - `/var/www/html/data` the actual data of your Nextcloud -- `/var/www/html/themes/` theming/branding +- `/var/www/html/themes/` theming/branding If you want to use named volumes for all of these it would look like this ```console @@ -130,7 +130,12 @@ The install and update script is only triggered when a default command is used ( - `NEXTCLOUD_UPDATE` (default: _0_) +If you want to use Redis you have to create a seperate [Redis](https://hub.docker.com/_/redis/) container in your setup / in your docker-compose file. To inform Nextcloud about the Redis container add: +- `REDIS_HOST` (not set by default) Name of Redis container +- `REDIS_HOST_PORT` (default: _6379_) Optional port for Redis, only use for external Redis servers that run on non-standard ports. + +The use of Redis is recommended to prevent file locking problems. See the examples for further instructions. # Running this image with docker-compose The easiest way to get a fully featured and functional setup is using a `docker-compose` file. There are too many different possibilities to setup your system, so here are only some examples what you have to look for. @@ -152,6 +157,7 @@ volumes: services: db: image: mariadb + command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW restart: always volumes: - db:/var/lib/mysql @@ -192,6 +198,7 @@ volumes: services: db: image: mariadb + command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW restart: always volumes: - db:/var/lib/mysql diff --git a/docker-entrypoint.sh b/docker-entrypoint.sh index 045227e8..07644c04 100755 --- a/docker-entrypoint.sh +++ b/docker-entrypoint.sh @@ -90,7 +90,7 @@ if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UP fi if [ "$install" = true ]; then - echo "starting nexcloud installation" + echo "starting nextcloud installation" max_retries=10 try=0 until run_as "php /var/www/html/occ maintenance:install $install_options" || [ "$try" -gt "$max_retries" ] diff --git a/generate-stackbrew-library.sh b/generate-stackbrew-library.sh index 3e72a0c8..25e26a88 100755 --- a/generate-stackbrew-library.sh +++ b/generate-stackbrew-library.sh @@ -2,8 +2,8 @@ set -Eeuo pipefail declare -A release_channel=( - [production]='13.0.8' - [stable]='14.0.4' + [stable]='15.0.4' + [production]='15.0.4' ) self="$(basename "$BASH_SOURCE")" diff --git a/update.sh b/update.sh index 641ba587..8dc4c81f 100755 --- a/update.sh +++ b/update.sh @@ -3,7 +3,8 @@ set -eo pipefail declare -A php_version=( [default]='7.2' - [12.0]='7.1' + [14.0]='7.2' + [13.0]='7.2' ) declare -A cmd=( @@ -25,9 +26,10 @@ declare -A extras=( ) declare -A pecl_versions=( - [APCu]='5.1.15' - [memcached]='3.0.4' + [APCu]='5.1.17' + [memcached]='3.1.3' [redis]='4.2.0' + [imagick]='3.4.3' ) variants=( @@ -57,6 +59,7 @@ travisEnv= function create_variant() { dir="$1/$variant" + phpVersion=${php_version[$version]-${php_version[default]}} # Create the version+variant directory with a Dockerfile. mkdir -p "$dir" @@ -69,7 +72,7 @@ function create_variant() { # Replace the variables. sed -ri -e ' - s/%%PHP_VERSION%%/'"${php_version[$version]-${php_version[default]}}"'/g; + s/%%PHP_VERSION%%/'"$phpVersion"'/g; s/%%VARIANT%%/'"$variant"'/g; s/%%VERSION%%/'"$fullversion"'/g; s/%%BASE_DOWNLOAD_URL%%/'"$2"'/g; @@ -78,8 +81,15 @@ function create_variant() { s/%%APCU_VERSION%%/'"${pecl_versions[APCu]}"'/g; s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g; s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g; + s/%%IMAGICK_VERSION%%/'"${pecl_versions[imagick]}"'/g; ' "$dir/Dockerfile" + if [[ "$phpVersion" != 7.3 ]]; then + sed -ri \ + -e '/libzip-dev/d' \ + "$dir/Dockerfile" + fi + # Copy the shell scripts for name in entrypoint cron; do cp "docker-$name.sh" "$dir/$name.sh"