Repository navigation
Expand file tree
/
Copy pathDockerfile
More file actions
93 lines (81 loc) · 2.75 KB
/
Copy pathDockerfile
File metadata and controls
93 lines (81 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# syntax=docker/dockerfile:1
ARG PHP_VERSION=8.5
FROM php:${PHP_VERSION}-cli-alpine
ENV LC_ALL=C.UTF-8
ENV COMPOSER_HOME=/composer
ENV PATH="${PATH}:${COMPOSER_HOME}/vendor/bin"
RUN <<EOF
set -eux
apk add --no-cache \
make \
git \
unzip
# Mounted projects are often owned by a host user with a different UID
git config --system --add safe.directory '*'
EOF
COPY --from=mlocati/php-extension-installer:2 /usr/bin/install-php-extensions /usr/local/bin/
ARG XDEBUG
RUN <<EOF
set -eux
# opcache is enabled in all base images, mbstring is missing from 8.6.
# The installer builds sockets first, compiles event with sockets support
# and names its ini xx-php-ext-event.ini, so event is loaded after sockets.
# TODO: install ev from PECL again after 2026-11-23. Its CDN still serves the withdrawn 1.3.0
# or the outdated 1.2.3 as stable to CI runners, so ev is installed from GitHub.
install-php-extensions \
@composer \
mbstring \
uv \
pcntl \
sockets \
intl \
bcmath \
pgsql \
pdo_pgsql \
rosmanov/pecl-ev@1.3.1 \
event \
${XDEBUG:-xdebug}
ln -s /usr/local/bin/composer /usr/local/bin/c
EOF
# Loaded first, so any user .ini in conf.d/ can override these defaults
COPY <<EOF /usr/local/etc/php/conf.d/00-xdebug.ini
xdebug.mode=off
xdebug.client_host=host.docker.internal
xdebug.log=/xdebug.log
EOF
RUN <<EOF
set -eux
addgroup -g 1000 dev
adduser -u 1000 -G dev -D dev
chown -R dev:dev ${COMPOSER_HOME}
# Writable for any user, so the image can run with --user matching the host UID
touch /xdebug.log
chmod 666 /xdebug.log
EOF
USER 1000:1000
RUN <<EOF
set -eux
composer global config allow-plugins.ergebnis/composer-normalize true
composer global require --no-cache \
friendsofphp/php-cs-fixer \
phpyh/coding-standard \
phpstan/phpstan \
phpstan/phpstan-strict-rules \
phpstan/phpstan-phpunit \
rector/rector \
shipmonk/composer-dependency-analyser \
ergebnis/composer-normalize
# PHPStan ships its turbo extension for every OS (~55 MB), keep only this platform's.
# If this platform's directory is not found (layout changed), keep everything.
turbo=${COMPOSER_HOME}/vendor/phpstan/phpstan/turbo-ext
case $(uname -m) in
aarch64) platform=linux-musl-arm64 ;;
*) platform=linux-musl-$(uname -m) ;;
esac
if [ -d "${turbo}/${platform}" ]; then
find "${turbo}" -mindepth 1 -maxdepth 1 -type d ! -name "${platform}" -exec rm -rf {} +
fi
# Writable for any user, so the image can run with --user matching the host UID
mkdir -p ${COMPOSER_HOME}/cache
chmod -R a+rwX ${COMPOSER_HOME}
EOF