Skip to content

Instantly share code, notes, and snippets.

@LachlanArthur
Last active March 13, 2025 14:56
Show Gist options
  • Save LachlanArthur/8e3905067db9eae1053b681b4ab289f7 to your computer and use it in GitHub Desktop.
Save LachlanArthur/8e3905067db9eae1053b681b4ab289f7 to your computer and use it in GitHub Desktop.
Docker Compose PHP 8.4 Starter
services:
app:
build:
context: .
args:
# Your own user's UID and GID on the host
WWW_UID: 1000 # Run `id -u` to find yours
WWW_GID: 1000 # Run `id -g` to find yours
tty: true # Nice coloured logs
volumes:
- $PWD:/app
environment:
SERVER_NAME: ":80" # The address Caddy will listen on
CADDY_GLOBAL_OPTIONS: |
debug
servers {
trusted_proxies static private_ranges
}
networks:
- default
- caddy
labels:
caddy: docker-php.localhost
caddy.reverse_proxy: "{{upstreams 80}}"
networks:
caddy:
external: true
FROM dunglas/frankenphp:php8.4-bookworm
ARG WWW_UID=33
ARG WWW_GID=33
RUN install-php-extensions \
@composer \
intl \
zip \
opcache \
xdebug
ENV XDEBUG_MODE=
COPY <<-INI /usr/local/etc/php/conf.d/xdebug.ini
[xdebug]
xdebug.max_nesting_level = 512
xdebug.profiler_output_name = cachegrind.xdebug-profile-%H-%t-%r
xdebug.mode = debug,develop
xdebug.discover_client_host = 1
xdebug.start_with_request = trigger
xdebug.log = /app/storage/logs/xdebug.log
xdebug.output_dir = /app/storage/logs/xdebug
INI
COPY <<-INI /usr/local/etc/php/conf.d/opcache.ini
[opcache]
opcache.enable = 1
opcache.huge_code_pages = 1
; Check the timestamp of the files to invalidate the cache
opcache.validate_timestamps = 1
; Update the cache on every request
opcache.revalidate_freq = 0
INI
# Modify existing www-data user
RUN usermod -u ${WWW_UID} www-data \
&& groupmod -g ${WWW_GID} www-data \
&& setcap CAP_NET_BIND_SERVICE=+eip /usr/local/bin/frankenphp \
&& chown -R www-data:www-data /data/caddy /config/caddy
USER www-data
<?php
phpinfo();
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for Xdebug",
"type": "php",
"request": "launch",
"port": 9003,
"pathMappings": {
"/app": "${workspaceFolder}"
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment