Dockerize Nextcloud with Postgre and Redis

This page summarizes the projects mentioned and recommended in the original post on dev.to

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • nextcloud-docker-postgresql-redis

    Docker compose based Nextcloud boilerplate using php8, PostgreSQL, Redis and nginx

  • You can find all the related code on this Github repository, feel free to contribute.

  • PostgreSQL

    Mirror of the official PostgreSQL GIT repository. Note that this is just a *mirror* - we don't work with pull requests on github. To contribute, please see https://wiki.postgresql.org/wiki/Submitting_a_Patch

  • We gonna use a PostgreSQL 14 database container in our stack. We also create another container running a Redis instance for cache purposes.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • Redis

    Redis is an in-memory database that persists on disk. The data model is key-value, but many different kind of values are supported: Strings, Lists, Sets, Sorted Sets, Hashes, Streams, HyperLogLogs, Bitmaps.

  • We gonna use a PostgreSQL 14 database container in our stack. We also create another container running a Redis instance for cache purposes.

  • Nextcloud

    ☁️ Nextcloud server, a safe home for all your data

  • # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template FROM php:8.0-fpm-alpine3.16 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apk add --no-cache \ rsync \ ; \ \ rm /var/spool/cron/crontabs/root; \ echo '*/5 * * * * 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/stable/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 \ libzip-dev \ openldap-dev \ pcre-dev \ postgresql-dev \ imagemagick-dev \ libwebp-dev \ gmp-dev \ ; \ \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ gd \ intl \ ldap \ opcache \ pcntl \ pdo_mysql \ pdo_pgsql \ zip \ gmp \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.21; \ pecl install memcached-3.2.0; \ pecl install redis-5.3.7; \ pecl install imagick-3.7.0; \ \ docker-php-ext-enable \ apcu \ memcached \ redis \ imagick \ ; \ rm -r /tmp/pear; \ \ 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/latest/admin_manual/installation/server_tuning.html#enable-php-opcache ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 10G RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=16'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=128'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'memory_limit=${PHP_MEMORY_LIMIT}'; \ echo 'upload_max_filesize=${PHP_UPLOAD_LIMIT}'; \ echo 'post_max_size=${PHP_UPLOAD_LIMIT}'; \ } > "${PHP_INI_DIR}/conf.d/nextcloud.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 24.0.7 RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ bzip2 \ gnupg \ ; \ \ curl -fsSL -o nextcloud.tar.bz2 \ "https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc \ "https://download.nextcloud.com/server/releases/nextcloud-${NEXTCLOUD_VERSION}.tar.bz2.asc"; \ export GNUPGHOME="$(mktemp -d)"; \ # gpg key from https://nextcloud.com/nextcloud.asc gpg --batch --keyserver keyserver.ubuntu.com --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 nextcloud.tar.bz2.asc nextcloud.tar.bz2; \ rm -rf "$GNUPGHOME" /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"] EXPOSE 9000

  • website

    Let's Encrypt Website and Documentation (by letsencrypt)

  • We'll also need some other containers to generate and also renew the SSL certificate using Letsencrypt.

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts