Repository: nextcloud/docker Branch: master Commit: 803d941dcbb5 Files: 195 Total size: 455.5 KB Directory structure: gitextract_83p45qnn/ ├── .config/ │ ├── apache-pretty-urls.config.php │ ├── apcu.config.php │ ├── apps.config.php │ ├── autoconfig.php │ ├── redis.config.php │ ├── reverse-proxy.config.php │ ├── s3.config.php │ ├── smtp.config.php │ ├── swift.config.php │ └── upgrade-disable-web.config.php ├── .examples/ │ ├── README.md │ ├── docker-compose/ │ │ ├── insecure/ │ │ │ ├── mariadb/ │ │ │ │ ├── apache/ │ │ │ │ │ ├── compose.yaml │ │ │ │ │ └── db.env │ │ │ │ └── fpm/ │ │ │ │ ├── compose.yaml │ │ │ │ ├── db.env │ │ │ │ └── web/ │ │ │ │ └── nginx.conf │ │ │ └── postgres/ │ │ │ ├── apache/ │ │ │ │ ├── compose.yaml │ │ │ │ └── db.env │ │ │ └── fpm/ │ │ │ ├── compose.yaml │ │ │ ├── db.env │ │ │ └── web/ │ │ │ └── nginx.conf │ │ └── with-nginx-proxy/ │ │ ├── mariadb/ │ │ │ ├── apache/ │ │ │ │ ├── compose.yaml │ │ │ │ ├── db.env │ │ │ │ └── proxy/ │ │ │ │ ├── Dockerfile │ │ │ │ └── uploadsize.conf │ │ │ └── fpm/ │ │ │ ├── compose.yaml │ │ │ ├── db.env │ │ │ ├── proxy/ │ │ │ │ ├── Dockerfile │ │ │ │ └── uploadsize.conf │ │ │ └── web/ │ │ │ └── nginx.conf │ │ └── postgres/ │ │ ├── apache/ │ │ │ ├── compose.yaml │ │ │ ├── db.env │ │ │ └── proxy/ │ │ │ ├── Dockerfile │ │ │ └── uploadsize.conf │ │ └── fpm/ │ │ ├── compose.yaml │ │ ├── db.env │ │ ├── proxy/ │ │ │ ├── Dockerfile │ │ │ └── uploadsize.conf │ │ └── web/ │ │ └── nginx.conf │ └── dockerfiles/ │ ├── cron/ │ │ ├── apache/ │ │ │ ├── Dockerfile │ │ │ └── supervisord.conf │ │ ├── fpm/ │ │ │ ├── Dockerfile │ │ │ └── supervisord.conf │ │ └── fpm-alpine/ │ │ ├── Dockerfile │ │ └── supervisord.conf │ ├── full/ │ │ ├── apache/ │ │ │ ├── Dockerfile │ │ │ └── supervisord.conf │ │ ├── fpm/ │ │ │ ├── Dockerfile │ │ │ └── supervisord.conf │ │ └── fpm-alpine/ │ │ ├── Dockerfile │ │ └── supervisord.conf │ ├── imap/ │ │ ├── apache/ │ │ │ └── Dockerfile │ │ ├── fpm/ │ │ │ └── Dockerfile │ │ └── fpm-alpine/ │ │ └── Dockerfile │ └── smb/ │ ├── apache/ │ │ └── Dockerfile │ ├── fpm/ │ │ └── Dockerfile │ └── fpm-alpine/ │ └── Dockerfile ├── .github/ │ ├── ISSUE_TEMPLATE/ │ │ ├── 01-Image_issue.md │ │ ├── 02-Image_enhancement │ │ └── config.yml │ └── workflows/ │ ├── images.yml │ └── update-sh.yml ├── 31/ │ ├── apache/ │ │ ├── Dockerfile │ │ ├── config/ │ │ │ ├── apache-pretty-urls.config.php │ │ │ ├── apcu.config.php │ │ │ ├── apps.config.php │ │ │ ├── autoconfig.php │ │ │ ├── redis.config.php │ │ │ ├── reverse-proxy.config.php │ │ │ ├── s3.config.php │ │ │ ├── smtp.config.php │ │ │ ├── swift.config.php │ │ │ └── upgrade-disable-web.config.php │ │ ├── cron.sh │ │ ├── entrypoint.sh │ │ └── upgrade.exclude │ ├── fpm/ │ │ ├── Dockerfile │ │ ├── config/ │ │ │ ├── apcu.config.php │ │ │ ├── apps.config.php │ │ │ ├── autoconfig.php │ │ │ ├── redis.config.php │ │ │ ├── reverse-proxy.config.php │ │ │ ├── s3.config.php │ │ │ ├── smtp.config.php │ │ │ ├── swift.config.php │ │ │ └── upgrade-disable-web.config.php │ │ ├── cron.sh │ │ ├── entrypoint.sh │ │ └── upgrade.exclude │ └── fpm-alpine/ │ ├── Dockerfile │ ├── config/ │ │ ├── apcu.config.php │ │ ├── apps.config.php │ │ ├── autoconfig.php │ │ ├── redis.config.php │ │ ├── reverse-proxy.config.php │ │ ├── s3.config.php │ │ ├── smtp.config.php │ │ ├── swift.config.php │ │ └── upgrade-disable-web.config.php │ ├── cron.sh │ ├── entrypoint.sh │ └── upgrade.exclude ├── 32/ │ ├── apache/ │ │ ├── Dockerfile │ │ ├── config/ │ │ │ ├── apache-pretty-urls.config.php │ │ │ ├── apcu.config.php │ │ │ ├── apps.config.php │ │ │ ├── autoconfig.php │ │ │ ├── redis.config.php │ │ │ ├── reverse-proxy.config.php │ │ │ ├── s3.config.php │ │ │ ├── smtp.config.php │ │ │ ├── swift.config.php │ │ │ └── upgrade-disable-web.config.php │ │ ├── cron.sh │ │ ├── entrypoint.sh │ │ └── upgrade.exclude │ ├── fpm/ │ │ ├── Dockerfile │ │ ├── config/ │ │ │ ├── apcu.config.php │ │ │ ├── apps.config.php │ │ │ ├── autoconfig.php │ │ │ ├── redis.config.php │ │ │ ├── reverse-proxy.config.php │ │ │ ├── s3.config.php │ │ │ ├── smtp.config.php │ │ │ ├── swift.config.php │ │ │ └── upgrade-disable-web.config.php │ │ ├── cron.sh │ │ ├── entrypoint.sh │ │ └── upgrade.exclude │ └── fpm-alpine/ │ ├── Dockerfile │ ├── config/ │ │ ├── apcu.config.php │ │ ├── apps.config.php │ │ ├── autoconfig.php │ │ ├── redis.config.php │ │ ├── reverse-proxy.config.php │ │ ├── s3.config.php │ │ ├── smtp.config.php │ │ ├── swift.config.php │ │ └── upgrade-disable-web.config.php │ ├── cron.sh │ ├── entrypoint.sh │ └── upgrade.exclude ├── 33/ │ ├── apache/ │ │ ├── Dockerfile │ │ ├── config/ │ │ │ ├── apache-pretty-urls.config.php │ │ │ ├── apcu.config.php │ │ │ ├── apps.config.php │ │ │ ├── autoconfig.php │ │ │ ├── redis.config.php │ │ │ ├── reverse-proxy.config.php │ │ │ ├── s3.config.php │ │ │ ├── smtp.config.php │ │ │ ├── swift.config.php │ │ │ └── upgrade-disable-web.config.php │ │ ├── cron.sh │ │ ├── entrypoint.sh │ │ └── upgrade.exclude │ ├── fpm/ │ │ ├── Dockerfile │ │ ├── config/ │ │ │ ├── apcu.config.php │ │ │ ├── apps.config.php │ │ │ ├── autoconfig.php │ │ │ ├── redis.config.php │ │ │ ├── reverse-proxy.config.php │ │ │ ├── s3.config.php │ │ │ ├── smtp.config.php │ │ │ ├── swift.config.php │ │ │ └── upgrade-disable-web.config.php │ │ ├── cron.sh │ │ ├── entrypoint.sh │ │ └── upgrade.exclude │ └── fpm-alpine/ │ ├── Dockerfile │ ├── config/ │ │ ├── apcu.config.php │ │ ├── apps.config.php │ │ ├── autoconfig.php │ │ ├── redis.config.php │ │ ├── reverse-proxy.config.php │ │ ├── s3.config.php │ │ ├── smtp.config.php │ │ ├── swift.config.php │ │ └── upgrade-disable-web.config.php │ ├── cron.sh │ ├── entrypoint.sh │ └── upgrade.exclude ├── CODE_OF_CONDUCT.md ├── Dockerfile-alpine.template ├── Dockerfile-debian.template ├── LICENSE.md ├── README.md ├── docker-cron.sh ├── docker-entrypoint.sh ├── generate-stackbrew-library.sh ├── latest.txt ├── stack.yml ├── update.sh ├── upgrade.exclude └── versions.json ================================================ FILE CONTENTS ================================================ ================================================ FILE: .config/apache-pretty-urls.config.php ================================================ '/', ); ================================================ FILE: .config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: .config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: .config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: .config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: .config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: .config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: .config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: .examples/README.md ================================================ # Examples section In this subfolders are some examples how to use the docker image. There are two sections: * [`dockerfiles`](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles) * [`docker-compose`](https://github.com/nextcloud/docker/tree/master/.examples/docker-compose) The `dockerfiles` are derived images, that add or alter certain functionalities of the default docker images. In the `docker-compose` subfolder are examples for deployment of the application, including database, redis, collabora and other services. ## Dockerfiles The Dockerfiles use the default images as base image and build on top of it. Example | Description ------- | ------- [cron](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/cron) | uses supervisor to run the cron job inside the container (so no extra container is needed). This image runs `supervisord` to start nextcloud and cron as two seperate processes inside the container. [imap](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/imap) | adds dependencies required to authenticate users via imap [smb](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/smb) | adds dependencies required to use smb shares [full](https://github.com/nextcloud/docker/tree/master/.examples/dockerfiles/full) | adds dependencies for ALL optional packages and cron functionality via supervisor (as in the `cron` example Dockerfile). ### cron NOTE: [this container must run as root or `cron.php` will not run](https://github.com/nextcloud/docker/issues/1899). ### 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/latest/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 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/latest/admin_manual/configuration_server/config_sample_php_parameters.html#previews) NOTE: Nextcloud recommends [disabling preview generation](https://docs.nextcloud.com/server/latest/admin_manual/installation/harden_server.html#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. #### PHP Module bz2 `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` #### PHP Module 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` #### ffmpeg `apt install ffmpeg` #### 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"]` ## docker-compose In `docker-compose` additional services are bundled to create a complete nextcloud installation. The examples are designed to run out-of-the-box. Before running the examples you have to modify the `db.env` and `compose.yaml` file and fill in your custom information. The docker compose examples make heavily use of derived Dockerfiles to add configuration files into the containers. This way they should also work on remote docker systems as _Docker for Windows_. When running docker compose on the same host as the docker daemon, another possibility would be to simply mount the files in the volumes section in the `compose.yaml` file. ### insecure This example should only be used for testing on the local network because it uses a unencrypted http connection. When you want to have your server reachable from the internet adding HTTPS-encryption is mandatory! For this use one of the [with-nginx-proxy](#with-nginx-proxy) examples. To use this example complete the following steps: 1. if you use mariadb or mysql choose a root password for the database in `compose.yaml` behind `MYSQL_ROOT_PASSWORD=` 2. choose a password for the database user nextcloud in `db.env` behind `MYSQL_PASSWORD=` (for mariadb/mysql) or `POSTGRES_PASSWORD=` (for postgres) 3. run `docker compose build --pull` to pull the most recent base images and build the custom dockerfiles 4. start nextcloud with `docker compose up -d` If you want to update your installation to a newer version of nextcloud, repeat the steps 3 and 4. ### with-nginx-proxy The nginx proxy adds a proxy layer between nextcloud and the internet. The proxy is designed to serve multiple sites on the same host machine. The advantage in adding this layer is the ability to add a container for [Let's Encrypt](https://letsencrypt.org/) certificate handling. This combination of the [nginxproxy/nginx-proxy](https://github.com/nginx-proxy/nginx-proxy) and [nginxproxy/acme-companion](https://github.com/nginx-proxy/acme-companion) containers creates a fully automated https encryption of the nextcloud installation without worrying about certificate generation, validation or renewal. **This setup only works with a valid domain name on a server that is reachable from the internet.** To use this example complete the following steps: 1. open `compose.yaml` 1. insert your nextcloud domain behind `VIRTUAL_HOST=`and `LETSENCRYPT_HOST=` 2. enter a valid email behind `LETSENCRYPT_EMAIL=` 3. if you use mariadb or mysql choose a root password for the database behind `MYSQL_ROOT_PASSWORD=` 2. choose a password for the database user nextcloud in `db.env` behind `MYSQL_PASSWORD=` (for mariadb/mysql) or `POSTGRES_PASSWORD=` (for postgres) 3. run `docker compose build --pull` to pull the most recent base images and build the custom dockerfiles 4. start nextcloud with `docker compose up -d` If you want to update your installation to a newer version of nextcloud, repeat the steps 3 and 4. ================================================ FILE: .examples/docker-compose/insecure/mariadb/apache/compose.yaml ================================================ --- services: # Note: MariaDB is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/mariadb db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: mariadb:lts command: --transaction-isolation=READ-COMMITTED restart: always volumes: - db:/var/lib/mysql:Z environment: - MYSQL_ROOT_PASSWORD= - MARIADB_AUTO_UPGRADE=1 - MARIADB_DISABLE_UPGRADE_BACKUP=1 env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:apache restart: always ports: - 127.0.0.1:8080:80 volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - MYSQL_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis cron: image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis volumes: db: nextcloud: ================================================ FILE: .examples/docker-compose/insecure/mariadb/apache/db.env ================================================ MYSQL_PASSWORD= MYSQL_DATABASE=nextcloud MYSQL_USER=nextcloud ================================================ FILE: .examples/docker-compose/insecure/mariadb/fpm/compose.yaml ================================================ --- services: # Note: MariaDB is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/mariadb db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: mariadb:lts command: --transaction-isolation=READ-COMMITTED restart: always volumes: - db:/var/lib/mysql:Z environment: - MYSQL_ROOT_PASSWORD= - MARIADB_AUTO_UPGRADE=1 - MARIADB_DISABLE_UPGRADE_BACKUP=1 env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - MYSQL_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis # Note: Nginx is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/nginx/ web: image: nginx:alpine-slim restart: always ports: - 127.0.0.1:8080:80 volumes: # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html - ./web/nginx.conf:/etc/nginx/nginx.conf:ro # NOTE: The `volumes` included below should match those of the `app` container (unless you know what you're doing) - nextcloud:/var/www/html:z,ro depends_on: - app cron: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis volumes: db: nextcloud: ================================================ FILE: .examples/docker-compose/insecure/mariadb/fpm/db.env ================================================ MYSQL_PASSWORD= MYSQL_DATABASE=nextcloud MYSQL_USER=nextcloud ================================================ FILE: .examples/docker-compose/insecure/mariadb/fpm/web/nginx.conf ================================================ worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; types { text/javascript mjs; } log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; # Prevent nginx HTTP Server Detection server_tokens off; keepalive_timeout 65; # Set the `immutable` cache control options only for assets with a cache busting `v` argument map $arg_v $asset_immutable { "" ""; default ", immutable"; } #gzip on; resolver 127.0.0.11 valid=2s; upstream php-handler { zone backends 64k; server app:9000 resolve; } server { listen 80; # HSTS settings # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; # set max upload size and increase upload timeout: client_max_body_size 512M; client_body_timeout 300s; fastcgi_buffers 64 4K; # The settings allows you to optimize the HTTP2 bandwidth. # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/ # for tuning hints client_body_buffer_size 512k; # Enable gzip but do not remove ETag headers gzip on; gzip_vary on; gzip_comp_level 4; gzip_min_length 256; gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; # Pagespeed is not supported by Nextcloud, so if your server is built # with the `ngx_pagespeed` module, uncomment this line to disable it. #pagespeed off; # HTTP response headers borrowed from Nextcloud `.htaccess` add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; # Remove X-Powered-By, which is an information leak fastcgi_hide_header X-Powered-By; # Path to the root of your installation root /var/www/html; # Specify how to handle directories -- specifying `/index.php$request_uri` # here as the fallback means that Nginx always exhibits the desired behaviour # when a client requests a path that corresponds to a directory that exists # on the server. In particular, if that directory contains an index.php file, # that file is correctly served; if it doesn't, then the request is passed to # the front-end controller. This consistent behaviour means that we don't need # to specify custom rules for certain paths (e.g. images and other assets, # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus # `try_files $uri $uri/ /index.php$request_uri` # always provides the desired behaviour. index index.php index.html /index.php$request_uri; # Rule borrowed from `.htaccess` to handle Microsoft DAV clients location = / { if ( $http_user_agent ~ ^DavClnt ) { return 302 /remote.php/webdav/$is_args$args; } } location = /robots.txt { allow all; log_not_found off; access_log off; } # Make a regex exception for `/.well-known` so that clients can still # access it despite the existence of the regex rule # `location ~ /(\.|autotest|...)` which would otherwise handle requests # for `/.well-known`. location ^~ /.well-known { # The rules in this block are an adaptation of the rules # in `.htaccess` that concern `/.well-known`. location = /.well-known/carddav { return 301 /remote.php/dav/; } location = /.well-known/caldav { return 301 /remote.php/dav/; } location /.well-known/acme-challenge { try_files $uri $uri/ =404; } location /.well-known/pki-validation { try_files $uri $uri/ =404; } # Let Nextcloud's API for `/.well-known` URIs handle all other # requests by passing them to the front-end controller. return 301 /index.php$request_uri; } # Rules borrowed from `.htaccess` to hide certain paths from clients location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } # Ensure this block, which passes PHP files to the PHP process, is above the blocks # which handle static assets (as seen below). If this block is not declared first, # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` # to the URI, resulting in a HTTP 500 error response. location ~ \.php(?:$|/) { # Required for legacy support rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri; fastcgi_split_path_info ^(.+?\.php)(/.*)$; set $path_info $fastcgi_path_info; try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $path_info; #fastcgi_param HTTPS on; fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice fastcgi_param front_controller_active true; # Enable pretty urls fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering on; # Required as PHP-FPM does not support chunked transfer encoding and requires a valid ContentLength header. fastcgi_max_temp_file_size 0; } # Serve static files location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463$asset_immutable"; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; access_log off; # Optional: Don't log access to assets } location ~ \.(otf|woff2?)$ { try_files $uri /index.php$request_uri; expires 7d; # Cache-Control policy borrowed from `.htaccess` access_log off; # Optional: Don't log access to assets } # Rule borrowed from `.htaccess` location /remote { return 301 /remote.php$request_uri; } location / { try_files $uri $uri/ /index.php$request_uri; } } } ================================================ FILE: .examples/docker-compose/insecure/postgres/apache/compose.yaml ================================================ --- services: # Note: PostgreSQL is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/postgres db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: postgres:alpine restart: always volumes: - db:/var/lib/postgresql/data:Z env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:apache restart: always ports: - 127.0.0.1:8080:80 volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - POSTGRES_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis cron: image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis volumes: db: nextcloud: ================================================ FILE: .examples/docker-compose/insecure/postgres/apache/db.env ================================================ POSTGRES_PASSWORD= POSTGRES_DB=nextcloud POSTGRES_USER=nextcloud ================================================ FILE: .examples/docker-compose/insecure/postgres/fpm/compose.yaml ================================================ --- services: # Note: PostgreSQL is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/postgres db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: postgres:alpine restart: always volumes: - db:/var/lib/postgresql/data:Z env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - POSTGRES_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis # Note: Nginx is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/nginx/ web: image: nginx:alpine-slim restart: always ports: - 127.0.0.1:8080:80 volumes: # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html - ./web/nginx.conf:/etc/nginx/nginx.conf:ro # NOTE: The `volumes` included below should match those of the `app` container (unless you know what you're doing) - nextcloud:/var/www/html:z,ro depends_on: - app cron: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis volumes: db: nextcloud: ================================================ FILE: .examples/docker-compose/insecure/postgres/fpm/db.env ================================================ POSTGRES_PASSWORD= POSTGRES_DB=nextcloud POSTGRES_USER=nextcloud ================================================ FILE: .examples/docker-compose/insecure/postgres/fpm/web/nginx.conf ================================================ worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; types { text/javascript mjs; } log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; # Prevent nginx HTTP Server Detection server_tokens off; keepalive_timeout 65; # Set the `immutable` cache control options only for assets with a cache busting `v` argument map $arg_v $asset_immutable { "" ""; default ", immutable"; } #gzip on; resolver 127.0.0.11 valid=2s; upstream php-handler { zone backends 64k; server app:9000 resolve; } server { listen 80; # HSTS settings # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; # set max upload size and increase upload timeout: client_max_body_size 512M; client_body_timeout 300s; fastcgi_buffers 64 4K; # The settings allows you to optimize the HTTP2 bandwidth. # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/ # for tuning hints client_body_buffer_size 512k; # Enable gzip but do not remove ETag headers gzip on; gzip_vary on; gzip_comp_level 4; gzip_min_length 256; gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; # Pagespeed is not supported by Nextcloud, so if your server is built # with the `ngx_pagespeed` module, uncomment this line to disable it. #pagespeed off; # HTTP response headers borrowed from Nextcloud `.htaccess` add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; # Remove X-Powered-By, which is an information leak fastcgi_hide_header X-Powered-By; # Path to the root of your installation root /var/www/html; # Specify how to handle directories -- specifying `/index.php$request_uri` # here as the fallback means that Nginx always exhibits the desired behaviour # when a client requests a path that corresponds to a directory that exists # on the server. In particular, if that directory contains an index.php file, # that file is correctly served; if it doesn't, then the request is passed to # the front-end controller. This consistent behaviour means that we don't need # to specify custom rules for certain paths (e.g. images and other assets, # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus # `try_files $uri $uri/ /index.php$request_uri` # always provides the desired behaviour. index index.php index.html /index.php$request_uri; # Rule borrowed from `.htaccess` to handle Microsoft DAV clients location = / { if ( $http_user_agent ~ ^DavClnt ) { return 302 /remote.php/webdav/$is_args$args; } } location = /robots.txt { allow all; log_not_found off; access_log off; } # Make a regex exception for `/.well-known` so that clients can still # access it despite the existence of the regex rule # `location ~ /(\.|autotest|...)` which would otherwise handle requests # for `/.well-known`. location ^~ /.well-known { # The rules in this block are an adaptation of the rules # in `.htaccess` that concern `/.well-known`. location = /.well-known/carddav { return 301 /remote.php/dav/; } location = /.well-known/caldav { return 301 /remote.php/dav/; } location /.well-known/acme-challenge { try_files $uri $uri/ =404; } location /.well-known/pki-validation { try_files $uri $uri/ =404; } # Let Nextcloud's API for `/.well-known` URIs handle all other # requests by passing them to the front-end controller. return 301 /index.php$request_uri; } # Rules borrowed from `.htaccess` to hide certain paths from clients location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } # Ensure this block, which passes PHP files to the PHP process, is above the blocks # which handle static assets (as seen below). If this block is not declared first, # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` # to the URI, resulting in a HTTP 500 error response. location ~ \.php(?:$|/) { # Required for legacy support rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri; fastcgi_split_path_info ^(.+?\.php)(/.*)$; set $path_info $fastcgi_path_info; try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $path_info; #fastcgi_param HTTPS on; fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice fastcgi_param front_controller_active true; # Enable pretty urls fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering on; # Required as PHP-FPM does not support chunked transfer encoding and requires a valid ContentLength header. fastcgi_max_temp_file_size 0; } # Serve static files location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463$asset_immutable"; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; access_log off; # Optional: Don't log access to assets } location ~ \.(otf|woff2?)$ { try_files $uri /index.php$request_uri; expires 7d; # Cache-Control policy borrowed from `.htaccess` access_log off; # Optional: Don't log access to assets } # Rule borrowed from `.htaccess` location /remote { return 301 /remote.php$request_uri; } location / { try_files $uri $uri/ /index.php$request_uri; } } } ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/apache/compose.yaml ================================================ --- services: # Note: MariaDB is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/mariadb db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: mariadb:lts command: --transaction-isolation=READ-COMMITTED restart: always volumes: - db:/var/lib/mysql:Z environment: - MYSQL_ROOT_PASSWORD= - MARIADB_AUTO_UPGRADE=1 - MARIADB_DISABLE_UPGRADE_BACKUP=1 env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - VIRTUAL_HOST= - LETSENCRYPT_HOST= - LETSENCRYPT_EMAIL= - MYSQL_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis - proxy networks: - proxy-tier - default cron: image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis # Note: Nginx-proxy is an external service. You can find more information about the configuration here: # Warning: Do not use :latest tags of nginx-proxy unless absolutely sure about the consequences. # https://hub.docker.com/r/nginxproxy/nginx-proxy proxy: build: ./proxy restart: always ports: - 80:80 - 443:443 labels: - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" volumes: - certs:/etc/nginx/certs:ro,z - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - dhparam:/etc/nginx/dhparam:z - /var/run/docker.sock:/tmp/docker.sock:z,ro networks: - proxy-tier # Note: Letsencrypt companion is an external service. You can find more information about the configuration here: # https://hub.docker.com/r/nginxproxy/acme-companion letsencrypt-companion: image: nginxproxy/acme-companion restart: always environment: - DEFAULT_EMAIL= volumes: - certs:/etc/nginx/certs:z - acme:/etc/acme.sh:z - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - /var/run/docker.sock:/var/run/docker.sock:z,ro networks: - proxy-tier depends_on: - proxy # self signed,outdated # omgwtfssl: # image: paulczar/omgwtfssl # restart: "no" # volumes: # - certs:/certs # environment: # - SSL_SUBJECT=servhostname.local # - CA_SUBJECT=my@example.com # - SSL_KEY=/certs/servhostname.local.key # - SSL_CSR=/certs/servhostname.local.csr # - SSL_CERT=/certs/servhostname.local.crt # networks: # - proxy-tier volumes: db: nextcloud: certs: acme: vhost.d: html: dhparam: networks: proxy-tier: ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/apache/db.env ================================================ MYSQL_PASSWORD= MYSQL_DATABASE=nextcloud MYSQL_USER=nextcloud ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/Dockerfile ================================================ FROM nginxproxy/nginx-proxy:1.7-alpine COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/apache/proxy/uploadsize.conf ================================================ client_max_body_size 10G; proxy_request_buffering off; ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/fpm/compose.yaml ================================================ --- services: # Note: MariaDB is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/mariadb db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: mariadb:lts command: --transaction-isolation=READ-COMMITTED restart: always volumes: - db:/var/lib/mysql:Z environment: - MYSQL_ROOT_PASSWORD= - MARIADB_AUTO_UPGRADE=1 - MARIADB_DISABLE_UPGRADE_BACKUP=1 env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - MYSQL_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis - proxy # Note: Nginx is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/nginx/ web: image: nginx:alpine-slim restart: always volumes: # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html - ./web/nginx.conf:/etc/nginx/nginx.conf:ro # NOTE: The `volumes` included below should match those of the `app` container (unless you know what you're doing) - nextcloud:/var/www/html:z,ro environment: - VIRTUAL_HOST= - LETSENCRYPT_HOST= - LETSENCRYPT_EMAIL= depends_on: - app networks: - proxy-tier - default cron: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis # Note: Nginx-proxy is an external service. You can find more information about the configuration here: # Warning: Do not use :latest tags of nginx-proxy unless absolutely sure about the consequences. # https://hub.docker.com/r/nginxproxy/nginx-proxy proxy: build: ./proxy restart: always ports: - 80:80 - 443:443 labels: - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" volumes: - certs:/etc/nginx/certs:z,ro - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - /var/run/docker.sock:/tmp/docker.sock:z,ro networks: - proxy-tier # Note: Letsencrypt companion is an external service. You can find more information about the configuration here: # https://hub.docker.com/r/nginxproxy/acme-companion letsencrypt-companion: image: nginxproxy/acme-companion restart: always environment: - DEFAULT_EMAIL= volumes: - certs:/etc/nginx/certs:z - acme:/etc/acme.sh:z - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - /var/run/docker.sock:/var/run/docker.sock:z,ro networks: - proxy-tier depends_on: - proxy # self signed, outdated. # omgwtfssl: # image: paulczar/omgwtfssl # restart: "no" # volumes: # - certs:/certs # environment: # - SSL_SUBJECT=servhostname.local # - CA_SUBJECT=my@example.com # - SSL_KEY=/certs/servhostname.local.key # - SSL_CSR=/certs/servhostname.local.csr # - SSL_CERT=/certs/servhostname.local.crt # networks: # - proxy-tier volumes: db: nextcloud: certs: acme: vhost.d: html: networks: proxy-tier: ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/fpm/db.env ================================================ MYSQL_PASSWORD= MYSQL_DATABASE=nextcloud MYSQL_USER=nextcloud ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/Dockerfile ================================================ FROM nginxproxy/nginx-proxy:1.7-alpine COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/fpm/proxy/uploadsize.conf ================================================ client_max_body_size 10G; proxy_request_buffering off; ================================================ FILE: .examples/docker-compose/with-nginx-proxy/mariadb/fpm/web/nginx.conf ================================================ worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; types { text/javascript mjs; } log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; # Prevent nginx HTTP Server Detection server_tokens off; keepalive_timeout 65; # Set the `immutable` cache control options only for assets with a cache busting `v` argument map $arg_v $asset_immutable { "" ""; default ", immutable"; } #gzip on; resolver 127.0.0.11 valid=2s; upstream php-handler { zone backends 64k; server app:9000 resolve; } server { listen 80; # HSTS settings # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; # set max upload size and increase upload timeout: client_max_body_size 512M; client_body_timeout 300s; fastcgi_buffers 64 4K; # The settings allows you to optimize the HTTP2 bandwidth. # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/ # for tuning hints client_body_buffer_size 512k; # Enable gzip but do not remove ETag headers gzip on; gzip_vary on; gzip_comp_level 4; gzip_min_length 256; gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; # Pagespeed is not supported by Nextcloud, so if your server is built # with the `ngx_pagespeed` module, uncomment this line to disable it. #pagespeed off; # HTTP response headers borrowed from Nextcloud `.htaccess` add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; # Remove X-Powered-By, which is an information leak fastcgi_hide_header X-Powered-By; # Path to the root of your installation root /var/www/html; # Specify how to handle directories -- specifying `/index.php$request_uri` # here as the fallback means that Nginx always exhibits the desired behaviour # when a client requests a path that corresponds to a directory that exists # on the server. In particular, if that directory contains an index.php file, # that file is correctly served; if it doesn't, then the request is passed to # the front-end controller. This consistent behaviour means that we don't need # to specify custom rules for certain paths (e.g. images and other assets, # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus # `try_files $uri $uri/ /index.php$request_uri` # always provides the desired behaviour. index index.php index.html /index.php$request_uri; # Rule borrowed from `.htaccess` to handle Microsoft DAV clients location = / { if ( $http_user_agent ~ ^DavClnt ) { return 302 /remote.php/webdav/$is_args$args; } } location = /robots.txt { allow all; log_not_found off; access_log off; } # Make a regex exception for `/.well-known` so that clients can still # access it despite the existence of the regex rule # `location ~ /(\.|autotest|...)` which would otherwise handle requests # for `/.well-known`. location ^~ /.well-known { # The rules in this block are an adaptation of the rules # in `.htaccess` that concern `/.well-known`. location = /.well-known/carddav { return 301 /remote.php/dav/; } location = /.well-known/caldav { return 301 /remote.php/dav/; } location /.well-known/acme-challenge { try_files $uri $uri/ =404; } location /.well-known/pki-validation { try_files $uri $uri/ =404; } # Let Nextcloud's API for `/.well-known` URIs handle all other # requests by passing them to the front-end controller. return 301 /index.php$request_uri; } # Rules borrowed from `.htaccess` to hide certain paths from clients location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } # Ensure this block, which passes PHP files to the PHP process, is above the blocks # which handle static assets (as seen below). If this block is not declared first, # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` # to the URI, resulting in a HTTP 500 error response. location ~ \.php(?:$|/) { # Required for legacy support rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri; fastcgi_split_path_info ^(.+?\.php)(/.*)$; set $path_info $fastcgi_path_info; try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $path_info; fastcgi_param HTTPS on; fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice fastcgi_param front_controller_active true; # Enable pretty urls fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering on; # Required as PHP-FPM does not support chunked transfer encoding and requires a valid ContentLength header. fastcgi_max_temp_file_size 0; } # Serve static files location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463$asset_immutable"; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; access_log off; # Optional: Don't log access to assets } location ~ \.(otf|woff2?)$ { try_files $uri /index.php$request_uri; expires 7d; # Cache-Control policy borrowed from `.htaccess` access_log off; # Optional: Don't log access to assets } # Rule borrowed from `.htaccess` location /remote { return 301 /remote.php$request_uri; } location / { try_files $uri $uri/ /index.php$request_uri; } } } ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/apache/compose.yaml ================================================ --- services: # Note: PostgreSQL is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/postgres db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: postgres:alpine restart: always volumes: - db:/var/lib/postgresql/data:Z env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - VIRTUAL_HOST= - LETSENCRYPT_HOST= - LETSENCRYPT_EMAIL= - POSTGRES_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis - proxy networks: - proxy-tier - default cron: image: nextcloud:apache restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis # Note: Nginx-proxy is an external service. You can find more information about the configuration here: # Warning: Do not use :latest tags of nginx-proxy unless absolutely sure about the consequences. # https://hub.docker.com/r/nginxproxy/nginx-proxy proxy: build: ./proxy restart: always ports: - 80:80 - 443:443 labels: - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" volumes: - certs:/etc/nginx/certs:ro,z - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - /var/run/docker.sock:/tmp/docker.sock:z,ro networks: - proxy-tier # Note: Letsencrypt companion is an external service. You can find more information about the configuration here: # https://hub.docker.com/r/nginxproxy/acme-companion letsencrypt-companion: image: nginxproxy/acme-companion restart: always volumes: - certs:/etc/nginx/certs:z - acme:/etc/acme.sh:z - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - /var/run/docker.sock:/var/run/docker.sock:z,ro networks: - proxy-tier depends_on: - proxy # self signed, outdated # omgwtfssl: # image: paulczar/omgwtfssl # restart: "no" # volumes: # - certs:/certs # environment: # - SSL_SUBJECT=servhostname.local # - CA_SUBJECT=my@example.com # - SSL_KEY=/certs/servhostname.local.key # - SSL_CSR=/certs/servhostname.local.csr # - SSL_CERT=/certs/servhostname.local.crt # networks: # - proxy-tier volumes: db: nextcloud: certs: acme: vhost.d: html: networks: proxy-tier: ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/apache/db.env ================================================ POSTGRES_PASSWORD= POSTGRES_DB=nextcloud POSTGRES_USER=nextcloud ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/Dockerfile ================================================ FROM nginxproxy/nginx-proxy:1.7-alpine COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/apache/proxy/uploadsize.conf ================================================ client_max_body_size 10G; proxy_request_buffering off; ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/fpm/compose.yaml ================================================ --- services: # Note: PostgreSQL is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/postgres db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: postgres:alpine restart: always volumes: - db:/var/lib/postgresql/data:Z env_file: - db.env # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match environment: - POSTGRES_HOST=db - REDIS_HOST=redis env_file: - db.env depends_on: - db - redis - proxy # Note: Nginx is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/nginx/ web: image: nginx:alpine-slim restart: always volumes: # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html - ./web/nginx.conf:/etc/nginx/nginx.conf:ro # NOTE: The `volumes` included below should match those of the `app` container (unless you know what you're doing) - nextcloud:/var/www/html:z,ro environment: - VIRTUAL_HOST= - LETSENCRYPT_HOST= - LETSENCRYPT_EMAIL= depends_on: - app networks: - proxy-tier - default cron: image: nextcloud:fpm-alpine restart: always volumes: - nextcloud:/var/www/html:z # NOTE: The `volumes` config of the `cron` and `app` containers must match entrypoint: /cron.sh depends_on: - db - redis # Note: Nginx-proxy is an external service. You can find more information about the configuration here: # Warning: Do not use :latest tags of nginx-proxy unless absolutely sure about the consequences. # https://hub.docker.com/r/nginxproxy/nginx-proxy proxy: build: ./proxy restart: always ports: - 80:80 - 443:443 labels: - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy" volumes: - certs:/etc/nginx/certs:z,ro - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - /var/run/docker.sock:/tmp/docker.sock:z,ro networks: - proxy-tier # Note: Letsencrypt companion is an external service. You can find more information about the configuration here: # https://hub.docker.com/r/nginxproxy/acme-companion letsencrypt-companion: image: nginxproxy/acme-companion restart: always volumes: - certs:/etc/nginx/certs:z - acme:/etc/acme.sh:z - vhost.d:/etc/nginx/vhost.d:z - html:/usr/share/nginx/html:z - /var/run/docker.sock:/var/run/docker.sock:z,ro environment: - DEFAULT_EMAIL= networks: - proxy-tier depends_on: - proxy # self signed, outdated # omgwtfssl: # image: paulczar/omgwtfssl # restart: "no" # volumes: # - certs:/certs # environment: # - SSL_SUBJECT=servhostname.local # - CA_SUBJECT=my@example.com # - SSL_KEY=/certs/servhostname.local.key # - SSL_CSR=/certs/servhostname.local.csr # - SSL_CERT=/certs/servhostname.local.crt # networks: # - proxy-tier volumes: db: nextcloud: certs: acme: vhost.d: html: networks: proxy-tier: ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/fpm/db.env ================================================ POSTGRES_PASSWORD= POSTGRES_DB=nextcloud POSTGRES_USER=nextcloud ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/Dockerfile ================================================ FROM nginxproxy/nginx-proxy:1.7-alpine COPY uploadsize.conf /etc/nginx/conf.d/uploadsize.conf ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/fpm/proxy/uploadsize.conf ================================================ client_max_body_size 10G; proxy_request_buffering off; ================================================ FILE: .examples/docker-compose/with-nginx-proxy/postgres/fpm/web/nginx.conf ================================================ worker_processes auto; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; types { text/javascript mjs; } log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; sendfile on; #tcp_nopush on; # Prevent nginx HTTP Server Detection server_tokens off; keepalive_timeout 65; # Set the `immutable` cache control options only for assets with a cache busting `v` argument map $arg_v $asset_immutable { "" ""; default ", immutable"; } #gzip on; resolver 127.0.0.11 valid=2s; upstream php-handler { zone backends 64k; server app:9000 resolve; } server { listen 80; # HSTS settings # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. #add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;" always; # set max upload size and increase upload timeout: client_max_body_size 512M; client_body_timeout 300s; fastcgi_buffers 64 4K; # The settings allows you to optimize the HTTP2 bandwidth. # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/ # for tuning hints client_body_buffer_size 512k; # Enable gzip but do not remove ETag headers gzip on; gzip_vary on; gzip_comp_level 4; gzip_min_length 256; gzip_proxied expired no-cache no-store private no_last_modified no_etag auth; gzip_types application/atom+xml text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy; # Pagespeed is not supported by Nextcloud, so if your server is built # with the `ngx_pagespeed` module, uncomment this line to disable it. #pagespeed off; # HTTP response headers borrowed from Nextcloud `.htaccess` add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; # Remove X-Powered-By, which is an information leak fastcgi_hide_header X-Powered-By; # Path to the root of your installation root /var/www/html; # Specify how to handle directories -- specifying `/index.php$request_uri` # here as the fallback means that Nginx always exhibits the desired behaviour # when a client requests a path that corresponds to a directory that exists # on the server. In particular, if that directory contains an index.php file, # that file is correctly served; if it doesn't, then the request is passed to # the front-end controller. This consistent behaviour means that we don't need # to specify custom rules for certain paths (e.g. images and other assets, # `/updater`, `/ocm-provider`, `/ocs-provider`), and thus # `try_files $uri $uri/ /index.php$request_uri` # always provides the desired behaviour. index index.php index.html /index.php$request_uri; # Rule borrowed from `.htaccess` to handle Microsoft DAV clients location = / { if ( $http_user_agent ~ ^DavClnt ) { return 302 /remote.php/webdav/$is_args$args; } } location = /robots.txt { allow all; log_not_found off; access_log off; } # Make a regex exception for `/.well-known` so that clients can still # access it despite the existence of the regex rule # `location ~ /(\.|autotest|...)` which would otherwise handle requests # for `/.well-known`. location ^~ /.well-known { # The rules in this block are an adaptation of the rules # in `.htaccess` that concern `/.well-known`. location = /.well-known/carddav { return 301 /remote.php/dav/; } location = /.well-known/caldav { return 301 /remote.php/dav/; } location /.well-known/acme-challenge { try_files $uri $uri/ =404; } location /.well-known/pki-validation { try_files $uri $uri/ =404; } # Let Nextcloud's API for `/.well-known` URIs handle all other # requests by passing them to the front-end controller. return 301 /index.php$request_uri; } # Rules borrowed from `.htaccess` to hide certain paths from clients location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/) { return 404; } location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) { return 404; } # Ensure this block, which passes PHP files to the PHP process, is above the blocks # which handle static assets (as seen below). If this block is not declared first, # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php` # to the URI, resulting in a HTTP 500 error response. location ~ \.php(?:$|/) { # Required for legacy support rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri; fastcgi_split_path_info ^(.+?\.php)(/.*)$; set $path_info $fastcgi_path_info; try_files $fastcgi_script_name =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $path_info; fastcgi_param HTTPS on; fastcgi_param modHeadersAvailable true; # Avoid sending the security headers twice fastcgi_param front_controller_active true; # Enable pretty urls fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering on; # Required as PHP-FPM does not support chunked transfer encoding and requires a valid ContentLength header. fastcgi_max_temp_file_size 0; } # Serve static files location ~ \.(?:css|js|mjs|svg|gif|ico|jpg|png|webp|wasm|tflite|map|ogg|flac|mp4|webm)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463$asset_immutable"; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "noindex, nofollow" always; access_log off; # Optional: Don't log access to assets } location ~ \.(otf|woff2?)$ { try_files $uri /index.php$request_uri; expires 7d; # Cache-Control policy borrowed from `.htaccess` access_log off; # Optional: Don't log access to assets } # Rule borrowed from `.htaccess` location /remote { return 301 /remote.php$request_uri; } location / { try_files $uri $uri/ /index.php$request_uri; } } } ================================================ FILE: .examples/dockerfiles/cron/apache/Dockerfile ================================================ FROM nextcloud:apache RUN apt-get update && apt-get install -y \ supervisor \ && rm -rf /var/lib/apt/lists/* \ && mkdir /var/log/supervisord /var/run/supervisord COPY supervisord.conf / ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] ================================================ FILE: .examples/dockerfiles/cron/apache/supervisord.conf ================================================ [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:apache2] stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 command=apache2-foreground [program:cron] stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 command=/cron.sh ================================================ FILE: .examples/dockerfiles/cron/fpm/Dockerfile ================================================ FROM nextcloud:fpm RUN apt-get update && apt-get install -y \ supervisor \ && rm -rf /var/lib/apt/lists/* \ && mkdir /var/log/supervisord /var/run/supervisord COPY supervisord.conf / ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] ================================================ FILE: .examples/dockerfiles/cron/fpm/supervisord.conf ================================================ [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 ================================================ FILE: .examples/dockerfiles/cron/fpm-alpine/Dockerfile ================================================ FROM nextcloud:fpm-alpine RUN apk add --no-cache supervisor \ && mkdir /var/log/supervisord /var/run/supervisord COPY supervisord.conf / ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] ================================================ FILE: .examples/dockerfiles/cron/fpm-alpine/supervisord.conf ================================================ [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 ================================================ FILE: .examples/dockerfiles/full/apache/Dockerfile ================================================ FROM nextcloud:apache RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ ffmpeg \ ghostscript \ libmagickcore-6.q16-6-extra \ procps \ smbclient \ supervisor \ # libreoffice \ ; \ 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 \ libkrb5-dev \ libsmbclient-dev \ ; \ \ docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ docker-php-ext-install \ bz2 \ 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -r dpkg-query --search \ | 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 / ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] ================================================ FILE: .examples/dockerfiles/full/apache/supervisord.conf ================================================ [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:apache2] stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 command=apache2-foreground [program:cron] stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 stderr_logfile=/dev/stderr stderr_logfile_maxbytes=0 command=/cron.sh ================================================ FILE: .examples/dockerfiles/full/fpm/Dockerfile ================================================ FROM nextcloud:fpm RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ ffmpeg \ ghostscript \ libmagickcore-6.q16-6-extra \ procps \ smbclient \ supervisor \ # libreoffice \ ; \ 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 \ libkrb5-dev \ libsmbclient-dev \ ; \ \ docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ docker-php-ext-install \ bz2 \ 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -r dpkg-query --search \ | 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 / ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] ================================================ FILE: .examples/dockerfiles/full/fpm/supervisord.conf ================================================ [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 ================================================ FILE: .examples/dockerfiles/full/fpm-alpine/Dockerfile ================================================ FROM nextcloud:fpm-alpine RUN set -ex; \ \ apk add --no-cache \ ffmpeg \ imagemagick \ procps \ samba-client \ supervisor \ # libreoffice \ ; RUN set -ex; \ \ apk add --no-cache --virtual .build-deps \ $PHPIZE_DEPS \ imap-dev \ krb5-dev \ openssl-dev \ samba-dev \ bzip2-dev \ ; \ \ docker-php-ext-configure imap --with-kerberos --with-imap-ssl; \ docker-php-ext-install \ bz2 \ 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 / ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord", "-c", "/supervisord.conf"] ================================================ FILE: .examples/dockerfiles/full/fpm-alpine/supervisord.conf ================================================ [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 ================================================ FILE: .examples/dockerfiles/imap/apache/Dockerfile ================================================ FROM nextcloud:apache 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -r dpkg-query --search \ | 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/* ================================================ FILE: .examples/dockerfiles/imap/fpm/Dockerfile ================================================ FROM nextcloud:fpm 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -r dpkg-query --search \ | 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/* ================================================ FILE: .examples/dockerfiles/imap/fpm-alpine/Dockerfile ================================================ FROM nextcloud:fpm-alpine RUN set -ex; \ \ apk add --no-cache --virtual .build-deps \ $PHPIZE_DEPS \ imap-dev \ krb5-dev \ openssl-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 ================================================ FILE: .examples/dockerfiles/smb/apache/Dockerfile ================================================ FROM nextcloud:apache RUN apt-get update && apt-get install -y procps smbclient && rm -rf /var/lib/apt/lists/* ================================================ FILE: .examples/dockerfiles/smb/fpm/Dockerfile ================================================ FROM nextcloud:fpm RUN apt-get update && apt-get install -y procps smbclient && rm -rf /var/lib/apt/lists/* ================================================ FILE: .examples/dockerfiles/smb/fpm-alpine/Dockerfile ================================================ FROM nextcloud:fpm-alpine RUN apk add --no-cache procps samba-client ================================================ FILE: .github/ISSUE_TEMPLATE/01-Image_issue.md ================================================ --- name: 🐛 Report a bug in the image about: Create a report to help us improve the image labels: "bug, 0. Needs triage" --- ================================================ FILE: .github/ISSUE_TEMPLATE/02-Image_enhancement ================================================ --- name: 🚀 Suggest an enhancement about: Suggest an idea for improving the image labels: "enhancement, 0. Needs triage" --- ================================================ FILE: .github/ISSUE_TEMPLATE/config.yml ================================================ contact_links: - name: ❓ Ask a question url: https://help.nextcloud.com/ about: Ask a question, get assistance or start a discussion regarding Nextcloud and/or this image - name: Documentation - Nextcloud Server url: https://docs.nextcloud.com/ about: Official documentation for Nextcloud Server - name: Documentation - Nextcloud Docker Image url: https://github.com/nextcloud/docker/blob/master/README.md about: Official documentation for this image - name: 🐳 Documentation - Docker url: https://docs.docker.com/ about: Official documentation for Docker (installing, configuring, troubleshooting) - name: 🐳 Docker Forum url: https://forums.docker.com/ about: Ask a question, get assistance or start a discussion regarding Docker - name: 🐛 Bug Report - Nextcloud Server url: https://github.com/nextcloud/server/issues/new/choose about: Report a bug in Nextcloud Server - name: Enhancement Idea - Nextcloud Server url: https://github.com/nextcloud/server/issues/new/choose about: Suggest an enhancement idea for Nextcloud Server ================================================ FILE: .github/workflows/images.yml ================================================ --- name: Images on: pull_request: workflow_run: workflows: ["update.sh"] branches: [master] types: - completed defaults: run: shell: 'bash -Eeuo pipefail -x {0}' jobs: init: name: Generate Jobs runs-on: ubuntu-latest outputs: strategy: ${{ steps.generate-jobs.outputs.strategy }} steps: - uses: actions/checkout@v4 - uses: docker-library/bashbrew@HEAD - id: generate-jobs name: Generate Jobs run: | strategy="$(GITHUB_REPOSITORY=nextcloud "$BASHBREW_SCRIPTS/github-actions/generate.sh")" strategy="$("$BASHBREW_SCRIPTS/github-actions/munge-i386.sh" -c <<<"$strategy")" echo "strategy=$strategy" >> "$GITHUB_OUTPUT" jq . <<<"$strategy" # sanity check / debugging aid test: needs: init strategy: ${{ fromJson(needs.init.outputs.strategy) }} name: ${{ matrix.name }} runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - name: Prepare Environment run: ${{ matrix.runs.prepare }} - name: Run update.sh script run: ./update.sh - name: Pull Dependencies run: ${{ matrix.runs.pull }} - name: Build ${{ matrix.name }} run: ${{ matrix.runs.build }} - name: History ${{ matrix.name }} run: ${{ matrix.runs.history }} - name: Test ${{ matrix.name }} run: ${{ matrix.runs.test }} - name: '"docker images"' run: ${{ matrix.runs.images }} summary: runs-on: ubuntu-latest needs: test if: always() name: images-test-summary steps: - name: Summary status run: if ${{ needs.test.result != 'success' && needs.test.result != 'skipped' }}; then exit 1; fi ================================================ FILE: .github/workflows/update-sh.yml ================================================ --- name: update.sh on: push: branches: - master schedule: - cron: '15 18 * * *' workflow_dispatch: jobs: run_update_sh: name: Run update.sh script runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Run update.sh script run: ./update.sh - name: Commit files run: | git config --local user.email "workflow@github.com" git config --local user.name "GitHub Workflow" git add -A git commit -m "Runs update.sh" || echo "Nothing to update" - name: Push changes uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} force: true ================================================ FILE: 31/apache/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:8.3-apache-trixie # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ busybox-static \ bzip2 \ libldap-common \ libmagickcore-7.q16-10-extra \ rsync \ ; \ apt-get dist-clean; \ \ mkdir -p /var/spool/cron/crontabs; \ 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 ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN set -ex; \ \ savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ libgmp-dev \ libicu-dev \ libjpeg-dev \ libldap2-dev \ liblz4-dev \ libmagickwand-dev \ libmemcached-dev \ libpng-dev \ libpq-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp --with-openssl-dir=/usr; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ rm -r /tmp/pear; \ \ # 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -rt dpkg-query --search \ # https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) | awk 'sub(":$", "", $1) { print $1 }' \ | sort -u \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get dist-clean # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html RUN a2enmod headers rewrite remoteip ; \ { \ echo 'RemoteIPHeader X-Real-IP'; \ echo 'RemoteIPInternalProxy 10.0.0.0/8'; \ echo 'RemoteIPInternalProxy 172.16.0.0/12'; \ echo 'RemoteIPInternalProxy 192.168.0.0/16'; \ } > /etc/apache2/conf-available/remoteip.conf; \ a2enconf remoteip # set apache config LimitRequestBody ENV APACHE_BODY_LIMIT 1073741824 RUN { \ echo 'LimitRequestBody ${APACHE_BODY_LIMIT}'; \ } > /etc/apache2/conf-available/apache-limits.conf; \ a2enconf apache-limits ENV NEXTCLOUD_VERSION 31.0.14 RUN set -ex; \ fetchDeps=" \ gnupg \ dirmngr \ "; \ apt-get update; \ apt-get install -y --no-install-recommends $fetchDeps; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.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; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ apt-get dist-clean COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] ================================================ FILE: 31/apache/config/apache-pretty-urls.config.php ================================================ '/', ); ================================================ FILE: 31/apache/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 31/apache/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 31/apache/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 31/apache/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 31/apache/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 31/apache/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 31/apache/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 31/apache/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 31/apache/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 31/apache/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 31/fpm/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:8.3-fpm-trixie # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ busybox-static \ bzip2 \ libldap-common \ libmagickcore-7.q16-10-extra \ rsync \ ; \ apt-get dist-clean; \ \ mkdir -p /var/spool/cron/crontabs; \ 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 ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN set -ex; \ \ savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ libgmp-dev \ libicu-dev \ libjpeg-dev \ libldap2-dev \ liblz4-dev \ libmagickwand-dev \ libmemcached-dev \ libpng-dev \ libpq-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp --with-openssl-dir=/usr; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ rm -r /tmp/pear; \ \ # 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -rt dpkg-query --search \ # https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) | awk 'sub(":$", "", $1) { print $1 }' \ | sort -u \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get dist-clean # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html ENV NEXTCLOUD_VERSION 31.0.14 RUN set -ex; \ fetchDeps=" \ gnupg \ dirmngr \ "; \ apt-get update; \ apt-get install -y --no-install-recommends $fetchDeps; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.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; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ apt-get dist-clean COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] ================================================ FILE: 31/fpm/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 31/fpm/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 31/fpm/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 31/fpm/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 31/fpm/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 31/fpm/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 31/fpm/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 31/fpm/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 31/fpm/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 31/fpm/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 31/fpm-alpine/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template FROM php:8.3-fpm-alpine3.23 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apk add --no-cache \ imagemagick \ imagemagick-pdf \ imagemagick-jpeg \ imagemagick-raw \ imagemagick-tiff \ imagemagick-heic \ imagemagick-webp \ imagemagick-svg \ 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 \ gmp-dev \ icu-dev \ imagemagick-dev \ libevent-dev \ libjpeg-turbo-dev \ libmemcached-dev \ libpng-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ openldap-dev \ pcre-dev \ postgresql-dev \ ; \ \ docker-php-ext-configure ftp --with-openssl-dir=/usr; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ 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 --no-network --virtual .nextcloud-phpext-rundeps $runDeps; \ apk del --no-network .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 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html ENV NEXTCLOUD_VERSION 31.0.14 RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ bzip2 \ gnupg \ ; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.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 --no-network .fetch-deps COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] ================================================ FILE: 31/fpm-alpine/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 31/fpm-alpine/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 31/fpm-alpine/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 31/fpm-alpine/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 31/fpm-alpine/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 31/fpm-alpine/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 31/fpm-alpine/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 31/fpm-alpine/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 31/fpm-alpine/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 31/fpm-alpine/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 32/apache/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:8.3-apache-trixie # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ busybox-static \ bzip2 \ libldap-common \ libmagickcore-7.q16-10-extra \ rsync \ ; \ apt-get dist-clean; \ \ mkdir -p /var/spool/cron/crontabs; \ 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 ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN set -ex; \ \ savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ libgmp-dev \ libicu-dev \ libjpeg-dev \ libldap2-dev \ liblz4-dev \ libmagickwand-dev \ libmemcached-dev \ libpng-dev \ libpq-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp --with-openssl-dir=/usr; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ rm -r /tmp/pear; \ \ # 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -rt dpkg-query --search \ # https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) | awk 'sub(":$", "", $1) { print $1 }' \ | sort -u \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get dist-clean # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html RUN a2enmod headers rewrite remoteip ; \ { \ echo 'RemoteIPHeader X-Real-IP'; \ echo 'RemoteIPInternalProxy 10.0.0.0/8'; \ echo 'RemoteIPInternalProxy 172.16.0.0/12'; \ echo 'RemoteIPInternalProxy 192.168.0.0/16'; \ } > /etc/apache2/conf-available/remoteip.conf; \ a2enconf remoteip # set apache config LimitRequestBody ENV APACHE_BODY_LIMIT 1073741824 RUN { \ echo 'LimitRequestBody ${APACHE_BODY_LIMIT}'; \ } > /etc/apache2/conf-available/apache-limits.conf; \ a2enconf apache-limits ENV NEXTCLOUD_VERSION 32.0.6 RUN set -ex; \ fetchDeps=" \ gnupg \ dirmngr \ "; \ apt-get update; \ apt-get install -y --no-install-recommends $fetchDeps; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.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; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ apt-get dist-clean COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] ================================================ FILE: 32/apache/config/apache-pretty-urls.config.php ================================================ '/', ); ================================================ FILE: 32/apache/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 32/apache/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 32/apache/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 32/apache/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 32/apache/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 32/apache/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 32/apache/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 32/apache/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 32/apache/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 32/apache/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 32/fpm/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:8.3-fpm-trixie # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ busybox-static \ bzip2 \ libldap-common \ libmagickcore-7.q16-10-extra \ rsync \ ; \ apt-get dist-clean; \ \ mkdir -p /var/spool/cron/crontabs; \ 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 ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN set -ex; \ \ savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ libgmp-dev \ libicu-dev \ libjpeg-dev \ libldap2-dev \ liblz4-dev \ libmagickwand-dev \ libmemcached-dev \ libpng-dev \ libpq-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp --with-openssl-dir=/usr; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ rm -r /tmp/pear; \ \ # 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -rt dpkg-query --search \ # https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) | awk 'sub(":$", "", $1) { print $1 }' \ | sort -u \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get dist-clean # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html ENV NEXTCLOUD_VERSION 32.0.6 RUN set -ex; \ fetchDeps=" \ gnupg \ dirmngr \ "; \ apt-get update; \ apt-get install -y --no-install-recommends $fetchDeps; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.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; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ apt-get dist-clean COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] ================================================ FILE: 32/fpm/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 32/fpm/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 32/fpm/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 32/fpm/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 32/fpm/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 32/fpm/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 32/fpm/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 32/fpm/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 32/fpm/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 32/fpm/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 32/fpm-alpine/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template FROM php:8.3-fpm-alpine3.23 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apk add --no-cache \ imagemagick \ imagemagick-pdf \ imagemagick-jpeg \ imagemagick-raw \ imagemagick-tiff \ imagemagick-heic \ imagemagick-webp \ imagemagick-svg \ 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 \ gmp-dev \ icu-dev \ imagemagick-dev \ libevent-dev \ libjpeg-turbo-dev \ libmemcached-dev \ libpng-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ openldap-dev \ pcre-dev \ postgresql-dev \ ; \ \ docker-php-ext-configure ftp --with-openssl-dir=/usr; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ 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 --no-network --virtual .nextcloud-phpext-rundeps $runDeps; \ apk del --no-network .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 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html ENV NEXTCLOUD_VERSION 32.0.6 RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ bzip2 \ gnupg \ ; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.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 --no-network .fetch-deps COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] ================================================ FILE: 32/fpm-alpine/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 32/fpm-alpine/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 32/fpm-alpine/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 32/fpm-alpine/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 32/fpm-alpine/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 32/fpm-alpine/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 32/fpm-alpine/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 32/fpm-alpine/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 32/fpm-alpine/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 32/fpm-alpine/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 33/apache/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:8.4-apache-trixie # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ busybox-static \ bzip2 \ libldap-common \ libmagickcore-7.q16-10-extra \ rsync \ ; \ apt-get dist-clean; \ \ mkdir -p /var/spool/cron/crontabs; \ 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 ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN set -ex; \ \ savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ libgmp-dev \ libicu-dev \ libjpeg-dev \ libldap2-dev \ liblz4-dev \ libmagickwand-dev \ libmemcached-dev \ libpng-dev \ libpq-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp --with-ftp-ssl; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ rm -r /tmp/pear; \ \ # 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -rt dpkg-query --search \ # https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) | awk 'sub(":$", "", $1) { print $1 }' \ | sort -u \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get dist-clean # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html RUN a2enmod headers rewrite remoteip ; \ { \ echo 'RemoteIPHeader X-Real-IP'; \ echo 'RemoteIPInternalProxy 10.0.0.0/8'; \ echo 'RemoteIPInternalProxy 172.16.0.0/12'; \ echo 'RemoteIPInternalProxy 192.168.0.0/16'; \ } > /etc/apache2/conf-available/remoteip.conf; \ a2enconf remoteip # set apache config LimitRequestBody ENV APACHE_BODY_LIMIT 1073741824 RUN { \ echo 'LimitRequestBody ${APACHE_BODY_LIMIT}'; \ } > /etc/apache2/conf-available/apache-limits.conf; \ a2enconf apache-limits ENV NEXTCLOUD_VERSION 33.0.0 RUN set -ex; \ fetchDeps=" \ gnupg \ dirmngr \ "; \ apt-get update; \ apt-get install -y --no-install-recommends $fetchDeps; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.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; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ apt-get dist-clean COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["apache2-foreground"] ================================================ FILE: 33/apache/config/apache-pretty-urls.config.php ================================================ '/', ); ================================================ FILE: 33/apache/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 33/apache/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 33/apache/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 33/apache/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 33/apache/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 33/apache/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 33/apache/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 33/apache/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 33/apache/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 33/apache/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 33/fpm/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-debian.template FROM php:8.4-fpm-trixie # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ busybox-static \ bzip2 \ libldap-common \ libmagickcore-7.q16-10-extra \ rsync \ ; \ apt-get dist-clean; \ \ mkdir -p /var/spool/cron/crontabs; \ 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 ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN set -ex; \ \ savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ libgmp-dev \ libicu-dev \ libjpeg-dev \ libldap2-dev \ liblz4-dev \ libmagickwand-dev \ libmemcached-dev \ libpng-dev \ libpq-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp --with-ftp-ssl; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ rm -r /tmp/pear; \ \ # 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -rt dpkg-query --search \ # https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) | awk 'sub(":$", "", $1) { print $1 }' \ | sort -u \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get dist-clean # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html ENV NEXTCLOUD_VERSION 33.0.0 RUN set -ex; \ fetchDeps=" \ gnupg \ dirmngr \ "; \ apt-get update; \ apt-get install -y --no-install-recommends $fetchDeps; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.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; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ apt-get dist-clean COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] ================================================ FILE: 33/fpm/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 33/fpm/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 33/fpm/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 33/fpm/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 33/fpm/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 33/fpm/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 33/fpm/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 33/fpm/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 33/fpm/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 33/fpm/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: 33/fpm-alpine/Dockerfile ================================================ # DO NOT EDIT: created by update.sh from Dockerfile-alpine.template FROM php:8.4-fpm-alpine3.23 # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apk add --no-cache \ imagemagick \ imagemagick-pdf \ imagemagick-jpeg \ imagemagick-raw \ imagemagick-tiff \ imagemagick-heic \ imagemagick-webp \ imagemagick-svg \ 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 \ gmp-dev \ icu-dev \ imagemagick-dev \ libevent-dev \ libjpeg-turbo-dev \ libmemcached-dev \ libpng-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ openldap-dev \ pcre-dev \ postgresql-dev \ ; \ \ docker-php-ext-configure ftp --with-ftp-ssl; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-5.1.28; \ pecl install igbinary-3.2.16; \ pecl install imagick-3.8.1; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-3.4.0; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-6.3.0; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ 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 --no-network --virtual .nextcloud-phpext-rundeps $runDeps; \ apk del --no-network .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 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html ENV NEXTCLOUD_VERSION 33.0.0 RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ bzip2 \ gnupg \ ; \ \ curl -fsSL -o nextcloud.tar.bz2 "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.tar.bz2"; \ curl -fsSL -o nextcloud.tar.bz2.asc "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.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 --no-network .fetch-deps COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["php-fpm"] ================================================ FILE: 33/fpm-alpine/config/apcu.config.php ================================================ '\OC\Memcache\APCu', ); ================================================ FILE: 33/fpm-alpine/config/apps.config.php ================================================ array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => OC::$SERVERROOT.'/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ); ================================================ FILE: 33/fpm-alpine/config/autoconfig.php ================================================ '\OC\Memcache\Redis', 'memcache.locking' => '\OC\Memcache\Redis', 'redis' => array( 'host' => getenv('REDIS_HOST'), 'password' => getenv('REDIS_HOST_PASSWORD_FILE') ? trim(file_get_contents(getenv('REDIS_HOST_PASSWORD_FILE'))) : (string) getenv('REDIS_HOST_PASSWORD'), ), ); if (getenv('REDIS_HOST_PORT') !== false) { $CONFIG['redis']['port'] = (int) getenv('REDIS_HOST_PORT'); } elseif (getenv('REDIS_HOST')[0] != '/') { $CONFIG['redis']['port'] = 6379; } if (getenv('REDIS_HOST_USER') !== false) { $CONFIG['redis']['user'] = (string) getenv('REDIS_HOST_USER'); } } ================================================ FILE: 33/fpm-alpine/config/reverse-proxy.config.php ================================================ array( 'class' => '\OC\Files\ObjectStore\S3', 'arguments' => array( 'bucket' => getenv('OBJECTSTORE_S3_BUCKET'), 'region' => getenv('OBJECTSTORE_S3_REGION') ?: '', 'hostname' => getenv('OBJECTSTORE_S3_HOST') ?: '', 'port' => getenv('OBJECTSTORE_S3_PORT') ?: '', 'storageClass' => getenv('OBJECTSTORE_S3_STORAGE_CLASS') ?: '', 'objectPrefix' => getenv("OBJECTSTORE_S3_OBJECT_PREFIX") ? getenv("OBJECTSTORE_S3_OBJECT_PREFIX") : "urn:oid:", 'autocreate' => strtolower($autocreate) !== 'false', 'use_ssl' => strtolower($use_ssl) !== 'false', // required for some non Amazon S3 implementations 'use_path_style' => $use_path == true && strtolower($use_path) !== 'false', // required for older protocol versions 'legacy_auth' => $use_legacyauth == true && strtolower($use_legacyauth) !== 'false' ) ) ); if (getenv('OBJECTSTORE_S3_KEY_FILE')) { $CONFIG['objectstore']['arguments']['key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_KEY')) { $CONFIG['objectstore']['arguments']['key'] = getenv('OBJECTSTORE_S3_KEY'); } else { $CONFIG['objectstore']['arguments']['key'] = ''; } if (getenv('OBJECTSTORE_S3_SECRET_FILE')) { $CONFIG['objectstore']['arguments']['secret'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SECRET_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SECRET')) { $CONFIG['objectstore']['arguments']['secret'] = getenv('OBJECTSTORE_S3_SECRET'); } else { $CONFIG['objectstore']['arguments']['secret'] = ''; } if (getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = trim(file_get_contents(getenv('OBJECTSTORE_S3_SSE_C_KEY_FILE'))); } elseif (getenv('OBJECTSTORE_S3_SSE_C_KEY')) { $CONFIG['objectstore']['arguments']['sse_c_key'] = getenv('OBJECTSTORE_S3_SSE_C_KEY'); } } ================================================ FILE: 33/fpm-alpine/config/smtp.config.php ================================================ 'smtp', 'mail_smtphost' => getenv('SMTP_HOST'), 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', 'mail_smtpauth' => getenv('SMTP_NAME') && (getenv('SMTP_PASSWORD') || getenv('SMTP_PASSWORD_FILE')), 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', 'mail_smtpname' => getenv('SMTP_NAME') ?: '', 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), 'mail_domain' => getenv('MAIL_DOMAIN'), ); if (getenv('SMTP_PASSWORD_FILE')) { $CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE'))); } elseif (getenv('SMTP_PASSWORD')) { $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); } else { $CONFIG['mail_smtppassword'] = ''; } } ================================================ FILE: 33/fpm-alpine/config/swift.config.php ================================================ [ 'class' => 'OC\\Files\\ObjectStore\\Swift', 'arguments' => [ 'autocreate' => $autocreate == true && strtolower($autocreate) !== 'false', 'user' => [ 'name' => getenv('OBJECTSTORE_SWIFT_USER_NAME'), 'password' => getenv('OBJECTSTORE_SWIFT_USER_PASSWORD'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_USER_DOMAIN')) ?: 'Default', ], ], 'scope' => [ 'project' => [ 'name' => getenv('OBJECTSTORE_SWIFT_PROJECT_NAME'), 'domain' => [ 'name' => (getenv('OBJECTSTORE_SWIFT_PROJECT_DOMAIN')) ?: 'Default', ], ], ], 'serviceName' => (getenv('OBJECTSTORE_SWIFT_SERVICE_NAME')) ?: 'swift', 'region' => getenv('OBJECTSTORE_SWIFT_REGION'), 'url' => getenv('OBJECTSTORE_SWIFT_URL'), 'bucket' => getenv('OBJECTSTORE_SWIFT_CONTAINER_NAME'), ] ] ); } ================================================ FILE: 33/fpm-alpine/config/upgrade-disable-web.config.php ================================================ true, ); ================================================ FILE: 33/fpm-alpine/cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: 33/fpm-alpine/entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: 33/fpm-alpine/upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: CODE_OF_CONDUCT.md ================================================ In the Nextcloud community, participants from all over the world come together to create Free Software for a free internet. This is made possible by the support, hard work and enthusiasm of thousands of people, including those who create and use Nextcloud software. Our code of conduct offers some guidance to ensure Nextcloud participants can cooperate effectively in a positive and inspiring atmosphere, and to explain how together we can strengthen and support each other. The Code of Conduct is shared by all contributors and users who engage with the Nextcloud team and its community services. It presents a summary of the shared values and “common sense” thinking in our community. You can find our full code of conduct on our website: https://nextcloud.com/code-of-conduct/ Please, keep our CoC in mind when you contribute! That way, everyone can be a part of our community in a productive, positive, creative and fun way. ================================================ FILE: Dockerfile-alpine.template ================================================ FROM php:%%PHP_VERSION%%-%%VARIANT%%%%ALPINE_VERSION%% # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apk add --no-cache \ imagemagick \ imagemagick-pdf \ imagemagick-jpeg \ imagemagick-raw \ imagemagick-tiff \ imagemagick-heic \ imagemagick-webp \ imagemagick-svg \ rsync \ ; \ \ rm /var/spool/cron/crontabs/root; \ echo '*/%%CRONTAB_INT%% * * * * 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 \ gmp-dev \ icu-dev \ imagemagick-dev \ libevent-dev \ libjpeg-turbo-dev \ libmemcached-dev \ libpng-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ openldap-dev \ pcre-dev \ postgresql-dev \ ; \ \ docker-php-ext-configure ftp %%FTP_OPTIONS%%; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-%%APCU_VERSION%%; \ pecl install igbinary-%%IGBINARY_VERSION%%; \ pecl install imagick-%%IMAGICK_VERSION%%; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-%%MEMCACHED_VERSION%%; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-%%REDIS_VERSION%%; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ 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 --no-network --virtual .nextcloud-phpext-rundeps $runDeps; \ apk del --no-network .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 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html %%VARIANT_EXTRAS%% ENV NEXTCLOUD_VERSION %%VERSION%% RUN set -ex; \ apk add --no-cache --virtual .fetch-deps \ bzip2 \ gnupg \ ; \ \ curl -fsSL -o nextcloud.tar.bz2 "%%DOWNLOAD_URL%%"; \ curl -fsSL -o nextcloud.tar.bz2.asc "%%DOWNLOAD_URL_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 --no-network .fetch-deps COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["%%CMD%%"] ================================================ FILE: Dockerfile-debian.template ================================================ FROM php:%%PHP_VERSION%%-%%VARIANT%%-%%DEBIAN_VERSION%% # entrypoint.sh and cron.sh dependencies RUN set -ex; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ busybox-static \ bzip2 \ libldap-common \ libmagickcore-7.q16-10-extra \ rsync \ ; \ apt-get dist-clean; \ \ mkdir -p /var/spool/cron/crontabs; \ echo '*/%%CRONTAB_INT%% * * * * 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 ENV PHP_MEMORY_LIMIT 512M ENV PHP_UPLOAD_LIMIT 512M ENV PHP_OPCACHE_MEMORY_CONSUMPTION 128 RUN set -ex; \ \ savedAptMark="$(apt-mark showmanual)"; \ \ apt-get update; \ apt-get install -y --no-install-recommends \ libcurl4-openssl-dev \ libevent-dev \ libfreetype6-dev \ libgmp-dev \ libicu-dev \ libjpeg-dev \ libldap2-dev \ liblz4-dev \ libmagickwand-dev \ libmemcached-dev \ libpng-dev \ libpq-dev \ libwebp-dev \ libxml2-dev \ libzip-dev \ ; \ \ debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \ docker-php-ext-configure ftp %%FTP_OPTIONS%%; \ docker-php-ext-configure gd --with-freetype --with-jpeg --with-webp; \ docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \ docker-php-ext-install -j "$(nproc)" \ bcmath \ exif \ ftp \ gd \ gmp \ intl \ ldap \ pcntl \ pdo_mysql \ pdo_pgsql \ sysvsem \ zip \ ; \ \ # pecl will claim success even if one install fails, so we need to perform each install separately pecl install APCu-%%APCU_VERSION%%; \ pecl install igbinary-%%IGBINARY_VERSION%%; \ pecl install imagick-%%IMAGICK_VERSION%%; \ pecl install --configureoptions 'enable-memcached-igbinary="yes"' \ memcached-%%MEMCACHED_VERSION%%; \ pecl install --configureoptions 'enable-redis-igbinary="yes" enable-redis-zstd="yes" enable-redis-lz4="yes"' \ redis-%%REDIS_VERSION%%; \ \ docker-php-ext-enable \ apcu \ igbinary \ imagick \ memcached \ redis \ ; \ rm -r /tmp/pear; \ \ # 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 '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \ | sort -u \ | xargs -rt dpkg-query --search \ # https://manpages.debian.org/trixie/dpkg/dpkg-query.1.en.html#S (we ignore diversions and it'll be really unusual for more than one package to provide any given .so file) | awk 'sub(":$", "", $1) { print $1 }' \ | sort -u \ | xargs -rt apt-mark manual; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \ apt-get dist-clean # set recommended PHP.ini settings # see https://docs.nextcloud.com/server/latest/admin_manual/installation/server_tuning.html#enable-php-opcache RUN { \ echo 'opcache.enable=1'; \ echo 'opcache.interned_strings_buffer=32'; \ echo 'opcache.max_accelerated_files=10000'; \ echo 'opcache.memory_consumption=${PHP_OPCACHE_MEMORY_CONSUMPTION}'; \ echo 'opcache.save_comments=1'; \ echo 'opcache.revalidate_freq=60'; \ echo 'opcache.jit=1255'; \ echo 'opcache.jit_buffer_size=8M'; \ } > "${PHP_INI_DIR}/conf.d/opcache-recommended.ini"; \ \ echo 'apc.enable_cli=1' >> "${PHP_INI_DIR}/conf.d/docker-php-ext-apcu.ini"; \ \ { \ echo 'apc.serializer=igbinary'; \ echo 'session.serialize_handler=igbinary'; \ } >> "${PHP_INI_DIR}/conf.d/docker-php-ext-igbinary.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; \ mkdir -p /docker-entrypoint-hooks.d/pre-installation \ /docker-entrypoint-hooks.d/post-installation \ /docker-entrypoint-hooks.d/pre-upgrade \ /docker-entrypoint-hooks.d/post-upgrade \ /docker-entrypoint-hooks.d/before-starting; \ chown -R www-data:root /var/www; \ chmod -R g=u /var/www VOLUME /var/www/html %%VARIANT_EXTRAS%% ENV NEXTCLOUD_VERSION %%VERSION%% RUN set -ex; \ fetchDeps=" \ gnupg \ dirmngr \ "; \ apt-get update; \ apt-get install -y --no-install-recommends $fetchDeps; \ \ curl -fsSL -o nextcloud.tar.bz2 "%%DOWNLOAD_URL%%"; \ curl -fsSL -o nextcloud.tar.bz2.asc "%%DOWNLOAD_URL_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; \ \ apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \ apt-get dist-clean COPY *.sh upgrade.exclude / COPY config/* /usr/src/nextcloud/config/ ENTRYPOINT ["/entrypoint.sh"] CMD ["%%CMD%%"] ================================================ FILE: LICENSE.md ================================================ GNU AFFERO GENERAL PUBLIC LICENSE Version 3, 19 November 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The GNU Affero General Public License is a free, copyleft license for software and other kinds of works, specifically designed to ensure cooperation with the community in the case of network server software. The licenses for most software and other practical works are designed to take away your freedom to share and change the works. By contrast, our General Public Licenses are intended to guarantee your freedom to share and change all versions of a program--to make sure it remains free software for all its users. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for them if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs, and that you know you can do these things. Developers that use our General Public Licenses protect your rights with two steps: (1) assert copyright on the software, and (2) offer you this License which gives you legal permission to copy, distribute and/or modify the software. A secondary benefit of defending all users' freedom is that improvements made in alternate versions of the program, if they receive widespread use, become available for other developers to incorporate. Many developers of free software are heartened and encouraged by the resulting cooperation. However, in the case of software used on network servers, this result may fail to come about. The GNU General Public License permits making a modified version and letting the public access it on a server without ever releasing its source code to the public. The GNU Affero General Public License is designed specifically to ensure that, in such cases, the modified source code becomes available to the community. It requires the operator of a network server to provide the source code of the modified version running there to the users of that server. Therefore, public use of a modified version, on a publicly accessible server, gives the public access to the source code of the modified version. An older license, called the Affero General Public License and published by Affero, was designed to accomplish similar goals. This is a different license, not a version of the Affero GPL, but Affero has released a new version of the Affero GPL which permits relicensing under this license. The precise terms and conditions for copying, distribution and modification follow. TERMS AND CONDITIONS 0. Definitions. "This License" refers to version 3 of the GNU Affero General Public License. "Copyright" also means copyright-like laws that apply to other kinds of works, such as semiconductor masks. "The Program" refers to any copyrightable work licensed under this License. Each licensee is addressed as "you". "Licensees" and "recipients" may be individuals or organizations. To "modify" a work means to copy from or adapt all or part of the work in a fashion requiring copyright permission, other than the making of an exact copy. The resulting work is called a "modified version" of the earlier work or a work "based on" the earlier work. A "covered work" means either the unmodified Program or a work based on the Program. To "propagate" a work means to do anything with it that, without permission, would make you directly or secondarily liable for infringement under applicable copyright law, except executing it on a computer or modifying a private copy. Propagation includes copying, distribution (with or without modification), making available to the public, and in some countries other activities as well. To "convey" a work means any kind of propagation that enables other parties to make or receive copies. Mere interaction with a user through a computer network, with no transfer of a copy, is not conveying. An interactive user interface displays "Appropriate Legal Notices" to the extent that it includes a convenient and prominently visible feature that (1) displays an appropriate copyright notice, and (2) tells the user that there is no warranty for the work (except to the extent that warranties are provided), that licensees may convey the work under this License, and how to view a copy of this License. If the interface presents a list of user commands or options, such as a menu, a prominent item in the list meets this criterion. 1. Source Code. The "source code" for a work means the preferred form of the work for making modifications to it. "Object code" means any non-source form of a work. A "Standard Interface" means an interface that either is an official standard defined by a recognized standards body, or, in the case of interfaces specified for a particular programming language, one that is widely used among developers working in that language. The "System Libraries" of an executable work include anything, other than the work as a whole, that (a) is included in the normal form of packaging a Major Component, but which is not part of that Major Component, and (b) serves only to enable use of the work with that Major Component, or to implement a Standard Interface for which an implementation is available to the public in source code form. A "Major Component", in this context, means a major essential component (kernel, window system, and so on) of the specific operating system (if any) on which the executable work runs, or a compiler used to produce the work, or an object code interpreter used to run it. The "Corresponding Source" for a work in object code form means all the source code needed to generate, install, and (for an executable work) run the object code and to modify the work, including scripts to control those activities. However, it does not include the work's System Libraries, or general-purpose tools or generally available free programs which are used unmodified in performing those activities but which are not part of the work. For example, Corresponding Source includes interface definition files associated with source files for the work, and the source code for shared libraries and dynamically linked subprograms that the work is specifically designed to require, such as by intimate data communication or control flow between those subprograms and other parts of the work. The Corresponding Source need not include anything that users can regenerate automatically from other parts of the Corresponding Source. The Corresponding Source for a work in source code form is that same work. 2. Basic Permissions. All rights granted under this License are granted for the term of copyright on the Program, and are irrevocable provided the stated conditions are met. This License explicitly affirms your unlimited permission to run the unmodified Program. The output from running a covered work is covered by this License only if the output, given its content, constitutes a covered work. This License acknowledges your rights of fair use or other equivalent, as provided by copyright law. You may make, run and propagate covered works that you do not convey, without conditions so long as your license otherwise remains in force. You may convey covered works to others for the sole purpose of having them make modifications exclusively for you, or provide you with facilities for running those works, provided that you comply with the terms of this License in conveying all material for which you do not control copyright. Those thus making or running the covered works for you must do so exclusively on your behalf, under your direction and control, on terms that prohibit them from making any copies of your copyrighted material outside their relationship with you. Conveying under any other circumstances is permitted solely under the conditions stated below. Sublicensing is not allowed; section 10 makes it unnecessary. 3. Protecting Users' Legal Rights From Anti-Circumvention Law. No covered work shall be deemed part of an effective technological measure under any applicable law fulfilling obligations under article 11 of the WIPO copyright treaty adopted on 20 December 1996, or similar laws prohibiting or restricting circumvention of such measures. When you convey a covered work, you waive any legal power to forbid circumvention of technological measures to the extent such circumvention is effected by exercising rights under this License with respect to the covered work, and you disclaim any intention to limit operation or modification of the work as a means of enforcing, against the work's users, your or third parties' legal rights to forbid circumvention of technological measures. 4. Conveying Verbatim Copies. You may convey verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice; keep intact all notices stating that this License and any non-permissive terms added in accord with section 7 apply to the code; keep intact all notices of the absence of any warranty; and give all recipients a copy of this License along with the Program. You may charge any price or no price for each copy that you convey, and you may offer support or warranty protection for a fee. 5. Conveying Modified Source Versions. You may convey a work based on the Program, or the modifications to produce it from the Program, in the form of source code under the terms of section 4, provided that you also meet all of these conditions: a) The work must carry prominent notices stating that you modified it, and giving a relevant date. b) The work must carry prominent notices stating that it is released under this License and any conditions added under section 7. This requirement modifies the requirement in section 4 to "keep intact all notices". c) You must license the entire work, as a whole, under this License to anyone who comes into possession of a copy. This License will therefore apply, along with any applicable section 7 additional terms, to the whole of the work, and all its parts, regardless of how they are packaged. This License gives no permission to license the work in any other way, but it does not invalidate such permission if you have separately received it. d) If the work has interactive user interfaces, each must display Appropriate Legal Notices; however, if the Program has interactive interfaces that do not display Appropriate Legal Notices, your work need not make them do so. A compilation of a covered work with other separate and independent works, which are not by their nature extensions of the covered work, and which are not combined with it such as to form a larger program, in or on a volume of a storage or distribution medium, is called an "aggregate" if the compilation and its resulting copyright are not used to limit the access or legal rights of the compilation's users beyond what the individual works permit. Inclusion of a covered work in an aggregate does not cause this License to apply to the other parts of the aggregate. 6. Conveying Non-Source Forms. You may convey a covered work in object code form under the terms of sections 4 and 5, provided that you also convey the machine-readable Corresponding Source under the terms of this License, in one of these ways: a) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by the Corresponding Source fixed on a durable physical medium customarily used for software interchange. b) Convey the object code in, or embodied in, a physical product (including a physical distribution medium), accompanied by a written offer, valid for at least three years and valid for as long as you offer spare parts or customer support for that product model, to give anyone who possesses the object code either (1) a copy of the Corresponding Source for all the software in the product that is covered by this License, on a durable physical medium customarily used for software interchange, for a price no more than your reasonable cost of physically performing this conveying of source, or (2) access to copy the Corresponding Source from a network server at no charge. c) Convey individual copies of the object code with a copy of the written offer to provide the Corresponding Source. This alternative is allowed only occasionally and noncommercially, and only if you received the object code with such an offer, in accord with subsection 6b. d) Convey the object code by offering access from a designated place (gratis or for a charge), and offer equivalent access to the Corresponding Source in the same way through the same place at no further charge. You need not require recipients to copy the Corresponding Source along with the object code. If the place to copy the object code is a network server, the Corresponding Source may be on a different server (operated by you or a third party) that supports equivalent copying facilities, provided you maintain clear directions next to the object code saying where to find the Corresponding Source. Regardless of what server hosts the Corresponding Source, you remain obligated to ensure that it is available for as long as needed to satisfy these requirements. e) Convey the object code using peer-to-peer transmission, provided you inform other peers where the object code and Corresponding Source of the work are being offered to the general public at no charge under subsection 6d. A separable portion of the object code, whose source code is excluded from the Corresponding Source as a System Library, need not be included in conveying the object code work. A "User Product" is either (1) a "consumer product", which means any tangible personal property which is normally used for personal, family, or household purposes, or (2) anything designed or sold for incorporation into a dwelling. In determining whether a product is a consumer product, doubtful cases shall be resolved in favor of coverage. For a particular product received by a particular user, "normally used" refers to a typical or common use of that class of product, regardless of the status of the particular user or of the way in which the particular user actually uses, or expects or is expected to use, the product. A product is a consumer product regardless of whether the product has substantial commercial, industrial or non-consumer uses, unless such uses represent the only significant mode of use of the product. "Installation Information" for a User Product means any methods, procedures, authorization keys, or other information required to install and execute modified versions of a covered work in that User Product from a modified version of its Corresponding Source. The information must suffice to ensure that the continued functioning of the modified object code is in no case prevented or interfered with solely because modification has been made. If you convey an object code work under this section in, or with, or specifically for use in, a User Product, and the conveying occurs as part of a transaction in which the right of possession and use of the User Product is transferred to the recipient in perpetuity or for a fixed term (regardless of how the transaction is characterized), the Corresponding Source conveyed under this section must be accompanied by the Installation Information. But this requirement does not apply if neither you nor any third party retains the ability to install modified object code on the User Product (for example, the work has been installed in ROM). The requirement to provide Installation Information does not include a requirement to continue to provide support service, warranty, or updates for a work that has been modified or installed by the recipient, or for the User Product in which it has been modified or installed. Access to a network may be denied when the modification itself materially and adversely affects the operation of the network or violates the rules and protocols for communication across the network. Corresponding Source conveyed, and Installation Information provided, in accord with this section must be in a format that is publicly documented (and with an implementation available to the public in source code form), and must require no special password or key for unpacking, reading or copying. 7. Additional Terms. "Additional permissions" are terms that supplement the terms of this License by making exceptions from one or more of its conditions. Additional permissions that are applicable to the entire Program shall be treated as though they were included in this License, to the extent that they are valid under applicable law. If additional permissions apply only to part of the Program, that part may be used separately under those permissions, but the entire Program remains governed by this License without regard to the additional permissions. When you convey a copy of a covered work, you may at your option remove any additional permissions from that copy, or from any part of it. (Additional permissions may be written to require their own removal in certain cases when you modify the work.) You may place additional permissions on material, added by you to a covered work, for which you have or can give appropriate copyright permission. Notwithstanding any other provision of this License, for material you add to a covered work, you may (if authorized by the copyright holders of that material) supplement the terms of this License with terms: a) Disclaiming warranty or limiting liability differently from the terms of sections 15 and 16 of this License; or b) Requiring preservation of specified reasonable legal notices or author attributions in that material or in the Appropriate Legal Notices displayed by works containing it; or c) Prohibiting misrepresentation of the origin of that material, or requiring that modified versions of such material be marked in reasonable ways as different from the original version; or d) Limiting the use for publicity purposes of names of licensors or authors of the material; or e) Declining to grant rights under trademark law for use of some trade names, trademarks, or service marks; or f) Requiring indemnification of licensors and authors of that material by anyone who conveys the material (or modified versions of it) with contractual assumptions of liability to the recipient, for any liability that these contractual assumptions directly impose on those licensors and authors. All other non-permissive additional terms are considered "further restrictions" within the meaning of section 10. If the Program as you received it, or any part of it, contains a notice stating that it is governed by this License along with a term that is a further restriction, you may remove that term. If a license document contains a further restriction but permits relicensing or conveying under this License, you may add to a covered work material governed by the terms of that license document, provided that the further restriction does not survive such relicensing or conveying. If you add terms to a covered work in accord with this section, you must place, in the relevant source files, a statement of the additional terms that apply to those files, or a notice indicating where to find the applicable terms. Additional terms, permissive or non-permissive, may be stated in the form of a separately written license, or stated as exceptions; the above requirements apply either way. 8. Termination. You may not propagate or modify a covered work except as expressly provided under this License. Any attempt otherwise to propagate or modify it is void, and will automatically terminate your rights under this License (including any patent licenses granted under the third paragraph of section 11). However, if you cease all violation of this License, then your license from a particular copyright holder is reinstated (a) provisionally, unless and until the copyright holder explicitly and finally terminates your license, and (b) permanently, if the copyright holder fails to notify you of the violation by some reasonable means prior to 60 days after the cessation. Moreover, your license from a particular copyright holder is reinstated permanently if the copyright holder notifies you of the violation by some reasonable means, this is the first time you have received notice of violation of this License (for any work) from that copyright holder, and you cure the violation prior to 30 days after your receipt of the notice. Termination of your rights under this section does not terminate the licenses of parties who have received copies or rights from you under this License. If your rights have been terminated and not permanently reinstated, you do not qualify to receive new licenses for the same material under section 10. 9. Acceptance Not Required for Having Copies. You are not required to accept this License in order to receive or run a copy of the Program. Ancillary propagation of a covered work occurring solely as a consequence of using peer-to-peer transmission to receive a copy likewise does not require acceptance. However, nothing other than this License grants you permission to propagate or modify any covered work. These actions infringe copyright if you do not accept this License. Therefore, by modifying or propagating a covered work, you indicate your acceptance of this License to do so. 10. Automatic Licensing of Downstream Recipients. Each time you convey a covered work, the recipient automatically receives a license from the original licensors, to run, modify and propagate that work, subject to this License. You are not responsible for enforcing compliance by third parties with this License. An "entity transaction" is a transaction transferring control of an organization, or substantially all assets of one, or subdividing an organization, or merging organizations. If propagation of a covered work results from an entity transaction, each party to that transaction who receives a copy of the work also receives whatever licenses to the work the party's predecessor in interest had or could give under the previous paragraph, plus a right to possession of the Corresponding Source of the work from the predecessor in interest, if the predecessor has it or can get it with reasonable efforts. You may not impose any further restrictions on the exercise of the rights granted or affirmed under this License. For example, you may not impose a license fee, royalty, or other charge for exercise of rights granted under this License, and you may not initiate litigation (including a cross-claim or counterclaim in a lawsuit) alleging that any patent claim is infringed by making, using, selling, offering for sale, or importing the Program or any portion of it. 11. Patents. A "contributor" is a copyright holder who authorizes use under this License of the Program or a work on which the Program is based. The work thus licensed is called the contributor's "contributor version". A contributor's "essential patent claims" are all patent claims owned or controlled by the contributor, whether already acquired or hereafter acquired, that would be infringed by some manner, permitted by this License, of making, using, or selling its contributor version, but do not include claims that would be infringed only as a consequence of further modification of the contributor version. For purposes of this definition, "control" includes the right to grant patent sublicenses in a manner consistent with the requirements of this License. Each contributor grants you a non-exclusive, worldwide, royalty-free patent license under the contributor's essential patent claims, to make, use, sell, offer for sale, import and otherwise run, modify and propagate the contents of its contributor version. In the following three paragraphs, a "patent license" is any express agreement or commitment, however denominated, not to enforce a patent (such as an express permission to practice a patent or covenant not to sue for patent infringement). To "grant" such a patent license to a party means to make such an agreement or commitment not to enforce a patent against the party. If you convey a covered work, knowingly relying on a patent license, and the Corresponding Source of the work is not available for anyone to copy, free of charge and under the terms of this License, through a publicly available network server or other readily accessible means, then you must either (1) cause the Corresponding Source to be so available, or (2) arrange to deprive yourself of the benefit of the patent license for this particular work, or (3) arrange, in a manner consistent with the requirements of this License, to extend the patent license to downstream recipients. "Knowingly relying" means you have actual knowledge that, but for the patent license, your conveying the covered work in a country, or your recipient's use of the covered work in a country, would infringe one or more identifiable patents in that country that you have reason to believe are valid. If, pursuant to or in connection with a single transaction or arrangement, you convey, or propagate by procuring conveyance of, a covered work, and grant a patent license to some of the parties receiving the covered work authorizing them to use, propagate, modify or convey a specific copy of the covered work, then the patent license you grant is automatically extended to all recipients of the covered work and works based on it. A patent license is "discriminatory" if it does not include within the scope of its coverage, prohibits the exercise of, or is conditioned on the non-exercise of one or more of the rights that are specifically granted under this License. You may not convey a covered work if you are a party to an arrangement with a third party that is in the business of distributing software, under which you make payment to the third party based on the extent of your activity of conveying the work, and under which the third party grants, to any of the parties who would receive the covered work from you, a discriminatory patent license (a) in connection with copies of the covered work conveyed by you (or copies made from those copies), or (b) primarily for and in connection with specific products or compilations that contain the covered work, unless you entered into that arrangement, or that patent license was granted, prior to 28 March 2007. Nothing in this License shall be construed as excluding or limiting any implied license or other defenses to infringement that may otherwise be available to you under applicable patent law. 12. No Surrender of Others' Freedom. If conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot convey a covered work so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not convey it at all. For example, if you agree to terms that obligate you to collect a royalty for further conveying from those to whom you convey the Program, the only way you could satisfy both those terms and this License would be to refrain entirely from conveying the Program. 13. Remote Network Interaction; Use with the GNU General Public License. Notwithstanding any other provision of this License, if you modify the Program, your modified version must prominently offer all users interacting with it remotely through a computer network (if your version supports such interaction) an opportunity to receive the Corresponding Source of your version by providing access to the Corresponding Source from a network server at no charge, through some standard or customary means of facilitating copying of software. This Corresponding Source shall include the Corresponding Source for any work covered by version 3 of the GNU General Public License that is incorporated pursuant to the following paragraph. Notwithstanding any other provision of this License, you have permission to link or combine any covered work with a work licensed under version 3 of the GNU General Public License into a single combined work, and to convey the resulting work. The terms of this License will continue to apply to the part which is the covered work, but the work with which it is combined will remain governed by version 3 of the GNU General Public License. 14. Revised Versions of this License. The Free Software Foundation may publish revised and/or new versions of the GNU Affero General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies that a certain numbered version of the GNU Affero General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that numbered version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the GNU Affero General Public License, you may choose any version ever published by the Free Software Foundation. If the Program specifies that a proxy can decide which future versions of the GNU Affero General Public License can be used, that proxy's public statement of acceptance of a version permanently authorizes you to choose that version for the Program. Later license versions may give you additional or different permissions. However, no additional obligations are imposed on any author or copyright holder as a result of your choosing to follow a later version. 15. Disclaimer of Warranty. THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. Limitation of Liability. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 17. Interpretation of Sections 15 and 16. If the disclaimer of warranty and limitation of liability provided above cannot be given local legal effect according to their terms, reviewing courts shall apply local law that most closely approximates an absolute waiver of all civil liability in connection with the Program, unless a warranty or assumption of liability accompanies a copy of the Program in return for a fee. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively state the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . Also add information on how to contact you by electronic and paper mail. If your software can interact with users remotely through a computer network, you should also make sure that it provides a way for users to get its source. For example, if your program is a web application, its interface could display a "Source" link that leads users to an archive of the code. There are many ways you could offer source, and different solutions will be better for different programs; see section 13 for the specific requirements. You should also get your employer (if you work as a programmer) or school, if any, to sign a "copyright disclaimer" for the program, if necessary. For more information on this, and how to apply and follow the GNU AGPL, see . ================================================ FILE: README.md ================================================ ![GitHub last commit](https://img.shields.io/github/last-commit/nextcloud/docker) [![GitHub Release](https://img.shields.io/github/v/release/nextcloud/docker?link=https%3A%2F%2Fgithub.com%2Fnextcloud%2Fdocker%2Freleases%2Flatest&label=latest%20Image)](https://github.com/nextcloud/docker/releases/) [![Docker Image Version](https://img.shields.io/docker/v/library/nextcloud?sort=semver&logo=nextcloud&label=Nextcloud)](https://nextcloud.com/changelog/) ![GitHub commits since latest release](https://img.shields.io/github/commits-since/nextcloud/docker/latest) ![GitHub commit activity](https://img.shields.io/github/commit-activity/m/nextcloud/docker) ![GitHub contributors](https://img.shields.io/github/contributors/nextcloud/docker?label=contributors%20-%20Thank%20you!) ![Docker Pulls](https://img.shields.io/docker/pulls/library/nextcloud) [![Helm](https://img.shields.io/badge/Helm-0F1689?logo=helm&logoColor=fff)](https://github.com/nextcloud/helm/?tab=readme-ov-file) # What is Nextcloud? A safe home for all your data. Access & share your files, calendars, contacts, mail & more from any device, on your terms. ![logo](https://cdn.rawgit.com/nextcloud/docker/071b888f7f689caa62c1498b6c61cb3599bcea2b/logo.svg) ⚠️⚠️⚠️ This image is maintained by community volunteers and designed for expert use. For quick and easy deployment that supports the full set of Nextcloud Hub features, use the [Nextcloud All-in-One docker container](https://github.com/nextcloud/all-in-one#nextcloud-all-in-one) maintained by Nextcloud GmbH. ## Table of Contents - [What is Nextcloud?](#what-is-nextcloud) - [How to use this image](#how-to-use-this-image) - [Getting help](#getting-help) - [Using the apache image](#using-the-apache-image) - [Using the fpm image](#using-the-fpm-image) - [Using an external database](#using-an-external-database) - [Persistent data](#persistent-data) - [Additional volumes](#additional-volumes) - [Custom volumes](#custom-volumes) - [Running as an arbitrary user / file permissions / changing the default container user](#running-as-an-arbitrary-user--file-permissions--changing-the-default-container-user) - [Accessing the Nextcloud command-line interface (`occ`)](#accessing-the-nextcloud-command-line-interface-occ) - [Viewing the Nextcloud configuration (`config.php`)](#viewing-the-nextcloud-configuration-configphp) - [Auto configuration via environment variables](#auto-configuration-via-environment-variables) - [Database parameters](#database-parameters) - [Initial admin account](#initial-admin-account) - [Custom Data directory (`datadirectory`)](#custom-data-directory-datadirectory) - [Trusted domains (`trusted_domains`)](#trusted-domains-trusted_domains) - [Image specific](#image-specific) - [Redis Memory Caching](#redis-memory-caching) - [E-mail (SMTP) Configuration](#e-mail-smtp-configuration) - [Object Storage (Primary Storage)](#object-storage-primary-storage) - [PHP Configuration](#php-configuration) - [Apache Configuration](#apache-configuration) - [Using the image behind a reverse proxy and specifying the server host and protocol](#using-the-image-behind-a-reverse-proxy-and-specifying-the-server-host-and-protocol) - [Handling `Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile` (aka: Auto configuration and Nextcloud updates)](#handling-warning-varwwwhtmlconfigcfgfile-differs-from-the-latest-version-of-this-image-at-usrsrcnextcloudconfigcfgfile-aka-auto-configuration-and-nextcloud-updates) - [Auto configuration via hook folders](#auto-configuration-via-hook-folders) - [Running this image with `docker compose`](#running-this-image-with-docker-compose) - [Base version - apache](#base-version---apache) - [Base version - FPM](#base-version---fpm) - [Docker Secrets](#docker-secrets) - [Make your Nextcloud available from the internet](#make-your-nextcloud-available-from-the-internet) - [HTTPS - SSL encryption](#https---ssl-encryption) - [First use](#first-use) - [Update to a newer version](#update-to-a-newer-version) - [Adding Features](#adding-features) - [Migrating an existing installation](#migrating-an-existing-installation) - [Migrating from a non-Alpine image to an Alpine image](#migrating-from-a-non-alpine-image-to-an-alpine-image) - [Reporting bugs or suggesting enhancements](#reporting-bugs-or-suggesting-enhancements) # How to use this image This image is designed to be used in a micro-service environment. There are two versions of the image you can choose from. The `apache` tag contains a full Nextcloud installation including an apache web server. It is designed to be easy to use and gets you running pretty fast. This is also the default for the `latest` tag and version tags that are not further specified. The second option is a `fpm` container. It is based on the [php-fpm](https://hub.docker.com/_/php/) image and runs a fastCGI-Process that serves your Nextcloud page. To use this image it must be combined with any webserver that can proxy the http requests to the FastCGI-port of the container. [![Try in PWD](https://github.com/play-with-docker/stacks/raw/cff22438cb4195ace27f9b15784bbb497047afa7/assets/images/button.png)](http://play-with-docker.com?stack=https://raw.githubusercontent.com/nextcloud/docker/8db861d67f257a3e9ac1790ea06d4e2a7a193a6c/stack.yml) ## Getting help Most Nextcloud Server administrative matters are covered in the official [Nextcloud Admin Manual](https://docs.nextcloud.com/server/latest/admin_manual/) or [other official Nextcloud documentation](https://docs.nextcloud.com) (which are all routinely updated). [![Discourse Users](https://img.shields.io/discourse/users?server=https%3A%2F%2Fhelp.nextcloud.com&label=Community%20Forum&color=blue&link=https%3A%2F%2Fhelp.nextcloud.com%2F)](https://help.nextcloud.com/) [![Discourse Posts](https://img.shields.io/discourse/posts?server=https%3A%2F%2Fhelp.nextcloud.com&label=Community%20Forum&color=blue&link=https%3A%2F%2Fhelp.nextcloud.com%2F)](https://help.nextcloud.com/) **If you have any problems or usage questions while using the image, please ask for assistance on the [Nextcloud Community Help Forum](https://help.nextcloud.com)** rather than reporting them as "bugs" (unless they are bugs of course). This helps the maintainers (who are volunteers) remain focused on making the image better (rather than responding solely to one-on-one support issues). (Tip: Some of the maintainers are also regular responders to help requests on the [community help forum](https://help.nextcloud.com/).) For the image specifically, we provide [some simple deployment examples](https://github.com/nextcloud/docker/?tab=readme-ov-file#running-this-image-with-docker-compose) as well as some more extensive [deployment examples](https://github.com/nextcloud/docker/tree/master/.examples). In addition, the [community help forum](https://help.nextcloud.com/) has a "how-to" section with further examples of other peoples' container based Nextcloud stacks. Below you'll find the main documentation for using this image. ## Using the apache image The apache image contains a webserver and exposes port 80. To start the container type: ```console $ docker run -d -p 8080:80 nextcloud ``` Now you can access Nextcloud at http://localhost:8080/ from your host system. WARNING: This example is only suitable for limited testing purposes. Please read on to understand how the image handles storing your data and other aspects you need to consider to establish a full Nextcloud stack. ## Using the fpm image To use the fpm image, you need an additional web server, such as [nginx](https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html), 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 to 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 your host. ```console $ docker run -d nextcloud:fpm ``` As the fastCGI-Process is not capable of serving static files (style sheets, images, ...), the webserver needs access to these files. This can be achieved with the `volumes-from` option. You can find more information in the [docker compose section](#running-this-image-with-docker-compose). ## Using an external database By default, this container uses SQLite for data storage but the Nextcloud setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB or PostgreSQL database. You can also link a database container, e. g. `--link my-mysql:mysql`, and then use `mysql` as the database host on setup. More info is in [the docker compose section](https://github.com/nextcloud/docker/?tab=readme-ov-file#running-this-image-with-docker-compose). ## Persistent data The Nextcloud installation and all data beyond what lives in the database (file uploads, etc.) are 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. 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 ```console $ docker run -d \ -v nextcloud:/var/www/html \ nextcloud ``` Database: - `/var/lib/mysql` MySQL / MariaDB Data - `/var/lib/postgresql/data` PostgreSQL Data ```console $ docker run -d \ -v db:/var/lib/mysql \ mariadb:lts ``` ### Additional volumes If you want to get fine grained access to your individual files, you can mount additional volumes for data, config, your theme and custom apps. The `data`, `config` files are stored in respective subfolders inside `/var/www/html/`. The apps are split into core `apps` (which are shipped with Nextcloud and you don't need to take care of) and a `custom_apps` folder. If you use a custom theme it would go into the `themes` subfolder. Overview of the folders that can be mounted as volumes: - `/var/www/html` Main folder, needed for updating - `/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 If you want to use named volumes for all of these, it would look like this: ```console $ docker run -d \ -v nextcloud:/var/www/html \ -v custom_apps:/var/www/html/custom_apps \ -v config:/var/www/html/config \ -v data:/var/www/html/data \ -v theme:/var/www/html/themes/ \ nextcloud ``` If you'd prefer to use bind mounts instead of named volumes, for instance, when working with different device or network mounts for user data files and configuration: ```console $ docker run -d \ -v /path/on/host/to/folder/nextcloud:/var/www/html \ -v /path/on/host/to/folder/custom_apps:/var/www/html/custom_apps \ -v /path/on/host/to/folder/config:/var/www/html/config \ -v /path/on/host/to/folder/data:/var/www/html/data \ -v /path/on/host/to/folder/theme:/var/www/html/themes/ \ nextcloud ``` Here’s the same example using Docker's more detailed `--mount`. Note that with `-v` or `--volume`, the specified folders are created automatically if they don't exist. However, when using `--mount` for bind mounts, the directories must already exist on the host, or Docker will return an error. ```console $ docker run -d \ --mount type=bind,source=/path/on/host/to/folder/nextcloud,target=/var/www/html \ --mount type=bind,source=/path/on/host/to/folder/custom_apps,target=/var/www/html/custom_apps \ --mount type=bind,source=/path/on/host/to/folder/config,target=/var/www/html/config \ --mount type=bind,source=/path/on/host/to/folder/data,target=/var/www/html/data \ --mount type=bind,source=/path/on/host/to/folder/theme,target=/var/www/html/themes/ \ nextcloud ``` The examples above use figurative directory `/path/on/host/to/folder/` for bind mounts. Please modify the paths by using either a relative or absolute path. NOTE: Do not confuse the `apps` and `custom_apps` folders. These folders contain different sets of apps, and mixing them will result in a broken installation. The former contains "shipped" apps, which come with Nextcloud Server. The latter contains apps you install from the App Store. ### Custom volumes If mounting additional volumes under `/var/www/html`, you should consider: - Confirming that [upgrade.exclude](https://github.com/nextcloud/docker/blob/master/upgrade.exclude) contains the files and folders that should persist during installation and upgrades; or - Mounting storage volumes to locations outside of `/var/www/html`. **Data inside the main folder (`/var/www/html`) will be overridden/removed during installation and upgrades, unless listed in [upgrade.exclude](https://github.com/nextcloud/docker/blob/master/upgrade.exclude).** The additional volumes officially supported are already in that list, but custom volumes will need to be added by you. We suggest mounting custom storage volumes outside of `/var/www/html` and if possible read-only so that making this adjustment is unnecessary. If you must do so, however, you may build a custom image with a modified `/upgrade.exclude` file that incorporates your custom volume(s). ## Running as an arbitrary user / file permissions / changing the default container user The default user within a container is root (uid = 0). By default, processes inside the container will expect to have root privileges. Network services will drop privileges and use `www-data` to serve requests. Depending on your volumes configuration, this can lead to permission issues. You can address this by running the container with a different default user. When changing the default user, the image will no longer assume it has root privileges and will run all processes under the specified uid. To accomplish this, use the `--user` / `user` option in your container environment. See: - https://docs.docker.com/engine/containers/run/#user - https://github.com/docker-library/docs/tree/master/php#running-as-an-arbitrary-user - https://docs.podman.io/en/stable/markdown/podman-run.1.html#user-u-user-group ## Accessing the Nextcloud command-line interface (`occ`) To use the [Nextcloud command-line interface](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/occ_command.html) (aka. `occ` command): ```console $ docker exec -it --user www-data CONTAINER_ID php occ ``` or for docker compose: ```console $ docker compose exec --user www-data app php occ ``` or even shorter: ```console $ docker compose exec -u33 app ./occ ``` Note: substitute `82` for `33` if using the Alpine-based images. ## Viewing the Nextcloud configuration (`config.php`) The image takes advantage of Nextcloud's [Multiple config.php support](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/config_sample_php_parameters.html#multiple-config-php-file) to inject auto configuration environment variables and set image specific config values. This means that merely viewing your `config.php` will not give you an accurate view of your running config. Instead, you should use Nextcloud's [`occ config:list system` command](https://docs.nextcloud.com/server/latest/admin_manual/occ_command.html#config-commands-label) to get get a complete view of your merged configuration. This has the added benefit of automatically omitting sensitive values such as passwords and secrets from the output by default (e.g. useful for shared publicly or assisting others when troubleshooting or reporting a bug). ```console $ docker compose exec -u33 app ./occ config:list system ``` The `--private` flag can also be specified, in order to output all configuration values including passwords and secrets. ## Auto configuration via environment variables The Nextcloud image supports auto configuration of the Nextcloud Server installation via environment variables. You can preconfigure everything that would otherwise be prompted for by the Nextcloud Installation Wizard (as well as a few other key parameters relevant to initial installation). ### Database parameters To enable auto configuration, define your database connection via the following environment variables. If you set any group of values (i.e. all of `MYSQL_DATABASE`, `MYSQL_USER`, `MYSQL_PASSWORD`, `MYSQL_HOST`), they will not be requested via the Installation Wizard on first run. You must specify all of the environment variables for a given database or the database environment variables defaults to SQLITE. ONLY use one database type! __SQLite__: - `SQLITE_DATABASE` Name of the database using sqlite __MYSQL/MariaDB__: - `MYSQL_DATABASE` Name of the database using mysql / mariadb. - `MYSQL_USER` Username for the database using mysql / mariadb. - `MYSQL_PASSWORD` Password for the database user using mysql / mariadb. - `MYSQL_HOST` Hostname of the database server using mysql / mariadb. __PostgreSQL__: - `POSTGRES_DB` Name of the database using postgres. - `POSTGRES_USER` Username for the database using postgres. - `POSTGRES_PASSWORD` Password for the database user using postgres. - `POSTGRES_HOST` Hostname of the database server using postgres. As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. See [Docker secrets](#docker-secrets) section below for details. ### Initial admin account If you specify all the variables for your database type (above), you can also auto configure your initial admin user and password (only works if you set both): - `NEXTCLOUD_ADMIN_USER` Name of the Nextcloud admin user. - `NEXTCLOUD_ADMIN_PASSWORD` Password for the Nextcloud admin user. Specifying a complete database and admin credential config set at initial deployment will result in a fully automated installation (i.e. bypassing the web-based Nextcloud Installation Wizard). Addition parameters may also be set at installation time and are described below. ### Custom Data directory (`datadirectory`) If you don't want to use the default data directory (`datadirectory`) location, you can set a custom one: - `NEXTCLOUD_DATA_DIR` (default: `/var/www/html/data`) Configures the data directory where nextcloud stores all files from the users. ### Trusted domains (`trusted_domains`) One or more trusted domains can be set through environment variable, too. They will be added to the configuration after install. - `NEXTCLOUD_TRUSTED_DOMAINS` (not set by default) Optional space-separated list of domains ### Image specific The install and update script is only triggered when a default command is used (`apache-foreground` or `php-fpm`). If you use a custom command you have to enable the install / update with - `NEXTCLOUD_UPDATE` (default: `0`) You might want to make sure the htaccess is up to date after each container update. Especially on multiple swarm nodes as any discrepancy will make your server unusable. - `NEXTCLOUD_INIT_HTACCESS` (not set by default) Set it to true to enable run `occ maintenance:update:htaccess` after container initialization. ### Redis Memory Caching To use Redis for memory caching as well as PHP session storage, specify the following values and also add a [Redis](https://hub.docker.com/_/redis/) container to your stack. See the [examples](https://github.com/nextcloud/docker/tree/master/.examples) for further instructions. - `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. - `REDIS_HOST_USER` (not set by default) Optional username for Redis, only use for external Redis servers that require a user. - `REDIS_HOST_PASSWORD` (not set by default) Redis password Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/caching_configuration.html) for more information. ### E-mail (SMTP) Configuration To use an external SMTP server, you have to provide the connection details. Note that if you configure these values via Docker, you should **not** use the Nexcloud Web UI to configure external SMTP server parameters. Conversely, if you prefer to use the Web UI, do **not** set these variables here (because these variables will override whatever you attempt to set in the Web UI for these parameters). To configure Nextcloud to use SMTP add: - `SMTP_HOST` (not set by default): The hostname of the SMTP server. - `SMTP_SECURE` (empty by default): Set to `ssl` to use SSL, or `tls` to use STARTTLS. - `SMTP_PORT` (default: `465` for SSL and `25` for non-secure connections): Optional port for the SMTP connection. Use `587` for an alternative port for STARTTLS. - `SMTP_AUTHTYPE` (default: `LOGIN`): The method used for authentication. Use `PLAIN` if no authentication is required. - `SMTP_NAME` (empty by default): The username for the authentication. - `SMTP_PASSWORD` (empty by default): The password for the authentication. - `MAIL_FROM_ADDRESS` (not set by default): Set the local-part for the 'from' field in the emails sent by Nextcloud. - `MAIL_DOMAIN` (not set by default): Set a different domain for the emails than the domain where Nextcloud is installed. At a minimum, the `SMTP_HOST`, `MAIL_FROM_ADDRESS` and `MAIL_DOMAIN` parameters must be defined. Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/email_configuration.html) for other values to configure SMTP. ### Object Storage (Primary Storage) By default, Nextcloud stores all files in `/var/www/html/data/` (or whatever custom data directory you've configured). Nextcloud also allows the use of object storages (like OpenStack Swift or any Amazon S3-compatible implementation) as *Primary Storage*. This semi-replaces the default storage of files in the data directory. Note: This data directory might still be used for compatibility reasons and still needs to exist. Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/primary_storage.html) for more information. To use an external S3 compatible object store as primary storage, set the following variables: - `OBJECTSTORE_S3_BUCKET`: The name of the bucket that Nextcloud should store the data in - `OBJECTSTORE_S3_REGION`: The region that the S3 bucket resides in - `OBJECTSTORE_S3_HOST`: The hostname of the object storage server - `OBJECTSTORE_S3_PORT`: The port that the object storage server is being served over - `OBJECTSTORE_S3_KEY`: AWS style access key - `OBJECTSTORE_S3_SECRET`: AWS style secret access key - `OBJECTSTORE_S3_STORAGE_CLASS`: The storage class to use when adding objects to the bucket - `OBJECTSTORE_S3_SSL` (default: `true`): Whether or not SSL/TLS should be used to communicate with object storage server - `OBJECTSTORE_S3_USEPATH_STYLE` (default: `false`): Not required for AWS S3 - `OBJECTSTORE_S3_LEGACYAUTH` (default: `false`): Not required for AWS S3 - `OBJECTSTORE_S3_OBJECT_PREFIX` (default: `urn:oid:`): Prefix to prepend to the fileid - `OBJECTSTORE_S3_AUTOCREATE` (default: `true`): Create the container if it does not exist - `OBJECTSTORE_S3_SSE_C_KEY` (not set by default): Base64 encoded key with a maximum length of 32 bytes for server side encryption (SSE-C) Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/primary_storage.html#simple-storage-service-s3) for more information. To use an external OpenStack Swift object store as primary storage, set the following variables: - `OBJECTSTORE_SWIFT_URL`: The Swift identity (Keystone) endpoint - `OBJECTSTORE_SWIFT_AUTOCREATE` (default: `false`): Whether or not Nextcloud should automatically create the Swift container - `OBJECTSTORE_SWIFT_USER_NAME`: Swift username - `OBJECTSTORE_SWIFT_USER_PASSWORD`: Swift user password - `OBJECTSTORE_SWIFT_USER_DOMAIN` (default: `Default`): Swift user domain - `OBJECTSTORE_SWIFT_PROJECT_NAME`: OpenStack project name - `OBJECTSTORE_SWIFT_PROJECT_DOMAIN` (default: `Default`): OpenStack project domain - `OBJECTSTORE_SWIFT_SERVICE_NAME` (default: `swift`): Swift service name - `OBJECTSTORE_SWIFT_REGION`: Swift endpoint region - `OBJECTSTORE_SWIFT_CONTAINER_NAME`: Swift container (bucket) that Nextcloud should store the data in Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/primary_storage.html#openstack-swift) for more information. ### PHP Configuration To customize PHP limits you can change the following variables: - `PHP_MEMORY_LIMIT` (default `512M`) This sets the maximum amount of memory in bytes that a script is allowed to allocate. This is meant to help prevent poorly written scripts from eating up all available memory but it can prevent normal operation if set too tight. - `PHP_UPLOAD_LIMIT` (default `512M`) This sets the upload limit (`post_max_size` and `upload_max_filesize`) for big files. Note that you may have to change other limits depending on your client, webserver or operating system. Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html) for more information. - `PHP_OPCACHE_MEMORY_CONSUMPTION` (default `128`) This sets the `opcache.memory_consumption` value. It's the size of the shared memory storage used by OPcache, in megabytes. ### Apache Configuration To customize the Apache max file upload limit you can change the following variable: - `APACHE_BODY_LIMIT` (default `1073741824` [1GiB]) This restricts the total size of the HTTP request body sent from the client. It specifies the number of _bytes_ that are allowed in a request body. A value of **0** means **unlimited**. Check the [Nextcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_files/big_file_upload_configuration.html#apache) for more information. ### Using the image behind a reverse proxy and specifying the server host and protocol By default, the apache image will replace the remote addr (IP address visible to Nextcloud) with the IP address from `X-Real-IP` if the request is coming from a reverse proxy in `10.0.0.0/8`, `172.16.0.0/12` or `192.168.0.0/16`. If you want Nextcloud to pick up the server host (`HTTP_X_FORWARDED_HOST`), protocol (`HTTP_X_FORWARDED_PROTO`) and client IP (`HTTP_X_FORWARDED_FOR`) from a trusted proxy, then disable rewrite IP and add the reverse proxy's IP address to `TRUSTED_PROXIES`. - `APACHE_DISABLE_REWRITE_IP` (not set by default): Set to 1 to disable rewrite IP. - `TRUSTED_PROXIES` (empty by default): A space-separated list of trusted proxies. CIDR notation is supported for IPv4. If the `TRUSTED_PROXIES` approach does not work for you, try using fixed values for overwrite parameters. - `OVERWRITEHOST` (empty by default): Set the hostname of the proxy. Can also specify a port. - `OVERWRITEPROTOCOL` (empty by default): Set the protocol of the proxy, http or https. - `OVERWRITECLIURL` (empty by default): Set the cli url of the proxy (e.g. https://mydnsname.example.com) - `OVERWRITEWEBROOT` (empty by default): Set the absolute path of the proxy. - `OVERWRITECONDADDR` (empty by default): Regex to overwrite the values dependent on the remote address. - `FORWARDED_FOR_HEADERS` (empty by default): HTTP headers with the original client IP address Check the [Nexcloud documentation](https://docs.nextcloud.com/server/latest/admin_manual/configuration_server/reverse_proxy_configuration.html) for more details. Keep in mind that once set at install time, removing these environment variables later won't remove them from your `config/config.php`, due to how Nextcloud generates and merges the initial configuration at installation time. They can still, however, be removed manually from your `config/config.php`. ### Handling `Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile` (aka: Auto configuration and Nextcloud updates) The image comes with special config files for Nextcloud that set parameters specific to containerized usage (e.g. `upgrade-disable-web.config.php`) or enable auto configuration via environment variables (e.g. `reverse-proxy.config.php`). Not keeping these files up-to-date when this warning appears may cause certain auto configuration environment variables to be ignored or the image to not work as documented or expected. During a fresh Nextcloud installation, the latest version (from the image) of these files are copied into `/var/www/html/config` so that they are stored within your container's persistent storage and picked up by Nextcloud alongside your local configuration. The copied files, however, are **not** automatically overwritten whenever you update your environment with a newer Nextcloud image. This is to prevent local changes in `/var/www/html/config` from being unexpectedly overwritten. This may lead to your image-specific configuration files becoming outdated and image functionality not matching that which is documented. Within each image, the latest version of these config files are located in `/usr/src/nextcloud/config`. A warning will be generated in the container log output when outdated image-specific configuration files are detected at startup in a running container. When you see this warning, you should manually compare (or copy) the files from `/usr/src/nextcloud/config` to `/var/www/html/config`. A command to copy these configs would e.g. be: ```console docker exec sh -c "cp /usr/src/nextcloud/config/*.php /var/www/html/config" ``` As long as you have not modified any of the provided config files in `/var/www/html/config` (other than `config.php`) or only added new ones with names that do not conflict with the image specific ones, copying the new ones into place should be safe (but check the source path `/usr/src/nextcloud/config` for any newly named config files to avoid new overlaps just in case). ## Auto configuration via hook folders There are 5 hooks - `pre-installation` Executed before the Nextcloud is installed/initiated - `post-installation` Executed after the Nextcloud is installed/initiated - `pre-upgrade` Executed before the Nextcloud is upgraded - `post-upgrade` Executed after the Nextcloud is upgraded - `before-starting` Executed before the Nextcloud starts To use the hooks triggered by the `entrypoint` script, either - Added your script(s) to the individual of the hook folder(s), which are located at the path `/docker-entrypoint-hooks.d` in the container - Use volume(s) if you want to use script from the host system inside the container, see example. **Note:** Only the script(s) located in a hook folder (not sub-folders), ending with `.sh` and marked as executable, will be executed. **Example:** Mount using volumes ```yaml ... app: image: nextcloud:stable volumes: - ./app-hooks/pre-installation:/docker-entrypoint-hooks.d/pre-installation - ./app-hooks/post-installation:/docker-entrypoint-hooks.d/post-installation - ./app-hooks/pre-upgrade:/docker-entrypoint-hooks.d/pre-upgrade - ./app-hooks/post-upgrade:/docker-entrypoint-hooks.d/post-upgrade - ./app-hooks/before-starting:/docker-entrypoint-hooks.d/before-starting ... ``` # Running this image with `docker compose` The easiest way to get a fully featured and functional setup is using a `compose.yaml` file. There are too many different possibilities to setup your system, so here are only some examples of what you have to look for. At first, make sure you have chosen the right base image (fpm or apache) and added features you wanted (see below). In every case, you would want to add a database container and docker volumes to get easy access to your persistent data. When you want to have your server reachable from the internet, adding HTTPS-encryption is mandatory! See below for more information. ## Base version - apache This version will use the apache variant and add a MariaDB container. The volumes are set to keep your data persistent. This setup provides **no TLS encryption** and is intended to run behind a proxy. Make sure to pass in values for `MYSQL_ROOT_PASSWORD` and `MYSQL_PASSWORD` variables before you run this setup. ```yaml services: # Note: MariaDB is external service. You can find more information about the configuration here: # https://hub.docker.com/_/mariadb db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: mariadb:lts restart: always command: --transaction-isolation=READ-COMMITTED volumes: - db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD= - MYSQL_PASSWORD= - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud restart: always ports: - 8080:80 depends_on: - redis - db volumes: - nextcloud:/var/www/html environment: - MYSQL_PASSWORD= - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - MYSQL_HOST=db volumes: nextcloud: db: ``` Then run `docker compose up -d`, now you can access Nextcloud at http://localhost:8080/ from your host system. ## Base version - FPM When using the FPM image, you need another container that acts as web server on port 80 and proxies the requests to the Nextcloud container. In this example a simple nginx container is combined with the Nextcloud-fpm image and a MariaDB database container. The data is stored in docker volumes. The nginx container also needs access to static files from your Nextcloud installation. It gets access to all the volumes mounted to Nextcloud via the `volumes` option. The configuration for nginx is stored in the configuration file `nginx.conf`, that is mounted into the container. An example can be found in the examples section [here](https://github.com/nextcloud/docker/tree/master/.examples). This setup provides **no TLS encryption** and is intended to run behind a reverse proxy. Make sure to pass in values for `MYSQL_ROOT_PASSWORD` and `MYSQL_PASSWORD` variables before you run this setup. ```yaml services: # Note: MariaDB is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/mariadb db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: mariadb:lts restart: always command: --transaction-isolation=READ-COMMITTED volumes: - db:/var/lib/mysql environment: - MYSQL_ROOT_PASSWORD= - MYSQL_PASSWORD= - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud:fpm restart: always depends_on: - redis - db volumes: - nextcloud:/var/www/html environment: - MYSQL_PASSWORD= - MYSQL_DATABASE=nextcloud - MYSQL_USER=nextcloud - MYSQL_HOST=db # Note: Nginx is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/nginx/ web: image: nginx:alpine-slim restart: always ports: - 8080:80 depends_on: - app volumes: # https://docs.nextcloud.com/server/latest/admin_manual/installation/nginx.html - ./nginx.conf:/etc/nginx/nginx.conf:ro volumes_from: - app volumes: nextcloud: db: ``` Then run `docker compose up -d`, now you can access Nextcloud at http://localhost:8080/ from your host system. # Docker Secrets As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to some the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Docker secrets stored in `/run/secrets/` files. Currently, this is only supported for `NEXTCLOUD_ADMIN_PASSWORD`, `NEXTCLOUD_ADMIN_USER`, `MYSQL_DATABASE`, `MYSQL_PASSWORD`, `MYSQL_USER`, `POSTGRES_DB`, `POSTGRES_PASSWORD`, `POSTGRES_USER`, `REDIS_HOST_PASSWORD`, `SMTP_PASSWORD`, `OBJECTSTORE_S3_KEY`, and `OBJECTSTORE_S3_SECRET`. If you set any group of `_FILE` based values (i.e. all of `MYSQL_DATABASE_FILE`, `MYSQL_USER_FILE`, `MYSQL_PASSWORD_FILE`), their non-`_FILE` counterparts will be ignored (`MYSQL_DATABASE`, `MYSQL_USER`, `MYSQL_PASSWORD`). Any files containing secrets must be readable by the UID the container is running Nextcloud as (i.e. `www-data` / `33`). Example: ```yaml services: # Note: PostgreSQL is external service. You can find more information about the configuration here: # https://hub.docker.com/_/postgres db: # Note: Check the recommend version here: https://docs.nextcloud.com/server/latest/admin_manual/installation/system_requirements.html#server image: postgres:alpine restart: always volumes: - db:/var/lib/postgresql/data environment: - POSTGRES_DB_FILE=/run/secrets/postgres_db - POSTGRES_USER_FILE=/run/secrets/postgres_user - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password secrets: - postgres_db - postgres_password - postgres_user # Note: Redis is an external service. You can find more information about the configuration here: # https://hub.docker.com/_/redis redis: image: redis:alpine restart: always app: image: nextcloud restart: always ports: - 8080:80 volumes: - nextcloud:/var/www/html environment: - POSTGRES_HOST=db - POSTGRES_DB_FILE=/run/secrets/postgres_db - POSTGRES_USER_FILE=/run/secrets/postgres_user - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password - NEXTCLOUD_ADMIN_PASSWORD_FILE=/run/secrets/nextcloud_admin_password - NEXTCLOUD_ADMIN_USER_FILE=/run/secrets/nextcloud_admin_user depends_on: - redis - db secrets: - nextcloud_admin_password - nextcloud_admin_user - postgres_db - postgres_password - postgres_user volumes: db: nextcloud: secrets: nextcloud_admin_password: file: ./nextcloud_admin_password.txt # put admin password in this file nextcloud_admin_user: file: ./nextcloud_admin_user.txt # put admin username in this file postgres_db: file: ./postgres_db.txt # put postgresql db name in this file postgres_password: file: ./postgres_password.txt # put postgresql password in this file postgres_user: file: ./postgres_user.txt # put postgresql username in this file ``` # Make your Nextcloud available from the internet Until here, your Nextcloud is just available from your docker host. If you want your Nextcloud available from the internet adding SSL encryption is mandatory. ## HTTPS - SSL encryption There are many different possibilities to introduce encryption depending on your setup. We recommend using a reverse proxy in front of your Nextcloud installation. Your Nextcloud will only be reachable through the proxy, which encrypts all traffic to the clients. You can mount your manually generated certificates to the proxy or use a fully automated solution which generates and renews the certificates for you. In our [examples](https://github.com/nextcloud/docker/tree/master/.examples) section we have an example for a fully automated setup using a reverse proxy, a container for [Let's Encrypt](https://letsencrypt.org/) certificate handling, database and Nextcloud. It uses the popular [nginx-proxy](https://github.com/nginx-proxy/nginx-proxy) and [acme-companion](https://github.com/nginx-proxy/acme-companion) containers. Please check the according documentations before using this setup. # First use When you first access your Nextcloud, the setup wizard will appear and ask you to choose an administrator account username, password and the database connection (unless of course you've provided all the necessary auto-config config values ahead of time). For the database use `db` as host and `nextcloud` as table and user name. Also enter the password you chose in your `compose.yaml` file. # Update to a newer version Updating the Nextcloud container is done by pulling the new image, throwing away the old container and starting the new one. **It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16.** Since all data is stored in volumes, nothing gets lost. The startup script will check for the version in your volume and the installed docker version. If it finds a mismatch, it automatically starts the upgrade process. Don't forget to add all the volumes to your new container, so it works as expected. ```console $ docker pull nextcloud $ docker stop $ docker rm $ docker run -d nextcloud ``` Beware that you have to run the same command with the options that you used to initially start your Nextcloud. That includes volumes, port mapping. When using docker compose your compose file takes care of your configuration, so you just have to run: ```console $ docker compose pull $ docker compose up -d ``` # Adding Features A lot of people want to use additional functionality inside their Nextcloud installation. If the image does not include the packages you need, you can easily build your own image on top of it. Start your derived image with the `FROM` statement and add whatever you like. ```dockerfile FROM nextcloud:apache RUN ... ``` The [examples folder](https://github.com/nextcloud/docker/blob/master/.examples) gives a few examples on how to add certain functionalities, like including the cron job, smb-support or imap-authentication. If you use your own Dockerfile, you need to configure your docker compose file accordingly. Switch out the `image` option with `build`. You have to specify the path to your Dockerfile. (in the example it's in the same directory next to the `compose.yaml` file) ```yaml app: build: . restart: always depends_on: - db volumes: - data:/var/www/html/data - config:/var/www/html/config - apps:/var/www/html/apps ``` If you intend to use another command to run the image, make sure that you set `NEXTCLOUD_UPDATE=1` in your Dockerfile. Otherwise the installation and update will not work. ```dockerfile FROM nextcloud:apache ... ENV NEXTCLOUD_UPDATE=1 CMD ["/usr/bin/supervisord"] ``` **Updating** your own derived image is also very simple. When a new version of the Nextcloud image is available run: ```console docker build -t your-name --pull . docker run -d your-name ``` or for docker compose: ```console docker compose build --pull docker compose up -d ``` The `--pull` option tells docker to look for new versions of the base image. Then the build instructions inside your `Dockerfile` are run on top of the new image. # Migrating an existing installation You're already using Nextcloud and want to switch to docker? Great! Here are some things to look out for: 1. Define your whole Nextcloud infrastructure in a `compose.yaml` file and run it with `docker compose up -d` to get the base installation, volumes and database. Work from there. 2. Restore your database from a mysqldump (db is the name of your database container / service name) - To import from a MySQL dump use the following commands ```console docker compose cp ./database.dmp db:/dmp docker compose exec db sh -c "mysql --user USER --password PASSWORD nextcloud < /dmp" docker compose exec db rm /dmp ``` - To import from a PostgreSQL dump use to following commands ```console docker compose cp ./database.dmp db:/dmp docker compose exec db sh -c "psql -U USER --set ON_ERROR_STOP=on nextcloud < /dmp" docker compose exec db rm /dmp ``` 3. Edit your config.php 1. Set database connection - In case of MySQL database ```php 'dbhost' => 'db:3306', ``` - In case of PostgreSQL database ```php 'dbhost' => 'db:5432', ``` 2. Make sure you have no configuration for the `apps_paths`. Delete lines like these ```php 'apps_paths' => array ( 0 => array ( 'path' => OC::$SERVERROOT.'/apps', 'url' => '/apps', 'writable' => true, ), ), ``` 3. Make sure to have the `apps` directory non writable and the `custom_apps` directory writable ```php 'apps_paths' => array ( 0 => array ( 'path' => '/var/www/html/apps', 'url' => '/apps', 'writable' => false, ), 1 => array ( 'path' => '/var/www/html/custom_apps', 'url' => '/custom_apps', 'writable' => true, ), ), ``` 4. Make sure your data directory is set to /var/www/html/data ```php 'datadirectory' => '/var/www/html/data', ``` 4. Copy your data (`app` is the name of your Nextcloud container / service name): ```console docker compose cp ./data/ app:/var/www/html/ docker compose exec app chown -R www-data:www-data /var/www/html/data docker compose cp ./theming/ app:/var/www/html/ docker compose exec app chown -R www-data:www-data /var/www/html/theming docker compose cp ./config/config.php app:/var/www/html/config docker compose exec app chown -R www-data:www-data /var/www/html/config ``` If you want to preserve the metadata of your files like timestamps, copy the data directly on the host to the named volume using plain `cp` like this: ```console cp --preserve --recursive ./data/ /path/to/nextcloudVolume/data ``` 5. Copy only the custom apps you use (or simply redownload them from the web interface): ```console docker compose cp ./custom_apps/ app:/var/www/html/ docker compose exec app chown -R www-data:www-data /var/www/html/custom_apps ``` ## Migrating from a non-Alpine image to an Alpine image If you already use one of our non-Alpine images, but want to switch to an Alpine-based image, you may experience permissions problems with your existing volumes. This is because the Alpine images uses a different user ID for `www-data`. So, you must change the ownership of the `/var/www/html` (or `$NEXTCLOUD_DATA_DIR`) folder to be compatible with Alpine: ```console docker exec container-name chown -R www-data:root /var/www/html ``` After changing the permissions, restart the container and the permission errors should disappear. # Reporting bugs or suggesting enhancements If you believe you've found a bug in the image itself (or have an enhancement idea specific to the image), please [search for already reported bugs and enhancement ideas](https://github.com/nextcloud/docker/issues). If there is a relevant existing open issue, you can either add to the discussion there or upvote it to indicate you're impacted by (or interested in) the same issue. If you believe you've found a new bug, please create a new Issue so that others can try to reproduce it and remediation can be tracked. ![GitHub Issues or Pull Requests](https://img.shields.io/github/issues/nextcloud/docker?label=Open%20Issues) ![GitHub Issues or Pull Requests by label](https://img.shields.io/github/issues/nextcloud/docker/bug?style=flat&label=Bug%20Reports&color=red) ![GitHub Issues or Pull Requests by label](https://img.shields.io/github/issues/nextcloud/docker/enhancement?style=flat&label=Enhancement%20Ideas&color=green) ![GitHub Issues or Pull Requests by label](https://img.shields.io/github/issues/nextcloud/docker/good%20first%20issue?style=flat&label=Good%20First%20Issues) **If you have any problems or usage questions while using the image, please ask for assistance on the [Nextcloud Community Help Forum](https://help.nextcloud.com)** rather than reporting them as "bugs" (unless they really are bugs of course). This helps the maintainers (who are volunteers) remain focused on making the image better (rather than responding solely to one-on-one support issues). (Tip: Some of the maintainers are also regular responders to help requests on the [Nextcloud Community Help Forum](https://help.nextcloud.com).) [![Discourse Users](https://img.shields.io/discourse/users?server=https%3A%2F%2Fhelp.nextcloud.com&label=Community%20Forum&color=blue&link=https%3A%2F%2Fhelp.nextcloud.com%2F)](https://help.nextcloud.com/) [![Discourse Posts](https://img.shields.io/discourse/posts?server=https%3A%2F%2Fhelp.nextcloud.com&label=Community%20Forum&color=blue&link=https%3A%2F%2Fhelp.nextcloud.com%2F)](https://help.nextcloud.com/) Most Nextcloud Server matters are covered in the official [Nextcloud Admin Manual](https://docs.nextcloud.com/server/latest/admin_manual/) or the [other official Nextcloud documentation](https://docs.nextcloud.com) (which are routinely updated). ================================================ FILE: docker-cron.sh ================================================ #!/bin/sh set -eu exec busybox crond -f -L /dev/stdout ================================================ FILE: docker-entrypoint.sh ================================================ #!/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 "$user" -s /bin/sh -c "$1" else sh -c "$1" fi } # Execute all executable files in a given directory in alphanumeric order run_path() { local hook_folder_path="/docker-entrypoint-hooks.d/$1" local return_code=0 local found=0 echo "=> Searching for hook scripts (*.sh) to run, located in the folder \"${hook_folder_path}\"" if ! [ -d "${hook_folder_path}" ] || directory_empty "${hook_folder_path}"; then echo "==> Skipped: the \"$1\" folder is empty (or does not exist)" return 0 fi find "${hook_folder_path}" -maxdepth 1 -iname '*.sh' '(' -type f -o -type l ')' -print | sort | ( while read -r script_file_path; do if ! [ -x "${script_file_path}" ]; then echo "==> The script \"${script_file_path}\" was skipped, because it lacks the executable flag" found=$((found-1)) continue fi echo "==> Running the script (cwd: $(pwd)): \"${script_file_path}\"" found=$((found+1)) run_as "${script_file_path}" || return_code="$?" if [ "${return_code}" -ne "0" ]; then echo "==> Failed at executing script \"${script_file_path}\". Exit code: ${return_code}" exit 1 fi echo "==> Finished executing the script: \"${script_file_path}\"" done if [ "$found" -lt "1" ]; then echo "==> Skipped: the \"$1\" folder does not contain any valid scripts" else echo "=> Completed executing scripts in the \"$1\" folder" fi ) } # usage: file_env VAR [DEFAULT] # ie: file_env 'XYZ_DB_PASSWORD' 'example' # (will allow for "$XYZ_DB_PASSWORD_FILE" to fill in the value of # "$XYZ_DB_PASSWORD" from a file, especially for Docker's secrets feature) file_env() { local var="$1" local fileVar="${var}_FILE" local def="${2:-}" local varValue=$(env | grep -E "^${var}=" | sed -E -e "s/^${var}=//") local fileVarValue=$(env | grep -E "^${fileVar}=" | sed -E -e "s/^${fileVar}=//") if [ -n "${varValue}" ] && [ -n "${fileVarValue}" ]; then echo >&2 "error: both $var and $fileVar are set (but are exclusive)" exit 1 fi if [ -n "${varValue}" ]; then export "$var"="${varValue}" elif [ -n "${fileVarValue}" ]; then export "$var"="$(cat "${fileVarValue}")" elif [ -n "${def}" ]; then export "$var"="$def" fi unset "$fileVar" } if expr "$1" : "apache" 1>/dev/null; then if [ -n "${APACHE_DISABLE_REWRITE_IP+x}" ]; then a2disconf remoteip fi fi if expr "$1" : "apache" 1>/dev/null || [ "$1" = "php-fpm" ] || [ "${NEXTCLOUD_UPDATE:-0}" -eq 1 ]; then uid="$(id -u)" gid="$(id -g)" if [ "$uid" = '0' ]; then case "$1" in apache2*) user="${APACHE_RUN_USER:-www-data}" group="${APACHE_RUN_GROUP:-www-data}" # strip off any '#' symbol ('#1000' is valid syntax for Apache) user="${user#'#'}" group="${group#'#'}" ;; *) # php-fpm user='www-data' group='www-data' ;; esac else user="$uid" group="$gid" fi if [ -n "${REDIS_HOST+x}" ]; then echo "Configuring Redis as session handler" { file_env REDIS_HOST_PASSWORD echo 'session.save_handler = redis' # check if redis host is an unix socket path if [ "$(echo "$REDIS_HOST" | cut -c1-1)" = "/" ]; then if [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"unix://${REDIS_HOST}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"unix://${REDIS_HOST}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"unix://${REDIS_HOST}\"" fi # check if redis password has been set elif [ -n "${REDIS_HOST_PASSWORD+x}" ]; then if [ -n "${REDIS_HOST_USER+x}" ]; then echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth[]=${REDIS_HOST_USER}&auth[]=${REDIS_HOST_PASSWORD}\"" else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}?auth=${REDIS_HOST_PASSWORD}\"" fi else echo "session.save_path = \"tcp://${REDIS_HOST}:${REDIS_HOST_PORT:=6379}\"" fi echo "redis.session.locking_enabled = 1" echo "redis.session.lock_retries = -1" # redis.session.lock_wait_time is specified in microseconds. # Wait 10ms before retrying the lock rather than the default 2ms. echo "redis.session.lock_wait_time = 10000" } > /usr/local/etc/php/conf.d/redis-session.ini fi # If another process is syncing the html folder, wait for # it to be done, then escape initalization. ( if ! flock -n 9; then # If we couldn't get it immediately, show a message, then wait for real echo "Another process is initializing Nextcloud. Waiting..." flock 9 fi 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 if [ "${image_version%%.*}" -gt "$((${installed_version%%.*} + 1))" ]; then echo "Can't start Nextcloud because upgrading from $installed_version to $image_version is not supported." echo "It is only possible to upgrade one major version at a time. For example, if you want to upgrade from version 14 to 16, you will have to upgrade from version 14 to 15, then from 15 to 16." exit 1 fi 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 $user:$group" 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 rsync $rsync_options --include '/version.php' --exclude '/*' /usr/src/nextcloud/ /var/www/html/ # Install if [ "$installed_version" = "0.0.0.0" ]; then echo "New nextcloud instance" file_env NEXTCLOUD_ADMIN_PASSWORD file_env NEXTCLOUD_ADMIN_USER install=false 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_DATA_DIR+x}" ]; then # shellcheck disable=SC2016 install_options=$install_options' --data-dir "$NEXTCLOUD_DATA_DIR"' fi file_env MYSQL_DATABASE file_env MYSQL_PASSWORD file_env MYSQL_USER file_env POSTGRES_DB file_env POSTGRES_PASSWORD file_env POSTGRES_USER 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 run_path pre-installation echo "Starting nextcloud installation" max_retries=10 try=0 until [ "$try" -gt "$max_retries" ] || run_as "php /var/www/html/occ maintenance:install $install_options" do echo "Retrying install..." try=$((try+1)) sleep 10s 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…" set -f # turn off glob 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 set +f # turn glob back on fi run_path post-installation fi fi # not enough specified to do a fully automated installation if [ "$install" = false ]; then echo "Next step: Access your instance to finish the web-based installation!" echo "Hint: You can specify NEXTCLOUD_ADMIN_USER and NEXTCLOUD_ADMIN_PASSWORD and the database variables _prior to first launch_ to fully automate initial installation." fi # Upgrade else run_path pre-upgrade 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 run_path post-upgrade fi echo "Initializing finished" fi # Update htaccess after init if requested if [ -n "${NEXTCLOUD_INIT_HTACCESS+x}" ] && [ "$installed_version" != "0.0.0.0" ]; then run_as 'php /var/www/html/occ maintenance:update:htaccess' fi ) 9> /var/www/html/nextcloud-init-sync.lock # warn if config files on persistent storage differ from the latest version of this image for cfgPath in /usr/src/nextcloud/config/*.php; do cfgFile=$(basename "$cfgPath") if [ "$cfgFile" != "config.sample.php" ] && [ "$cfgFile" != "autoconfig.php" ]; then if ! cmp -s "/usr/src/nextcloud/config/$cfgFile" "/var/www/html/config/$cfgFile"; then echo "Warning: /var/www/html/config/$cfgFile differs from the latest version of this image at /usr/src/nextcloud/config/$cfgFile" fi fi done run_path before-starting fi exec "$@" ================================================ FILE: generate-stackbrew-library.sh ================================================ #!/usr/bin/env bash set -Eeuo pipefail stable_channel='32.0.6' self="$(basename "$BASH_SOURCE")" cd "$(dirname "$(readlink -f "$BASH_SOURCE")")" # Get the most recent commit which modified any of "$@". fileCommit() { commit="$(git log -1 --format='format:%H' HEAD -- "$@")" if [ -z "$commit" ]; then # return some valid sha1 hash to make bashbrew happy echo '0000000000000000000000000000000000000000' else echo "$commit" fi } # Get the most recent commit which modified "$1/Dockerfile" or any file that # the Dockerfile copies into the rootfs (with COPY). dockerfileCommit() { local dir="$1"; shift ( cd "$dir"; fileCommit Dockerfile \ $(awk ' toupper($1) == "COPY" { for (i = 2; i < NF; i++) print $i; } ' Dockerfile) ) } getArches() { local repo="$1"; shift local officialImagesUrl='https://github.com/docker-library/official-images/raw/master/library/' eval "declare -g -A parentRepoToArches=( $( find -maxdepth 3 -name 'Dockerfile' -exec awk ' toupper($1) == "FROM" && $2 !~ /^('"$repo"'|scratch|microsoft\/[^:]+)(:|$)/ { print "'"$officialImagesUrl"'" $2 } ' '{}' + \ | sort -u \ | xargs bashbrew cat --format '[{{ .RepoName }}:{{ .TagName }}]="{{ join " " .TagEntry.Architectures }}"' ) )" } getArches 'nextcloud' # Header. cat <<-EOH # This file is generated via https://github.com/nextcloud/docker/blob/$(fileCommit "$self")/$self Maintainers: Nextcloud (@nextcloud) GitRepo: https://github.com/nextcloud/docker.git EOH # prints "$2$1$3$1...$N" join() { local sep="$1"; shift local out; printf -v out "${sep//%/%%}%s" "$@" echo "${out#$sep}" } latest=$( cat latest.txt ) # Generate each of the tags. versions=( */ ) versions=( "${versions[@]%/}" ) for version in "${versions[@]}"; do variants=( $version/*/ ) variants=( $(for variant in "${variants[@]%/}"; do echo "$(basename "$variant")" done) ) for variant in "${variants[@]}"; do commit="$(dockerfileCommit "$version/$variant")" fullversion_with_extension="$( awk '$1 == "ENV" && $2 == "NEXTCLOUD_VERSION" { print $3; exit }' "$version/$variant/Dockerfile" )" fullversion="$( echo "$fullversion_with_extension" | grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}')" versionAliases=( ) versionPostfix="" if [ "$fullversion_with_extension" != "$fullversion" ]; then versionAliases=( "$fullversion_with_extension" ) versionPostfix="-$( echo "$fullversion_with_extension" | tr '[:upper:]' '[:lower:]' | grep -oE '(beta|rc|alpha)')" fi versionAliases+=( "$fullversion$versionPostfix" "${fullversion%.*}$versionPostfix" "${fullversion%.*.*}$versionPostfix" ) if [ "$fullversion_with_extension" = "$latest" ]; then versionAliases+=( "latest" ) fi if [ "$fullversion_with_extension" = "$stable_channel" ]; then versionAliases+=( "stable" "production" ) fi variantAliases=( "${versionAliases[@]/%/-$variant}" ) variantAliases=( "${variantAliases[@]//latest-}" ) if [ "$variant" = "apache" ]; then variantAliases+=( "${versionAliases[@]}" ) fi variantParent="$(awk 'toupper($1) == "FROM" { print $2 }' "$version/$variant/Dockerfile")" variantArches="${parentRepoToArches[$variantParent]}" cat <<-EOE Tags: $(join ', ' "${variantAliases[@]}") Architectures: $(join ', ' $variantArches) GitCommit: $commit Directory: $version/$variant EOE done done ================================================ FILE: latest.txt ================================================ 33.0.0 ================================================ FILE: stack.yml ================================================ version: '3.2' services: db: image: postgres restart: always volumes: - db:/var/lib/postgresql/data environment: - POSTGRES_DB=nextcloud - POSTGRES_USER=nextcloud - POSTGRES_PASSWORD=nextcloud app: image: nextcloud restart: always ports: - 8080:80 volumes: - nextcloud:/var/www/html environment: - POSTGRES_HOST=db - POSTGRES_DB=nextcloud - POSTGRES_USER=nextcloud - POSTGRES_PASSWORD=nextcloud depends_on: - db cron: image: nextcloud restart: always volumes: - nextcloud:/var/www/html entrypoint: /cron.sh depends_on: - db volumes: db: nextcloud: ================================================ FILE: update.sh ================================================ #!/usr/bin/env bash set -eo pipefail declare -A alpine_version=( [default]='3.23' ) declare -A debian_version=( [default]='trixie' ) declare -A php_version=( [31]='8.3' [32]='8.3' [default]='8.4' ) declare -A ftp_options=( [31]='--with-openssl-dir=/usr' [32]='--with-openssl-dir=/usr' [default]='--with-ftp-ssl' ) declare -A cmd=( [apache]='apache2-foreground' [fpm]='php-fpm' [fpm-alpine]='php-fpm' ) declare -A base=( [apache]='debian' [fpm]='debian' [fpm-alpine]='alpine' ) declare -A extras=( [apache]='\nRUN a2enmod headers rewrite remoteip ; \\\n { \\\n echo '\''RemoteIPHeader X-Real-IP'\''; \\\n echo '\''RemoteIPInternalProxy 10.0.0.0/8'\''; \\\n echo '\''RemoteIPInternalProxy 172.16.0.0/12'\''; \\\n echo '\''RemoteIPInternalProxy 192.168.0.0/16'\''; \\\n } > /etc/apache2/conf-available/remoteip.conf; \\\n a2enconf remoteip\n\n# set apache config LimitRequestBody\nENV APACHE_BODY_LIMIT 1073741824\nRUN { \\\n echo '\''LimitRequestBody ${APACHE_BODY_LIMIT}'\''; \\\n } > /etc/apache2/conf-available/apache-limits.conf; \\\n a2enconf apache-limits' [fpm]='' [fpm-alpine]='' ) declare -A crontab_int=( [default]='5' ) apcu_version="$( git ls-remote --tags https://github.com/krakjoe/apcu.git \ | cut -d/ -f3 \ | grep -viE -- 'rc|b' \ | sed -E 's/^v//' \ | sort -V \ | tail -1 )" igbinary_version="$( git ls-remote --tags https://github.com/igbinary/igbinary.git \ | cut -d/ -f3 \ | grep -viE '[a-z]' \ | tr -d '^{}' \ | sort -V \ | tail -1 )" imagick_version="$( git ls-remote --tags https://github.com/imagick/imagick.git \ | cut -d/ -f3 \ | grep -viE '[a-z]' \ | tr -d '^{}' \ | sort -V \ | tail -1 )" memcached_version="$( git ls-remote --tags https://github.com/php-memcached-dev/php-memcached.git \ | cut -d/ -f3 \ | grep -viE -- 'rc|b' \ | sed -E 's/^[rv]//' \ | sort -V \ | tail -1 )" redis_version="$( git ls-remote --tags https://github.com/phpredis/phpredis.git \ | cut -d/ -f3 \ | grep -viE '[a-z]' \ | tr -d '^{}' \ | sort -V \ | tail -1 )" declare -A pecl_versions=( [APCu]="$apcu_version" [igbinary]="$igbinary_version" [imagick]="$imagick_version" [memcached]="$memcached_version" [redis]="$redis_version" ) variants=( apache fpm fpm-alpine ) min_version='31' # version_greater_or_equal A B returns whether A >= B function version_greater_or_equal() { [[ "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1" || "$1" == "$2" ]]; } function create_variant() { dir="$1/$variant" alpineVersion=${alpine_version[$version]-${alpine_version[default]}} debianVersion=${debian_version[$version]-${debian_version[default]}} ftp_options=${ftp_options[$version]-${ftp_options[default]}} phpVersion=${php_version[$version]-${php_version[default]}} crontabInt=${crontab_int[$version]-${crontab_int[default]}} url="https://github.com/nextcloud-releases/server/releases/download/v$fullversion/nextcloud-$fullversion.tar.bz2" ascUrl="https://github.com/nextcloud-releases/server/releases/download/v$fullversion/nextcloud-$fullversion.tar.bz2.asc" # Create the version+variant directory with a Dockerfile. mkdir -p "$dir" template="Dockerfile-${base[$variant]}.template" echo "# DO NOT EDIT: created by update.sh from $template" > "$dir/Dockerfile" cat "$template" >> "$dir/Dockerfile" echo "updating $fullversion [$1] $variant" # Replace the variables. sed -ri -e ' s/%%ALPINE_VERSION%%/'"$alpineVersion"'/g; s/%%DEBIAN_VERSION%%/'"$debianVersion"'/g; s/%%PHP_VERSION%%/'"$phpVersion"'/g; s/%%VARIANT%%/'"$variant"'/g; s/%%VERSION%%/'"$fullversion"'/g; s/%%DOWNLOAD_URL%%/'"$(sed -e 's/[\/&]/\\&/g' <<< "$url")"'/g; s/%%DOWNLOAD_URL_ASC%%/'"$(sed -e 's/[\/&]/\\&/g' <<< "$ascUrl")"'/g; s/%%CMD%%/'"${cmd[$variant]}"'/g; s|%%VARIANT_EXTRAS%%|'"${extras[$variant]}"'|g; s/%%APCU_VERSION%%/'"${pecl_versions[APCu]}"'/g; s|%%FTP_OPTIONS%%|'"$ftp_options"'|g; s/%%IGBINARY_VERSION%%/'"${pecl_versions[igbinary]}"'/g; s/%%IMAGICK_VERSION%%/'"${pecl_versions[imagick]}"'/g; s/%%MEMCACHED_VERSION%%/'"${pecl_versions[memcached]}"'/g; s/%%REDIS_VERSION%%/'"${pecl_versions[redis]}"'/g; s/%%CRONTAB_INT%%/'"$crontabInt"'/g; ' "$dir/Dockerfile" # Copy the shell scripts for name in entrypoint cron; do cp "docker-$name.sh" "$dir/$name.sh" done # Copy the upgrade.exclude cp upgrade.exclude "$dir/" # Copy the config directory cp -rT .config "$dir/config" # Remove Apache config if we're not an Apache variant. if [ "$variant" != "apache" ]; then rm "$dir/config/apache-pretty-urls.config.php" fi # Add variant to versions.json [ "${base[$variant]}" == "alpine" ] && baseVersion="$alpineVersion" || baseVersion="$debianVersion" versionVariantsJson="$(jq -e \ --arg version "$version" --arg variant "$variant" --arg base "${base[$variant]}" --arg baseVersion "$baseVersion" --arg phpVersion "$phpVersion" \ '.[$version].variants[$variant] = {"variant": $variant, "base": $base, "baseVersion": $baseVersion, "phpVersion": $phpVersion}' versions.json)" versionJson="$(jq -e \ --arg version "$version" --arg fullversion "$fullversion" --arg url "$url" --arg ascUrl "$ascUrl" --argjson variants "$versionVariantsJson" \ '.[$version] = {"branch": $version, "version": $fullversion, "url": $url, "ascUrl": $ascUrl, "variants": $variants[$version].variants}' versions.json)" printf '%s\n' "$versionJson" > versions.json } curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \ grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \ grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | \ sort -uV | \ tail -1 > latest.txt find . -maxdepth 1 -type d -regextype sed -regex '\./[[:digit:]]\+\.[[:digit:]]\+\(-rc\|-beta\|-alpha\)\?' -exec rm -r '{}' \; printf '%s' "{}" > versions.json fullversions=( $( curl -fsSL 'https://download.nextcloud.com/server/releases/' |tac|tac| \ grep -oE 'nextcloud-[[:digit:]]+(\.[[:digit:]]+){2}' | \ grep -oE '[[:digit:]]+(\.[[:digit:]]+){2}' | \ sort -urV ) ) versions=( $( printf '%s\n' "${fullversions[@]}" | cut -d. -f1 | sort -urV ) ) for version in "${versions[@]}"; do fullversion="$( printf '%s\n' "${fullversions[@]}" | grep -E "^$version" | head -1 )" if version_greater_or_equal "$version" "$min_version"; then for variant in "${variants[@]}"; do create_variant "$version" done fi done ================================================ FILE: upgrade.exclude ================================================ /config/ /data/ /custom_apps/ /themes/ /version.php /nextcloud-init-sync.lock ================================================ FILE: versions.json ================================================ { "33": { "branch": "33", "version": "33.0.0", "url": "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.tar.bz2", "ascUrl": "https://github.com/nextcloud-releases/server/releases/download/v33.0.0/nextcloud-33.0.0.tar.bz2.asc", "variants": { "apache": { "variant": "apache", "base": "debian", "baseVersion": "trixie", "phpVersion": "8.4" }, "fpm": { "variant": "fpm", "base": "debian", "baseVersion": "trixie", "phpVersion": "8.4" }, "fpm-alpine": { "variant": "fpm-alpine", "base": "alpine", "baseVersion": "3.23", "phpVersion": "8.4" } } }, "32": { "branch": "32", "version": "32.0.6", "url": "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.tar.bz2", "ascUrl": "https://github.com/nextcloud-releases/server/releases/download/v32.0.6/nextcloud-32.0.6.tar.bz2.asc", "variants": { "apache": { "variant": "apache", "base": "debian", "baseVersion": "trixie", "phpVersion": "8.3" }, "fpm": { "variant": "fpm", "base": "debian", "baseVersion": "trixie", "phpVersion": "8.3" }, "fpm-alpine": { "variant": "fpm-alpine", "base": "alpine", "baseVersion": "3.23", "phpVersion": "8.3" } } }, "31": { "branch": "31", "version": "31.0.14", "url": "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.tar.bz2", "ascUrl": "https://github.com/nextcloud-releases/server/releases/download/v31.0.14/nextcloud-31.0.14.tar.bz2.asc", "variants": { "apache": { "variant": "apache", "base": "debian", "baseVersion": "trixie", "phpVersion": "8.3" }, "fpm": { "variant": "fpm", "base": "debian", "baseVersion": "trixie", "phpVersion": "8.3" }, "fpm-alpine": { "variant": "fpm-alpine", "base": "alpine", "baseVersion": "3.23", "phpVersion": "8.3" } } } }