-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
88 lines (77 loc) · 3.01 KB
/
Dockerfile
File metadata and controls
88 lines (77 loc) · 3.01 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
FROM ubuntu:24.04
ARG GITHUB_TOKEN
ARG PHP_MINOR=8.3
# Avoid interactive prompts during build
ENV DEBIAN_FRONTEND=noninteractive
ENV GITHUB_TOKEN=${GITHUB_TOKEN}
ENV PHP_MINOR=${PHP_MINOR}
ENV SPC_TARGET="native-native-gnu"
ENV SPC_BUILD_SHARED="xdebug"
# Install all build dependencies
RUN apt-get update && apt-get install -y --no-install-recommends \
autoconf \
automake \
autopoint \
bison \
bzip2 \
ca-certificates \
cmake \
curl \
flex \
g++ \
gcc \
git \
jq \
libtool \
make \
patch \
pkg-config \
re2c \
sudo \
unzip \
xz-utils \
libunistring-dev \
libidn2-dev \
libedit-dev \
&& rm -rf /var/lib/apt/lists/*
USER root
WORKDIR /app
COPY --chmod=755 build-prepare-build.sh .
COPY --chmod=755 build-php-local.sh .
COPY --chmod=644 php-versions.json .
COPY --chmod=644 craft.yml .
RUN --mount=type=cache,target=/app/downloads \
--mount=type=cache,target=/app/source \
./build-prepare-build.sh
RUN --mount=type=cache,target=/app/downloads \
--mount=type=cache,target=/app/source \
spc doctor --auto-fix
# Dynamically update php-version in craft.yml based on PHP_MINOR
RUN sed -i "s/^php-version: .*/php-version: ${PHP_MINOR}/" craft.yml
# Download all required sources and extensions
RUN --mount=type=cache,target=/app/downloads \
--mount=type=cache,target=/app/source \
PHP_BUILD=$(jq -r --arg minor "${PHP_MINOR}" '.[$minor].build' php-versions.json) && \
spc download --with-php="$PHP_BUILD" --for-extensions="apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,igbinary,mbstring,mbregex,msgpack,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib,xdebug" --prefer-pre-built
# Build PHP using spc build to explicitly control SAPIs and avoid embed failures
RUN --mount=type=cache,target=/app/downloads \
--mount=type=cache,target=/app/source \
spc build --build-cli \
--build-shared="xdebug" \
--enable-zts \
--with-suggested-libs \
--with-suggested-exts \
"apcu,bcmath,calendar,ctype,curl,dba,dom,exif,fileinfo,filter,gd,iconv,igbinary,mbstring,mbregex,msgpack,mysqli,mysqlnd,opcache,openssl,pcntl,pdo,pdo_mysql,pdo_sqlite,phar,posix,readline,redis,session,simplexml,sockets,sodium,sqlite3,tokenizer,xml,xmlreader,xmlwriter,xsl,zip,zlib" \
--debug
# Verify PHP execution (without and with xdebug)
RUN ./buildroot/bin/php --version
RUN ./buildroot/bin/php -d zend_extension=./buildroot/modules/xdebug.so --version
# Package result
RUN PHP_BUILD=$(jq -r --arg minor "${PHP_MINOR}" '.[$minor].build' php-versions.json) && \
DIST_DIR="dist/${PHP_MINOR}" && \
mkdir -p "$DIST_DIR/ext" && \
cp buildroot/bin/php "$DIST_DIR/php" && \
cp buildroot/modules/xdebug.so "$DIST_DIR/ext/xdebug.so" && \
TARBALL="php-version-${PHP_BUILD}-linux-x86_64.tar.gz" && \
tar -C "$DIST_DIR" -czf "/php-artifact.tar.gz" . && \
echo "$TARBALL" > /tarball-name.txt