chore(docker): switch back to the official PHP builds (#153)

* chore(docker): switch back to the official PHP builds

* alpine
This commit is contained in:
Kévin Dunglas
2023-06-26 14:34:03 +02:00
committed by GitHub
parent 4c8a16f6cc
commit 930c627a44
3 changed files with 7 additions and 160 deletions

View File

@@ -1,82 +1,5 @@
FROM php:8.2-zts-bullseye AS php-base
# Note that this image is based on the official PHP image, once https://github.com/php/php-src/pull/10141 is merged, this stage can be removed
RUN rm -Rf /usr/local/include/php/ /usr/local/lib/libphp.* /usr/local/lib/php/ /usr/local/php/
ENV PHPIZE_DEPS \
autoconf \
dpkg-dev \
file \
g++ \
gcc \
libc-dev \
make \
pkg-config \
re2c
RUN apt-get update && \
apt-get -y --no-install-recommends install \
$PHPIZE_DEPS \
libargon2-dev \
libcurl4-openssl-dev \
libonig-dev \
libreadline-dev \
libsodium-dev \
libsqlite3-dev \
libssl-dev \
libxml2-dev \
zlib1g-dev \
bison \
git \
&& \
apt-get clean
RUN git clone --depth=1 --single-branch --branch=PHP-8.2 https://github.com/php/php-src.git && \
cd php-src && \
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
./buildconf && \
./configure \
--enable-embed \
--enable-zts \
--disable-zend-signals \
--enable-zend-max-execution-timers \
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
--enable-mysqlnd \
# make sure invalid --configure-flags are fatal errors instead of just warnings
--enable-option-checking=fatal \
# https://github.com/docker-library/php/issues/439
--with-mhash \
# https://github.com/docker-library/php/issues/822
--with-pic \
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
--enable-ftp \
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
--enable-mbstring \
# https://wiki.php.net/rfc/argon2_password_hash
--with-password-argon2 \
# https://wiki.php.net/rfc/libsodium
--with-sodium=shared \
# always build against system sqlite3 (https://github.com/php/php-src/commit/6083a387a81dbbd66d6316a3a12a63f06d5f7109)
--with-pdo-sqlite=/usr \
--with-sqlite3=/usr \
--with-curl \
--with-iconv \
--with-openssl \
--with-readline \
--with-zlib \
# https://github.com/bwoebi/phpdbg-docs/issues/1#issuecomment-163872806 ("phpdbg is primarily a CLI debugger, and is not suitable for debugging an fpm stack.")
--disable-phpdbg \
--with-config-file-path="$PHP_INI_DIR" \
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d" && \
make -j$(nproc) && \
make install && \
rm -Rf php-src/ && \
echo "Creating src archive for building extensions\n" && \
tar -c -f /usr/src/php.tar.xz -J /php-src/ && \
ldconfig && \
php --version
FROM php-base AS builder
COPY --from=golang:1.19-bullseye /usr/local/go/bin/go /usr/local/bin/go
@@ -124,7 +47,7 @@ RUN cd caddy/frankenphp && \
ENTRYPOINT ["/bin/bash","-c"]
FROM php:8.2-zts-bullseye AS final
FROM php-base AS final
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

View File

@@ -1,87 +1,9 @@
FROM php:8.2-zts-alpine3.17 AS php-base
# Note that this image is based on the official PHP image, once https://github.com/php/php-src/pull/10141 is merged, this stage can be removed
RUN rm -Rf /usr/local/include/php/ /usr/local/lib/libphp.* /usr/local/lib/php/ /usr/local/php/
ENV PHPIZE_DEPS \
autoconf \
dpkg-dev dpkg \
file \
g++ \
gcc \
libc-dev \
make \
pkgconf \
re2c
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
argon2-dev \
coreutils \
curl-dev \
readline-dev \
libsodium-dev \
sqlite-dev \
openssl-dev \
libxml2-dev \
gnu-libiconv-dev \
linux-headers \
oniguruma-dev \
bison \
git
RUN git clone --depth=1 --single-branch --branch=PHP-8.2 https://github.com/php/php-src.git
WORKDIR /php-src/
# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly
RUN ./buildconf
RUN ./configure \
--enable-embed \
--enable-zts \
--disable-zend-signals \
--enable-zend-max-execution-timers \
# --enable-mysqlnd is included here because it's harder to compile after the fact than extensions are (since it's a plugin for several extensions, not an extension in itself)
--enable-mysqlnd \
# make sure invalid --configure-flags are fatal errors instead of just warnings
--enable-option-checking=fatal \
# https://github.com/docker-library/php/issues/439
--with-mhash \
# https://github.com/docker-library/php/issues/822
--with-pic \
# --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236)
--enable-ftp \
# --enable-mbstring is included here because otherwise there's no way to get pecl to use it properly (see https://github.com/docker-library/php/issues/195)
--enable-mbstring \
# https://wiki.php.net/rfc/argon2_password_hash
--with-password-argon2 \
# https://wiki.php.net/rfc/libsodium
--with-sodium=shared \
# always build against system sqlite3 (https://github.com/php/php-src/commit/6083a387a81dbbd66d6316a3a12a63f06d5f7109)
--with-pdo-sqlite=/usr \
--with-sqlite3=/usr \
--with-curl \
--with-iconv \
--with-openssl \
--with-readline \
--with-zlib \
# https://github.com/bwoebi/phpdbg-docs/issues/1#issuecomment-163872806 ("phpdbg is primarily a CLI debugger, and is not suitable for debugging an fpm stack.")
--disable-phpdbg \
--with-config-file-path="$PHP_INI_DIR" \
--with-config-file-scan-dir="$PHP_INI_DIR/conf.d"
RUN make -j$(nproc)
RUN make install
RUN rm -Rf /php-src/
RUN echo "Creating src archive for building extensions\n"
RUN tar -c -f /usr/src/php.tar.xz -J /php-src/
#RUN ldconfig
RUN php --version
FROM php:8.2-zts-alpine3.18 AS php-base
FROM php-base AS builder
COPY --from=golang:1.19-alpine3.17 /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang:1.19-alpine3.17 /usr/local/go /usr/local/go
COPY --from=golang:1.19-alpine3.18 /usr/local/go/bin/go /usr/local/bin/go
COPY --from=golang:1.19-alpine3.18 /usr/local/go /usr/local/go
RUN apk add --no-cache --virtual .build-deps \
$PHPIZE_DEPS \
@@ -124,7 +46,7 @@ RUN cd caddy/frankenphp && \
ENTRYPOINT ["/bin/sh","-c"]
FROM php:8.2-zts-alpine3.17 AS final
FROM php-base AS final
COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/

View File

@@ -27,6 +27,8 @@ RUN apt-get update && \
bison \
# Dev tools \
git \
clang \
llvm \
gdb \
valgrind \
neovim \