Sign inSign up

llaumgui/nextcloud-php

By llaumgui

•Updated 6 days ago

Repository with my Nextcloud php-fpm's Dockerfile

Image
Languages & frameworks
Web servers
0

6.2K

llaumgui/nextcloud-php repository overview

⁠PHP 8.4-nextcloud (PHP-FPM) on Debian (GLibC)

Author Build Status Docker Pulls Latest Version License


⚠ Warning: This image is a PHP-FPM container and does not include Nextcloud or a web server.

  • Nextcloud must be mounted separately via a Docker volume to allow web updates.
  • A web server like Apache⁠ is required to serve Nextcloud.

⁠Table of Contents


⁠Features

⁠s6-overlay integration

Use s6-overlay⁠ for:

  • Multi-process container management and customization.
  • Allows running custom scripts.
  • Override PHP and PHP-FPM configurations easily.
  • Supports changing the UID/GID running PHP-FPM.
⁠Cron Jobs
  • Runs the Nextcloud cron job every 5 minutes.
  • Runs preview:pre-generate cron job every 10 minutes if Preview Generator⁠ is present.
  • Automatically updates extensions daily if NC_EXT_UPDATE is defined.
  • Includes Healthcheck⁠.
    • Nextcloud cron job configured via HEALTHCHECKS_NC_URL.
    • Preview Generator job configured via HEALTHCHECKS_PREVIEW_URL.
    • Automatic daily updates configured via HEALTHCHECKS_UPDATE_URL.
⁠Fulltext Search Support

Includes Full Text Search⁠ support:

  • Installs Tesseract⁠ and OCRmyPDF⁠ for OCR capabilities.
  • Enables occ fulltextsearch:live for automatic indexing of new content (only if Full Text Search is present).
⁠Other Features
  • Additional binaries:
  • Recommended configurations included:
    • APCu, igbinary, OPCache, Postgres support, PHP security hardening.
  • Dedicated php-cli.ini for CLI scripts.

⁠Customization

⁠Custom UID/GID

You can use PUID / GUID to use a non root user specific instead of the www-data's PID 82. For that, just set environment variables:

environment:
  PUID: 'NEXTCLOUD_PUID'
  PGID: 'NEXTCLOUD_PGID'
⁠Custom PHP and PHP-FPM Configuration

You can include your own PHP (/usr/local/etc/php/conf.d) and PHP-FPM (/usr/local/etc/php-fpm.d/) configuration files:

  • For PHP: mount your files to /custom-php-conf-init.d
  • For PHP-FPM: mount your files to /custom-php-fpm-conf-init.d

šŸ‘‰ See the example⁠.

⁠Custom initialization Scripts

You can execute custom scripts at container initialization, for example, to install additional software or modify configurations. Just put it in /custom-script-init.d

šŸ‘‰ See the example⁠.


⁠Usage

⁠Running with Docker CLI

To run the container using the Docker CLI:

docker run -d \
  -v /docker/volumes/www:/var/www \
  --expose 9000 \
  llaumgui/php:8.4-nextcloud
⁠All environemnts variables
VariableDescriptionDefault Value
TZTimezone configuration
HEALTHCHECKS_NC_URLHealthcheck URL for Nextcloud cron jobfalse
HEALTHCHECKS_PREVIEW_URLHealthcheck URL for Preview Generator jobfalse
HEALTHCHECKS_UPDATE_URLHealthcheck URL for automatic updatesfalse
NC_EXT_UPDATEEnable automatic extension updates (true/false)false
PUIDUser ID for the httpd process (www-data).33
PGIDGroup ID for the httpd process (www-data).33

⁠Full stack Docker Compose examples

⚠ Warning: Replace NEXTCLOUD_DOMAIN, HEALTHCHECKS_DOMAIN and NEXTCLOUD_PUID / NEXTCLOUD_PGID.

You can use this container in a docker-compose.yml file:

# Services definition part
services:

## httpd
  httpd:
    container_name: nextcloud_httpd
    hostname: nextcloud-httpd
    image: ghcr.io/llaumgui/httpd:2.4
    restart: unless-stopped
    environment:
      TZ: 'Europe/Paris'
      PUID: 'NEXTCLOUD_PUID'
      PGID: 'NEXTCLOUD_PGID'
    volumes:
     - /srv/nextcloud/www:/var/www
     - /srv/nextcloud/apache/vhost.d:/usr/local/apache2/conf/vhost.d
    healthcheck:
      test: ["CMD-SHELL", "wget --no-verbose --tries=1 http://localhost:80/status.php -q -O /dev/null || exit 1"]
    depends_on:
      - php
    expose:
     - 80

## PHP
  php:
    container_name: nextcloud_php
    hostname: nextcloud-php
    image: ghcr.io/llaumgui/php:8.4-nextcloud-fpm
    restart: unless-stopped
    environment:
      TZ: 'Europe/Paris'
      PUID: 'NEXTCLOUD_PUID'
      PGID: 'NEXTCLOUD_PGID'
    volumes:
      - type: tmpfs
        target: /tmp:exec
      - /srv/nextcloud/data:/nextcloud/data
      - /srv/nextcloud/logs:/nextcloud/logs
      - /srv/nextcloud/www:/var/www
      - /srv/storage:/srv/storage
    expose:
      - 9000

You can also use with Traefik⁠, PostgreSQL⁠, and Collabora⁠:

# Services definition part
services:

## httpd
  httpd:
    container_name: nextcloud_httpd
    hostname: nextcloud-httpd
    image: ghcr.io/llaumgui/httpd:2.4
    restart: unless-stopped
    environment:
      TZ: 'Europe/Paris'
      PUID: 'NEXTCLOUD_PUID'
      PGID: 'NEXTCLOUD_PGID'
      HEALTHCHECKS_NC_URL: 'https://HEALTHCHECKS_DOMAIN/ping/xxx'
      HEALTHCHECKS_UPDATE_URL: 'https://HEALTHCHECKS_DOMAIN/ping/xxx'
      HEALTHCHECKS_PREVIEW_URL: 'https://HEALTHCHECKS_DOMAIN/ping/xxx'
      NC_EXT_UPDATE: 'true'
    labels:
      - traefik.enable=true
      - traefik.http.routers.nextcloud.entrypoints=web
      - traefik.http.routers.nextcloud.rule=Host("NEXTCLOUD_DOMAIN")
      - traefik.http.routers.nextcloud.tls.certresolver=letsencrypt
      - traefik.http.routers.nextcloud.middlewares=redirectregex_nextcloud1,redirectregex_nextcloud2
      - traefik.http.middlewares.redirectregex_nextcloud1.redirectregex.permanent=true
      - traefik.http.middlewares.redirectregex_nextcloud1.redirectregex.regex=https?://([^/]*)/.well-known/(card|cal)dav
      - traefik.http.middlewares.redirectregex_nextcloud1.redirectregex.replacement=https://$${1}/remote.php/dav/
      - traefik.http.middlewares.redirectregex_nextcloud2.redirectregex.permanent=true
      - traefik.http.middlewares.redirectregex_nextcloud2.redirectregex.regex=https?://([^/]*)(/.well-known[^#]*)
      - traefik.http.middlewares.redirectregex_nextcloud2.redirectregex.replacement=https://$${1}/index.php$${2}
    volumes:
     - /srv/nextcloud/www:/var/www
     - /srv/nextcloud/apache/vhost.d:/usr/local/apache2/conf/vhost.d
    healthcheck:
      test: ["CMD-SHELL", "wget --no-verbose --tries=1 http://localhost:80/status.php -q -O /dev/null || exit 1"]
    depends_on:
      - php
    expose:
     - 80

## PHP
  php:
    container_name: nextcloud_php
    hostname: nextcloud-php
    image: ghcr.io/llaumgui/php:8.4-nextcloud-fpm
    restart: unless-stopped
    environment:
      TZ: 'Europe/Paris'
      PUID: 'NEXTCLOUD_PUID'
      PGID: 'NEXTCLOUD_PGID'
    volumes:
      - type: tmpfs
        target: /tmp:exec
      - /srv/nextcloud/data:/nextcloud/data
      - /srv/nextcloud/logs:/nextcloud/logs
      - /srv/nextcloud/www:/var/www
      - /srv/storage:/srv/storage
    depends_on:
      - collabora
    expose:
      - 9000

## Postgres
  postgres:
    container_name: storage_postgres
    hostname: storage-postgres
    image: postgres:17
    restart: unless-stopped
    user: NEXTCLOUD_PUID:123
    environment:
      TZ: 'Europe/Paris'
    volumes:
      - /srv/postgresql:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD", "pg_isready", "-U", "miniflux"]
    ports:
     - "127.0.0.1:5432:5432"

## Collabora
  collabora:
    container_name: nextcloud_collabora
    hostname: nextcloud-collabora
    image: collabora/code
    restart: unless-stopped
    environment:
      TZ: 'Europe/Paris'
      dictionaries: 'fr_FR'
      server_name: 'office.NEXTCLOUD_DOMAIN'
      aliasgroup1: 'https://NEXTCLOUD_DOMAIN'
      extra_params: '--o:ssl.enable=false --o:ssl.termination=true --o:net.proto=IPv4'
      username: 'johndo'
      password: 'azerty'
    labels:
      - traefik.enable=true
      - traefik.http.routers.collabora.entrypoints=web
      - traefik.http.routers.collabora.rule=Host("office.NEXTCLOUD_DOMAIN")
      - traefik.http.routers.collabora.tls.certresolver=letsencrypt
      - traefik.http.routers.collabora.service=collabora
      - traefik.http.services.collabora.loadbalancer.server.port=9980
    cap_add:
      - MKNOD
    healthcheck:
      test: ["CMD-SHELL", "curl -s http://localhost:9980 | grep OK || exit 1"]
      interval: 1m
      start_period: 2m

⁠BASH or ZSH alias

alias occ="docker exec -u NEXTCLOUD_PUID -i nextcloud_php php /var/www/occ"

Tag summary

Content type

Image

Digest

sha256:836adeab5…

Size

1021.5 MB

Last updated

6 days ago

docker pull llaumgui/nextcloud-php