-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathDockerfile.debian
More file actions
97 lines (85 loc) · 3.5 KB
/
Copy pathDockerfile.debian
File metadata and controls
97 lines (85 loc) · 3.5 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
94
95
96
97
# Rebuilds the official php:<BASE_TAG> image with php-debugger statically
# compiled into the interpreter. The official image ships its own source
# (docker-php-source) and records its full configure command (the
# "Configure Command" line in php -i), so we re-run the exact same build
# with the extension added and opcache JIT disabled (JIT is incompatible
# with php-debugger).
#
# Usage:
# docker build -f Dockerfile.debian --build-arg BASE_TAG=8.4-cli --build-arg DEBUGGER_REF=0.1.0 .
ARG BASE_TAG
FROM php:${BASE_TAG} AS builder
ARG DEBUGGER_REF
ARG DEBUGGER_REPO=https://github.com/php-debugger/php-debugger.git
# The toolchain ($PHPIZE_DEPS: autoconf, gcc, make, re2c, ...) is
# preinstalled on Debian variants but listed anyway in case upstream ever
# makes it transient; git is needed for the clone and the -dev packages
# match the official image's configure options (the official build purges
# these after compiling, keeping just the runtime libs). bison is not
# needed: the bundled source tarball ships pre-generated parsers.
# apache2-dev only applies when the base was built --with-apxs2.
RUN set -eux; \
apt-get update; \
apt-get install -y --no-install-recommends \
$PHPIZE_DEPS \
git \
libargon2-dev \
libcurl4-openssl-dev \
libedit-dev \
libonig-dev \
libreadline-dev \
libsodium-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
zlib1g-dev \
; \
if php-config --configure-options | grep -q -- --with-apxs2; then \
apt-get install -y --no-install-recommends apache2-dev; \
fi; \
rm -rf /var/lib/apt/lists/*
# DEBUGGER_SHA is optional: when set (CI passes the commit the release tag
# points at) it busts this layer's build cache if the tag is ever re-pointed,
# and fails the build if the clone doesn't match the expected commit.
ARG DEBUGGER_SHA=
RUN set -eux; \
docker-php-source extract; \
git clone --depth 1 --branch "${DEBUGGER_REF}" "${DEBUGGER_REPO}" /usr/src/php/ext/php_debugger; \
if [ -n "${DEBUGGER_SHA}" ]; then \
[ "$(git -C /usr/src/php/ext/php_debugger rev-parse HEAD)" = "${DEBUGGER_SHA}" ]; \
fi; \
mkdir -p /usr/src/php/m4; \
cp /usr/src/php/ext/php_debugger/m4/*.m4 /usr/src/php/m4/
RUN set -eux; \
cd /usr/src/php; \
./buildconf --force; \
export CFLAGS="$PHP_CFLAGS" CPPFLAGS="$PHP_CPPFLAGS" LDFLAGS="$PHP_LDFLAGS"; \
configureCommand="$(php -i | sed -n 's/^Configure Command => *//p' | head -n 1)"; \
eval "$configureCommand" \
--enable-php-debugger \
--disable-opcache-jit; \
make -j"$(nproc)"; \
make install; \
# the apache SAPI installs libphp outside /usr/local — stage it so the
# final image can pick it up (empty dir for the other variants)
mkdir -p /opt/php-debugger/apache2-modules; \
if [ -d /usr/lib/apache2/modules ]; then \
cp -a /usr/lib/apache2/modules/libphp* /opt/php-debugger/apache2-modules/; \
fi; \
php -v; \
php -m | grep -ix php_debugger; \
php -r 'exit(extension_loaded("php_debugger") ? 0 : 1);'
FROM php:${BASE_TAG}
ARG DEBUGGER_REF
LABEL org.opencontainers.image.source="https://github.com/php-debugger/php-debugger" \
org.opencontainers.image.description="Official PHP image with php-debugger statically compiled into the interpreter" \
org.opencontainers.image.version="${DEBUGGER_REF}"
COPY --from=builder /usr/local /usr/local
COPY --from=builder /opt/php-debugger/apache2-modules /opt/php-debugger/apache2-modules
RUN set -eux; \
if [ -d /usr/lib/apache2/modules ]; then \
cp -a /opt/php-debugger/apache2-modules/. /usr/lib/apache2/modules/; \
fi; \
rm -rf /opt/php-debugger; \
php -v; \
php -m | grep -ix php_debugger