This repository provides a Docker image based on Debian Trixie that includes:
The image is designed to serve PHP applications efficiently using Caddy as the web server and PHP-FPM for processing.
An alternative Alpine-based image is also available via Dockerfile.alpine.
linux/amd64 and linux/arm64.Europe/Berlin by default.Clone the repository:
git clone <repository-url>
cd <repository-directory>
Build with default settings (PHP 8.4):
docker build -t my-php-caddy-image .
docker build \
--build-arg ENV_PHP_VERSION=8.3 \
--build-arg S6_OVERLAY_VERSION=3.2.1.0 \
--build-arg CADDY_VERSION=2.10.2 \
-t my-php-caddy-image .
docker buildx build --platform linux/amd64,linux/arm64 \
--build-arg ENV_PHP_VERSION=8.4 \
-t my-php-caddy-image .
An alternative Alpine-based image (Dockerfile.alpine) is available with PHP 8.2 and s6-overlay 3.2.0.0:
docker build -f Dockerfile.alpine -t my-php-caddy-alpine .
/command/s6-svc -r /run/service/caddy
/command/s6-svc -r /run/service/php-fpm
s6-rc -a list
s6-svstat /run/service/caddy
Configuration files are located in the config/ and php-fpm/ directories.
config/entrypoint.shconfig/etc/caddy/Caddyfileconfig/etc/caddy/snippets/
headers_default.caddy — Default response headersheaders_security.caddy — Security headers (HSTS, X-Frame-Options, etc.)logging.caddy — Request loggingstatic_caching.caddy — Static asset caching (CSS, JS, fonts, images)php-fpm/php-fpm.confphp-fpm/www.confphp-fpm/php-vars.iniconfig/etc/s6-overlay/s6-rc.d/The s6-rc.d directory contains service definitions for s6-overlay, organized to manage services like caddy and php-fpm.
caddy and php-fpm Directories:
dependencies.d: Lists dependencies required by the service to start. caddy depends on php-fpm, php-fpm depends on base.run: The main command to start the service as a longrun process.finish: Cleanup commands that run when the service stops.type: Set to longrun for automatic restart on failure.user Directory:
contents.d: Registers caddy and php-fpm as user services.The following PHP extensions are installed by default (Debian variant):
bcmath, bz2, calendar, cli, curl, gd, gmp, imagick, intl, mbstring, memcache, mysql, opcache, pgsql, redis, soap, sqlite3, xml, zip
The entrypoint script (config/entrypoint.sh) performs the following steps:
.env.docker from /var/www/html/.env.docker if present./docker/scripts/envsubst_mapping.sh if present./docker/scripts/bootstrap.sh if present./init (s6-overlay) if no arguments are provided.Modify the TIMEZONE environment variable in the Dockerfile:
ENV TIMEZONE=Your/Timezone
In the Dockerfile, update the apt install command:
php$PHP_VERSION-<extension-name>
Edit php-fpm/php-vars.ini to change PHP settings like memory_limit, upload_max_filesize, etc.
Edit config/etc/caddy/Caddyfile and the snippets in config/etc/caddy/snippets/ to customize Caddy's behavior.
The project includes a GitLab CI pipeline (.gitlab-ci.yml) that:
linux/amd64, linux/arm64) for PHP 8.5, PHP 8.4 and PHP 8.3 in parallel.zeacom/phpfpm-caddy:{tag}-php{version}.Check the logs for the failing service:
s6-svlogd -tt /run/service/<service-name>/log
Ensure that file permissions are set correctly for the web server and PHP-FPM processes.
Validate configurations:
caddy validate --config /etc/caddy/Caddyfilephp-fpm -t/var/log/caddy/ inside the container./var/log/php-fpm.log or the configured log file.Content type
Image
Digest
sha256:a05b8592b…
Size
155.3 MB
Last updated
12 days ago
docker pull zeacom/phpfpm-caddy:trixie-v1.1.0-rc1-php8.3