Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Split Dockerfile into multiple steps for 8.3 ZTS build #80

Open
wants to merge 6 commits into
base: release/8.3-zts
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .hadolint.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ignored:
- DL3018 # warning: Pin versions in apk add. Instead of `apk add <package>` use `apk add <package>=<version>`
- DL3059 # info: Multiple consecutive `RUN` instructions. Consider consolidation.
- SC2086 # info: Double quote to prevent globbing and word splitting.

179 changes: 129 additions & 50 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM alpine:3.19.1 as PHPZTSBUILDER
FROM alpine:3.19.1 as alpine-distro
FROM alpine-distro as php-zts-builder

RUN apk add --no-cache libc6-compat
RUN apk add --no-cache alpine-sdk
Expand All @@ -17,7 +18,7 @@ USER root
RUN cp /workspace/.abuild/*.rsa.pub /etc/apk/keys/
USER alpiner

RUN git clone -b 3.19-stable --single-branch --depth=1 https://gitlab.alpinelinux.org/alpine/aports
RUN git clone -b 3.19-stable --single-branch --depth=1 https://gitlab.alpinelinux.org/alpine/aports # 2024-09-19

WORKDIR /workspace/aports/community/php83
RUN cp -rf /workspace/aports/community/php83 /workspace/aports/community/phpzts83
Expand Down Expand Up @@ -66,15 +67,17 @@ RUN sed -i -e 's/_allow_fail=no/_allow_fail=yes/g' APKBUILD

RUN abuild checksum && abuild -r

FROM alpine:3.19.1
FROM alpine-distro as php-zts-base

ARG PHP_VERSION="8.3.8"
ARG PHP_PACKAGE_BASENAME="phpzts83"
ARG PHP_PACKAGE_INCLUDE="/usr/include/php83"
ARG PHP_FPM_BINARY_PATH="/usr/sbin/php-fpmzts83"
ARG UNIT_VERSION="1.32.1"
ARG APACHE2_VERSION="2.4.59"
ARG APACHE2_VERSION="2.4.62"
ENV PHP_VERSION=$PHP_VERSION
ENV PHP_PACKAGE_BASENAME=$PHP_PACKAGE_BASENAME
ENV PHP_PACKAGE_INCLUDE=$PHP_PACKAGE_INCLUDE
ENV PHP_FPM_BINARY_PATH=$PHP_FPM_BINARY_PATH
ENV UNIT_VERSION=$UNIT_VERSION
ENV APACHE2_VERSION=$APACHE2_VERSION
Expand Down Expand Up @@ -103,7 +106,7 @@ RUN apk add --no-cache \
RUN set -eux; \
adduser -u 82 -D -S -G www-data www-data

COPY --from=PHPZTSBUILDER /workspace/packages/community /opt/custom-packages
COPY --from=php-zts-builder /workspace/packages/community /opt/custom-packages
# hadolint ignore=DL3003,SC2035,SC2046
RUN apk add --no-cache abuild && \
abuild-keygen -a -n && \
Expand Down Expand Up @@ -142,6 +145,21 @@ RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pear
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-tokenizer
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-session

# FIXME: we need this, since php83 is not the _default_php in https://git.alpinelinux.org/aports/tree/community/php83/APKBUILD
WORKDIR /usr/bin
RUN ln -s phpzts83 php \
&& ln -s peardevzts83 peardev \
&& ln -s peclzts83 pecl \
&& ln -s phpizezts83 phpize \
&& ln -s php-configzts83 php-config \
&& ln -s phpdbgzts83 phpdbg \
&& ln -s lsphpzts83 lsphp \
&& ln -s php-cgizts83 php-cgi \
&& ln -s phar.pharzts83 phar.phar \
&& ln -s pharzts83 phar

FROM php-zts-base as PECL-BUILDER-AMQP

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-amqp
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers rabbitmq-c-dev ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install amqp \
Expand All @@ -150,20 +168,26 @@ RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automa
&& apk del --no-network .build-deps \
&& apk add --no-cache rabbitmq-c

FROM php-zts-base as PECL-BUILDER-APCU

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-apcu
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install apcu \
&& strip --strip-all /usr/lib/$PHP_PACKAGE_BASENAME/modules/apcu.so \
&& echo "extension=apcu" > /etc/$PHP_PACKAGE_BASENAME/conf.d/apcu.ini \
&& apk del --no-network .build-deps

FROM php-zts-base as PECL-BUILDER-IGBINARY

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-igbinary
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install igbinary \
&& strip --strip-all /usr/lib/$PHP_PACKAGE_BASENAME/modules/igbinary.so \
&& echo "extension=igbinary" > /etc/$PHP_PACKAGE_BASENAME/conf.d/10_igbinary.ini \
&& apk del --no-network .build-deps

FROM php-zts-base as PECL-BUILDER-IMAGICK

# FIXME: # FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-imagick
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers imagemagick imagemagick-dev imagemagick-libs ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install imagick \
Expand All @@ -172,13 +196,23 @@ RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automa
&& apk del --no-network .build-deps \
&& apk add --no-cache imagemagick imagemagick-libs libgomp

FROM php-zts-base as PECL-BUILDER-MSGPACK

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-msgpack
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install msgpack \
&& strip --strip-all /usr/lib/$PHP_PACKAGE_BASENAME/modules/msgpack.so \
&& echo "extension=msgpack" > /etc/$PHP_PACKAGE_BASENAME/conf.d/10_msgpack.ini \
&& apk del --no-network .build-deps

FROM php-zts-base as PECL-BUILDER-MEMCACHED

COPY --from=PECL-BUILDER-IGBINARY /usr/lib/$PHP_PACKAGE_BASENAME/modules/igbinary.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/igbinary.so
COPY --from=PECL-BUILDER-IGBINARY /etc/$PHP_PACKAGE_BASENAME/conf.d/10_igbinary.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/10_igbinary.ini
COPY --from=PECL-BUILDER-IGBINARY $PHP_PACKAGE_INCLUDE/ext/igbinary $PHP_PACKAGE_INCLUDE/ext/igbinary
COPY --from=PECL-BUILDER-MSGPACK /usr/lib/$PHP_PACKAGE_BASENAME/modules/msgpack.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/msgpack.so
COPY --from=PECL-BUILDER-MSGPACK /etc/$PHP_PACKAGE_BASENAME/conf.d/10_msgpack.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/10_msgpack.ini
COPY --from=PECL-BUILDER-MSGPACK $PHP_PACKAGE_INCLUDE/ext/msgpack $PHP_PACKAGE_INCLUDE/ext/msgpack
# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-memcached
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers zlib-dev libmemcached-dev cyrus-sasl-dev libevent-dev ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install -D 'enable-memcached-igbinary="yes" enable-memcached-session="yes" enable-memcached-json="yes" enable-memcached-protocol="yes" enable-memcached-msgpack="yes"' memcached \
Expand All @@ -187,44 +221,39 @@ RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automa
&& apk del --no-network .build-deps \
&& apk add --no-cache libmemcached-libs libevent

FROM php-zts-base as PECL-BUILDER-PROTOBUF

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-protobuf
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install protobuf \
&& strip --strip-all /usr/lib/$PHP_PACKAGE_BASENAME/modules/protobuf.so \
&& echo "extension=protobuf" > /etc/$PHP_PACKAGE_BASENAME/conf.d/protobuf.ini \
&& apk del --no-network .build-deps

RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pgsql
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-phar
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-posix
FROM php-zts-base as PECL-BUILDER-REDIS

COPY --from=PECL-BUILDER-IGBINARY /usr/lib/$PHP_PACKAGE_BASENAME/modules/igbinary.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/igbinary.so
COPY --from=PECL-BUILDER-IGBINARY /etc/$PHP_PACKAGE_BASENAME/conf.d/10_igbinary.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/10_igbinary.ini
COPY --from=PECL-BUILDER-IGBINARY $PHP_PACKAGE_INCLUDE/ext/igbinary $PHP_PACKAGE_INCLUDE/ext/igbinary
# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-redis
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers lz4-dev zstd-dev ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install -D 'enable-redis-igbinary="yes" enable-redis-lz4="yes" with-liblz4="yes" enable-redis-lzf="yes" enable-redis-zstd="yes"' redis \
&& strip --strip-all /usr/lib/$PHP_PACKAGE_BASENAME/modules/redis.so \
&& echo "extension=redis" > /etc/$PHP_PACKAGE_BASENAME/conf.d/20_redis.ini \
&& apk del --no-network .build-deps

RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-simplexml
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-soap
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-sockets
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-sodium
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-sqlite3
FROM php-zts-base as PECL-BUILDER-XDEBUG

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xdebug
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install xdebug \
&& strip --strip-all /usr/lib/$PHP_PACKAGE_BASENAME/modules/xdebug.so \
&& echo ";zend_extension=xdebug.so" > /etc/$PHP_PACKAGE_BASENAME/conf.d/50_xdebug.ini \
&& echo ";xdebug.mode=off" >> /etc/$PHP_PACKAGE_BASENAME/conf.d/50_xdebug.ini \
&& sed -i -e 's/;zend/zend/g' /etc/${PHP_PACKAGE_BASENAME}/conf.d/50_xdebug.ini \
&& apk del --no-network .build-deps

RUN sed -i -e 's/;zend/zend/g' /etc/${PHP_PACKAGE_BASENAME}/conf.d/50_xdebug.ini
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xml
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xmlwriter
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xmlreader
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xsl
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-zip
FROM php-zts-base as PECL-BUILDER-GRPC

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-grpc~=$GRPC_EXTENSION_VERSION --repository $GRPC_EXTENSION_REPOSITORY
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
Expand All @@ -233,25 +262,93 @@ RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automa
&& echo "extension=grpc" > /etc/$PHP_PACKAGE_BASENAME/conf.d/grpc.ini \
&& apk del --no-network .build-deps

FROM php-zts-base as PECL-BUILDER-PCOV

# FIXME: RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pecl-pcov~=$PCOV_EXTENSION_VERSION --repository $PCOV_EXTENSION_REPOSITORY
RUN apk add --no-cache binutils build-base openssl-dev autoconf pcre2-dev automake libtool linux-headers ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& MAKEFLAGS="-j $(nproc)" peclzts83 install pcov \
&& strip --strip-all /usr/lib/$PHP_PACKAGE_BASENAME/modules/pcov.so \
&& echo "extension=pcov" > /etc/$PHP_PACKAGE_BASENAME/conf.d/pcov.ini \
&& apk del --no-network .build-deps

# FIXME: we need this, since php83 is not the _default_php in https://git.alpinelinux.org/aports/tree/community/php83/APKBUILD
WORKDIR /usr/bin
RUN ln -s phpzts83 php \
&& ln -s peardevzts83 peardev \
&& ln -s peclzts83 pecl \
&& ln -s phpizezts83 phpize \
&& ln -s php-configzts83 php-config \
&& ln -s phpdbgzts83 phpdbg \
&& ln -s lsphpzts83 lsphp \
&& ln -s php-cgizts83 php-cgi \
&& ln -s phar.pharzts83 phar.phar \
&& ln -s pharzts83 phar
FROM php-zts-base as FRANKENPHPBUILDER

# install caddy with frankenphp
# hadolint ignore=SC2016,SC2086,DL3003
RUN apk add --no-cache go~=1.21 --virtual .go-build-deps \
&& apk add --no-cache libxml2-dev sqlite-dev brotli-dev build-base openssl-dev ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& cd /opt \
&& git clone https://github.com/dunglas/frankenphp.git --recursive --branch v1.1.0 --single-branch \
&& cd /opt/frankenphp/caddy/frankenphp \
# make frankenphp to be happy about lphpzts83.so and not require us to have a lphp.so
&& sed -i -e "s/lphp/l${PHP_PACKAGE_BASENAME}/g" ../../frankenphp.go \
&& export PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 `php-config --includes`" \
&& export PHP_CPPFLAGS="$PHP_CFLAGS" \
&& export PHP_LDFLAGS="-Wl,-O1 -pie `php-config --ldflags`" \
&& export CGO_LDFLAGS="$PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS \
&& go build \
&& rm -rf /root/.cache /root/go \
&& mv /opt/frankenphp/caddy/frankenphp/frankenphp /usr/sbin/frankenphp \
&& rm -rf /opt/frankenphp \
&& apk del --no-network .build-deps .go-build-deps

FROM php-zts-base

COPY --from=PECL-BUILDER-AMQP /usr/lib/$PHP_PACKAGE_BASENAME/modules/amqp.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/amqp.so
COPY --from=PECL-BUILDER-AMQP /etc/$PHP_PACKAGE_BASENAME/conf.d/40_amqp.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/40_amqp.ini
RUN apk add --no-cache rabbitmq-c

COPY --from=PECL-BUILDER-APCU /usr/lib/$PHP_PACKAGE_BASENAME/modules/apcu.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/apcu.so
COPY --from=PECL-BUILDER-APCU /etc/$PHP_PACKAGE_BASENAME/conf.d/apcu.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/apcu.ini
COPY --from=PECL-BUILDER-APCU $PHP_PACKAGE_INCLUDE/ext/apcu $PHP_PACKAGE_INCLUDE/ext/apcu

COPY --from=PECL-BUILDER-IGBINARY /usr/lib/$PHP_PACKAGE_BASENAME/modules/igbinary.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/igbinary.so
COPY --from=PECL-BUILDER-IGBINARY /etc/$PHP_PACKAGE_BASENAME/conf.d/10_igbinary.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/10_igbinary.ini
COPY --from=PECL-BUILDER-IGBINARY $PHP_PACKAGE_INCLUDE/ext/igbinary $PHP_PACKAGE_INCLUDE/ext/igbinary

COPY --from=PECL-BUILDER-IMAGICK /usr/lib/$PHP_PACKAGE_BASENAME/modules/imagick.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/imagick.so
COPY --from=PECL-BUILDER-IMAGICK /etc/$PHP_PACKAGE_BASENAME/conf.d/00_imagick.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/00_imagick.ini
RUN apk add --no-cache imagemagick imagemagick-libs libgomp

COPY --from=PECL-BUILDER-MSGPACK /usr/lib/$PHP_PACKAGE_BASENAME/modules/msgpack.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/msgpack.so
COPY --from=PECL-BUILDER-MSGPACK /etc/$PHP_PACKAGE_BASENAME/conf.d/10_msgpack.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/10_msgpack.ini
COPY --from=PECL-BUILDER-MSGPACK $PHP_PACKAGE_INCLUDE/ext/msgpack $PHP_PACKAGE_INCLUDE/ext/msgpack

COPY --from=PECL-BUILDER-MEMCACHED /usr/lib/$PHP_PACKAGE_BASENAME/modules/memcached.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/memcached.so
COPY --from=PECL-BUILDER-MEMCACHED /etc/$PHP_PACKAGE_BASENAME/conf.d/20_memcached.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/20_memcached.ini
RUN apk add --no-cache libmemcached-libs libevent

COPY --from=PECL-BUILDER-PROTOBUF /usr/lib/$PHP_PACKAGE_BASENAME/modules/protobuf.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/protobuf.so
COPY --from=PECL-BUILDER-PROTOBUF /etc/$PHP_PACKAGE_BASENAME/conf.d/protobuf.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/protobuf.ini


RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-pgsql
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-phar
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-posix

COPY --from=PECL-BUILDER-REDIS /usr/lib/$PHP_PACKAGE_BASENAME/modules/redis.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/redis.so
COPY --from=PECL-BUILDER-REDIS /etc/$PHP_PACKAGE_BASENAME/conf.d/20_redis.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/20_redis.ini

RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-simplexml
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-soap
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-sockets
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-sodium
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-sqlite3

COPY --from=PECL-BUILDER-XDEBUG /usr/lib/$PHP_PACKAGE_BASENAME/modules/xdebug.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/xdebug.so
COPY --from=PECL-BUILDER-XDEBUG /etc/$PHP_PACKAGE_BASENAME/conf.d/50_xdebug.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/50_xdebug.ini

RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xml
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xmlwriter
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xmlreader
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-xsl
RUN apk add --no-cache ${PHP_PACKAGE_BASENAME}-zip

COPY --from=PECL-BUILDER-GRPC /usr/lib/$PHP_PACKAGE_BASENAME/modules/grpc.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/grpc.so
COPY --from=PECL-BUILDER-GRPC /etc/$PHP_PACKAGE_BASENAME/conf.d/grpc.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/grpc.ini

COPY --from=PECL-BUILDER-PCOV /usr/lib/$PHP_PACKAGE_BASENAME/modules/pcov.so /usr/lib/$PHP_PACKAGE_BASENAME/modules/pcov.so
COPY --from=PECL-BUILDER-PCOV /etc/$PHP_PACKAGE_BASENAME/conf.d/pcov.ini /etc/$PHP_PACKAGE_BASENAME/conf.d/pcov.ini

# add php.ini containing environment variables
COPY files/php.ini /etc/${PHP_PACKAGE_BASENAME}/php.ini
Expand Down Expand Up @@ -316,24 +413,7 @@ RUN chown www-data:www-data /var/log/cron.log
COPY files/cron/start-cron /usr/sbin/start-cron
RUN chmod +x /usr/sbin/start-cron

# install caddy with frankenphp
# hadolint ignore=SC2016,SC2086,DL3003
RUN apk add --no-cache go~=1.21 --virtual .go-build-deps \
&& apk add --no-cache libxml2-dev sqlite-dev brotli-dev build-base openssl-dev ${PHP_PACKAGE_BASENAME}-dev~=${PHP_VERSION} --virtual .build-deps \
&& cd /opt \
&& git clone https://github.com/dunglas/frankenphp.git --recursive --branch v1.1.0 --single-branch \
&& cd /opt/frankenphp/caddy/frankenphp \
# make frankenphp to be happy about lphpzts83.so and not require us to have a lphp.so
&& sed -i -e "s/lphp/l${PHP_PACKAGE_BASENAME}/g" ../../frankenphp.go \
&& export PHP_CFLAGS="-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 `php-config --includes`" \
&& export PHP_CPPFLAGS="$PHP_CFLAGS" \
&& export PHP_LDFLAGS="-Wl,-O1 -pie `php-config --ldflags`" \
&& export CGO_LDFLAGS="$PHP_LDFLAGS" CGO_CFLAGS=$PHP_CFLAGS CGO_CPPFLAGS=$PHP_CPPFLAGS \
&& go build \
&& rm -rf /root/.cache /root/go \
&& mv /opt/frankenphp/caddy/frankenphp/frankenphp /usr/sbin/frankenphp \
&& rm -rf /opt/frankenphp \
&& apk del --no-network .build-deps .go-build-deps
COPY --from=FRANKENPHPBUILDER /usr/sbin/frankenphp /usr/sbin/frankenphp

COPY files/frankenphp/Caddyfile /etc/Caddyfile
# FIXME: start with /usr/sbin/frankenphp run --config /etc/Caddyfile
Expand All @@ -343,7 +423,6 @@ RUN apk add --no-cache nss-tools

CMD ["php", "-a"]


ENV PHP_DATE_TIMEZONE="UTC" \
PHP_ALLOW_URL_FOPEN="On" \
PHP_LOG_ERRORS_MAX_LEN=1024 \
Expand Down
Loading