|
1 | | -FROM php:8.2-zts-alpine3.17 AS builder |
| 1 | +FROM php:8.2-zts-alpine3.17 AS php-base |
2 | 2 |
|
3 | | -COPY --from=golang:1.19-alpine3.17 /usr/local/go/bin/go /usr/local/bin/go |
4 | | -COPY --from=golang:1.19-alpine3.17 /usr/local/go /usr/local/go |
| 3 | +# 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 |
| 4 | + |
| 5 | +RUN rm -Rf /usr/local/include/php/ /usr/local/lib/libphp.* /usr/local/lib/php/ /usr/local/php/ |
| 6 | + |
| 7 | +ENV PHPIZE_DEPS \ |
| 8 | + autoconf \ |
| 9 | + dpkg-dev dpkg \ |
| 10 | + file \ |
| 11 | + g++ \ |
| 12 | + gcc \ |
| 13 | + libc-dev \ |
| 14 | + make \ |
| 15 | + pkgconf \ |
| 16 | + re2c |
| 17 | + |
| 18 | +RUN apk add --no-cache --virtual .build-deps \ |
| 19 | + $PHPIZE_DEPS \ |
| 20 | + argon2-dev \ |
| 21 | + coreutils \ |
| 22 | + curl-dev \ |
| 23 | + readline-dev \ |
| 24 | + libsodium-dev \ |
| 25 | + sqlite-dev \ |
| 26 | + openssl-dev \ |
| 27 | + libxml2-dev \ |
| 28 | + gnu-libiconv-dev \ |
| 29 | + linux-headers \ |
| 30 | + oniguruma-dev \ |
| 31 | + bison \ |
| 32 | + git |
| 33 | + |
| 34 | +RUN git clone --depth=1 --single-branch --branch=frankenphp https://github.com/dunglas/php-src.git |
| 35 | + |
| 36 | +WORKDIR /php-src/ |
| 37 | + |
| 38 | +# --enable-embed is only necessary to generate libphp.so, we don't use this SAPI directly |
| 39 | +RUN ./buildconf |
| 40 | +RUN ./configure \ |
| 41 | + --enable-embed \ |
| 42 | + --enable-zts \ |
| 43 | + --disable-zend-signals \ |
| 44 | + # --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) |
| 45 | + --enable-mysqlnd \ |
| 46 | + # make sure invalid --configure-flags are fatal errors instead of just warnings |
| 47 | + --enable-option-checking=fatal \ |
| 48 | + # https://github.com/docker-library/php/issues/439 |
| 49 | + --with-mhash \ |
| 50 | + # https://github.com/docker-library/php/issues/822 |
| 51 | + --with-pic \ |
| 52 | + # --enable-ftp is included here because ftp_ssl_connect() needs ftp to be compiled statically (see https://github.com/docker-library/php/issues/236) |
| 53 | + --enable-ftp \ |
| 54 | + # --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) |
| 55 | + --enable-mbstring \ |
| 56 | + # https://wiki.php.net/rfc/argon2_password_hash |
| 57 | + --with-password-argon2 \ |
| 58 | + # https://wiki.php.net/rfc/libsodium |
| 59 | + --with-sodium=shared \ |
| 60 | + # always build against system sqlite3 (https://github.com/php/php-src/commit/6083a387a81dbbd66d6316a3a12a63f06d5f7109) |
| 61 | + --with-pdo-sqlite=/usr \ |
| 62 | + --with-sqlite3=/usr \ |
| 63 | + --with-curl \ |
| 64 | + --with-iconv \ |
| 65 | + --with-openssl \ |
| 66 | + --with-readline \ |
| 67 | + --with-zlib \ |
| 68 | + # 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.") |
| 69 | + --disable-phpdbg \ |
| 70 | + --with-config-file-path="$PHP_INI_DIR" \ |
| 71 | + --with-config-file-scan-dir="$PHP_INI_DIR/conf.d" |
| 72 | +RUN make -j$(nproc) |
| 73 | +RUN make install |
| 74 | +RUN rm -Rf /php-src/ |
| 75 | +RUN echo "Creating src archive for building extensions\n" |
| 76 | +RUN tar -c -f /usr/src/php.tar.xz -J /php-src/ |
| 77 | +#RUN ldconfig |
| 78 | +RUN php --version |
| 79 | + |
| 80 | +FROM php-base AS builder |
| 81 | + |
| 82 | +COPY --from=golang:alpine3.16 /usr/local/go/bin/go /usr/local/bin/go |
| 83 | +COPY --from=golang:alpine3.16 /usr/local/go /usr/local/go |
5 | 84 |
|
6 | 85 | RUN apk add --no-cache --virtual .build-deps \ |
7 | 86 | $PHPIZE_DEPS \ |
@@ -44,7 +123,7 @@ RUN cd caddy/frankenphp && \ |
44 | 123 |
|
45 | 124 | ENTRYPOINT ["/bin/sh","-c"] |
46 | 125 |
|
47 | | -FROM php:8.2-zts-alpine3.17 AS final |
| 126 | +FROM php:8.2-zts-alpine3.16 AS final |
48 | 127 |
|
49 | 128 | COPY --from=mlocati/php-extension-installer /usr/bin/install-php-extensions /usr/local/bin/ |
50 | 129 |
|
|
0 commit comments