diff --git a/README.md b/README.md index 7488fed6bb..2fd270e2ff 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,85 @@ docker run --detach --rm \ Oryx consists of a build image, a collection of runtime images, a build script generator, and a collection of startup script generators. For more details, refer to our [architecture](./doc/architecture.md) page. +The active Node, Python, and PHP runtime Dockerfiles include the common and +platform-specific bases as stages in the same file. Build them directly from +the repository root with exact version inputs from `images/constants.yml`; +separately built `BASE_IMAGE` inputs are no longer required. The .NET runtime +Dockerfiles were already self-contained. Python's shared Debian recipe still +selects its OS using `DEBIAN_FLAVOR`, and disposable compiler stages remain +part of the runtime build. + +The .NET 8 Bullseye runtime uses the official Debian archive because Bullseye +packages have moved off the live mirrors. APT signature, checksum, and metadata +expiry verification remain enabled. + +Azure Linux certificate-package retrieval retries only connection failures, +up to three attempts with bounded delays. Other errors and exhausted retries +remain fatal; repository signatures and certificate verification are unchanged. +Acquisition uses the existing official base repository that supplies these +packages, avoiding metadata downloads for unrelated Azure Linux repositories. +OpenSSL certificate metadata inspection uses at most four workers; deduplication, +filename selection, installation, and import diagnostics retain their original +order. The final trust-store refresh is unchanged. + +PHP runtime builds configure and compile four independent bundled extensions +concurrently, splitting make jobs between them. The existing extension installer +then installs and enables the results serially to avoid shared-header races. +Core compilation starts the Zend executor and configured JIT translation units +early in the same make dependency graph, retaining the complete `all` target, +compiler flags, and job limit. +The core installation uses native Linux `install` instead of PHP's portable +shell installer, preserving file contents and permissions without changing compilation. +PHP 8.1 FPM Bullseye and PHP 8.2 FPM builds compile 22 bundled shared modules with +the interpreter, avoiding repeated configure work. PDO, mbstring, IMAP, PDO_MYSQL, +and sockets retain their standalone build profiles; merging those profiles can +change library detection, default socket settings, or exposed constants. The +jointly built modules retain PHP 8.1's non-stripping and PHP 8.2's stripping +behavior and use the existing enablement helpers, preserving the module inventory. +PHP 8.3 and 8.4 FPM Bullseye builds also compile 22 bundled shared modules with +the interpreter. PDO, PDO_MYSQL, mbstring, and sockets retain their standalone +profiles; PHP 8.3 also builds bundled IMAP separately, while PHP 8.4 retains +external PECL IMAP. Their module enablement and non-stripping behavior remain +unchanged, as does the separate ODBC build. +The Bookworm PHP 8.3 Apache and PHP 8.3/8.4 FPM recipes use the same shared-module +partition while preserving their existing SAPI flags, standalone profiles, +module enablement, and non-stripping behavior. +PHP 8.5 FPM builds compile 21 bundled shared modules with the interpreter. +PDO, PDO_MYSQL, and sockets retain their standalone profiles; built-in OPcache, +external PECL IMAP, and the separate ODBC build remain unchanged. +Its Noble recipe installs core headers with the persistent dependencies and +cleans APT indexes before committing package layers, retaining package marks +and ODBC holds while avoiding redundant metadata refreshes and deleted index blobs. +PHP 8.2 FPM Bookworm, PHP 8.3/8.4 FPM Bullseye and Bookworm, and PHP 8.3 Apache +Bookworm, along with PHP 8.5 FPM Noble, reuse fresh APT indexes for the +persistent-dependency upgrade. +These FPM recipes also group Nginx repository setup and package installation. +PHP 8.2 FPM Bookworm, PHP 8.3/8.4 FPM Bullseye, and PHP 8.5 FPM Noble avoid the +adjacent duplicate extension-phase upgrade; +package upgrades, ODBC holds, and Nginx signing-key verification remain enabled. +PECL receives command-scoped `MAKEFLAGS`, leaving the running +image's environment and extension selection unchanged. +PECL downloads retry up to three times in isolated temporary directories; +compilation and installation failures are not retried. The same package requests, +including pinned SQL Server driver versions, still go through PECL's installer. +Extension configuration, compilation, and source cleanup share a layer so +extracted PHP build sources are not retained in the runtime image. The original +source archive remains available to `docker-php-source extract`. +GPG key retrieval stops after the first successful retry and fails explicitly +when all attempts are exhausted. Key fingerprints and signature checks are unchanged. +Python keeps PGO/LTO enabled and runs the unchanged default PGO training suite +across the available CPUs. GCC's LTO links use balanced parallel partitions, +including on older CPython versions that otherwise disable partitioning (see +[CPython's upstream change](https://github.com/python/cpython/pull/132258)). +Only the disposable training interpreter skips LTO; the installed interpreter +keeps full optimization, PGO, and fat LTO objects. Runtime OS dependencies are +installed before copying the compiled interpreter so BuildKit can overlap their +installation with compilation. +Only the SDK build driver compresses an SDK archive; runtime builds copy the +installed interpreter directly. +Azure Linux CA imports read each certificate's subject and SHA256 fingerprint +in one OpenSSL invocation, retaining the existing validation and trust-store deduplication. + # Testing Locally ## startup script generator `build/testStartupScriptGenerators.sh` will perform tests on all startup script generators written in go. diff --git a/images/receiveGpgKeys.sh b/images/receiveGpgKeys.sh index 0290e98e47..29ab299621 100644 --- a/images/receiveGpgKeys.sh +++ b/images/receiveGpgKeys.sh @@ -16,15 +16,20 @@ fi for keyID in $KEY_IDS; do for i in {1..10}; do echo "Try # $i" + EXIT_CODE=0 gpg --batch --keyserver hkps://keyserver.ubuntu.com:443 --recv-keys "$keyID" || \ gpg --batch --keyserver hkp://p80.pool.sks-keyservers.net:80 --recv-keys "$keyID" || \ gpg --batch --keyserver hkp://ipv4.pool.sks-keyservers.net --recv-keys "$keyID" || \ gpg --batch --keyserver hkp://pgp.mit.edu:80 --recv-keys "$keyID" || \ EXIT_CODE=$? - if [ "$EXIT_CODE" == '' ] || [ "$EXIT_CODE" == 0 ]; then + if [ "$EXIT_CODE" -eq 0 ]; then echo "Received key successfully." break fi done + if [ "$EXIT_CODE" -ne 0 ]; then + echo "Error: Unable to receive GPG key $keyID after 10 attempts" >&2 + exit 1 + fi done \ No newline at end of file diff --git a/images/runtime/dotnetcore/10.0/noble.Dockerfile b/images/runtime/dotnetcore/10.0/noble.Dockerfile index 79a0ddac67..c96b6af9ec 100644 --- a/images/runtime/dotnetcore/10.0/noble.Dockerfile +++ b/images/runtime/dotnetcore/10.0/noble.Dockerfile @@ -42,12 +42,10 @@ RUN chmod +x build.sh && ./build.sh dotnetcore /opt/startupcmdgen/startupcmdgen FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core ARG INCLUDE_AZURELINUX_CERTS COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ set -eux; \ - tdnf makecache; \ - tdnf install -y ca-certificates; \ - update-ca-trust extract; \ - tdnf clean all; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ fi FROM mcr.microsoft.com/mirror/docker/library/ubuntu:noble diff --git a/images/runtime/dotnetcore/11.0/resolute.Dockerfile b/images/runtime/dotnetcore/11.0/resolute.Dockerfile index 880ed0d90d..4e4d7f03a6 100644 --- a/images/runtime/dotnetcore/11.0/resolute.Dockerfile +++ b/images/runtime/dotnetcore/11.0/resolute.Dockerfile @@ -41,12 +41,10 @@ RUN chmod +x build.sh && ./build.sh dotnetcore /opt/startupcmdgen/startupcmdgen FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core ARG INCLUDE_AZURELINUX_CERTS COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ set -eux; \ - tdnf makecache; \ - tdnf install -y ca-certificates; \ - update-ca-trust extract; \ - tdnf clean all; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ fi FROM mcr.microsoft.com/mirror/docker/library/ubuntu:resolute diff --git a/images/runtime/dotnetcore/8.0/bookworm.Dockerfile b/images/runtime/dotnetcore/8.0/bookworm.Dockerfile index 69ea119cf2..33747168e4 100644 --- a/images/runtime/dotnetcore/8.0/bookworm.Dockerfile +++ b/images/runtime/dotnetcore/8.0/bookworm.Dockerfile @@ -42,12 +42,10 @@ RUN chmod +x build.sh && ./build.sh dotnetcore /opt/startupcmdgen/startupcmdgen FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core ARG INCLUDE_AZURELINUX_CERTS COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ set -eux; \ - tdnf makecache; \ - tdnf install -y ca-certificates; \ - update-ca-trust extract; \ - tdnf clean all; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ fi FROM mcr.microsoft.com/mirror/docker/library/debian:bookworm-slim diff --git a/images/runtime/dotnetcore/8.0/bullseye.Dockerfile b/images/runtime/dotnetcore/8.0/bullseye.Dockerfile index 8dec4d7ad1..97824e382a 100644 --- a/images/runtime/dotnetcore/8.0/bullseye.Dockerfile +++ b/images/runtime/dotnetcore/8.0/bullseye.Dockerfile @@ -42,12 +42,10 @@ RUN chmod +x build.sh && ./build.sh dotnetcore /opt/startupcmdgen/startupcmdgen FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core ARG INCLUDE_AZURELINUX_CERTS COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ set -eux; \ - tdnf makecache; \ - tdnf install -y ca-certificates; \ - update-ca-trust extract; \ - tdnf clean all; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ fi FROM mcr.microsoft.com/mirror/docker/library/debian:bullseye-slim @@ -55,7 +53,9 @@ ARG BUILD_DIR=/tmp/oryx/build ARG INCLUDE_AZURELINUX_CERTS ADD build ${BUILD_DIR} -RUN apt-get update \ +# Bullseye packages have moved from the live mirrors to the signed Debian archive. +RUN sed -i 's|deb.debian.org|archive.debian.org|g' /etc/apt/sources.list \ + && apt-get update \ && apt-get install -y --no-install-recommends \ # .NET Core dependencies libc6 \ diff --git a/images/runtime/dotnetcore/9.0/bookworm.Dockerfile b/images/runtime/dotnetcore/9.0/bookworm.Dockerfile index 345d14342e..6c7b73b02c 100644 --- a/images/runtime/dotnetcore/9.0/bookworm.Dockerfile +++ b/images/runtime/dotnetcore/9.0/bookworm.Dockerfile @@ -42,12 +42,10 @@ RUN chmod +x build.sh && ./build.sh dotnetcore /opt/startupcmdgen/startupcmdgen FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core ARG INCLUDE_AZURELINUX_CERTS COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ set -eux; \ - tdnf makecache; \ - tdnf install -y ca-certificates; \ - update-ca-trust extract; \ - tdnf clean all; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ fi FROM mcr.microsoft.com/mirror/docker/library/debian:bookworm-slim diff --git a/images/runtime/node/20/bookworm.Dockerfile b/images/runtime/node/20/bookworm.Dockerfile index 4967242350..0da5d6705b 100644 --- a/images/runtime/node/20/bookworm.Dockerfile +++ b/images/runtime/node/20/bookworm.Dockerfile @@ -1,4 +1,107 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bookworm +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base +ARG IMAGES_DIR=/tmp/oryx/images + +RUN apt-get update \ + && apt-get install -y \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# NOTE: This is a list of keys for ALL Node versions and also Yarn package installs. +# Receiving them once speeds up building of individual node versions as they all derive +# from this image. + +# Gpg keys listed at https://github.com/nodejs/node + +RUN ${IMAGES_DIR}/receiveGpgKeys.sh \ + 6A010C5166006599AA17F08146C2130DFD2497F5 + +ARG YARN_VERSION +ENV YARN_VERSION ${YARN_VERSION} + +COPY images/yarn-v${YARN_VERSION}.tar.gz . + +RUN mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -15,7 +118,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh node /opt/startupcmdgen/startupcmdgen # Download Node.js directly from official source -FROM ${BASE_IMAGE} AS nodeDownloader +FROM oryx_runtime_base AS nodeDownloader ARG NODE20_VERSION WORKDIR /tmp/node-download RUN apt-get update \ @@ -31,8 +134,7 @@ RUN apt-get update \ && tar -xJf "node-v${NODE20_VERSION}-linux-x64.tar.xz" -C /opt/nodejs --strip-components=1 \ && rm -rf /tmp/node-download -#FROM oryxdevmcr.azurecr.io/private/oryx/oryx-node-run-base-bookworm:${BUILD_NUMBER} -FROM ${BASE_IMAGE} +FROM oryx_runtime_base RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node diff --git a/images/runtime/node/20/bullseye.Dockerfile b/images/runtime/node/20/bullseye.Dockerfile index 6176d3fcb8..8ab95e4877 100644 --- a/images/runtime/node/20/bullseye.Dockerfile +++ b/images/runtime/node/20/bullseye.Dockerfile @@ -1,4 +1,107 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bullseye +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base +ARG IMAGES_DIR=/tmp/oryx/images + +RUN apt-get update \ + && apt-get install -y \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# NOTE: This is a list of keys for ALL Node versions and also Yarn package installs. +# Receiving them once speeds up building of individual node versions as they all derive +# from this image. + +# Gpg keys listed at https://github.com/nodejs/node + +RUN ${IMAGES_DIR}/receiveGpgKeys.sh \ + 6A010C5166006599AA17F08146C2130DFD2497F5 + +ARG YARN_VERSION +ENV YARN_VERSION ${YARN_VERSION} + +COPY images/yarn-v${YARN_VERSION}.tar.gz . + +RUN mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -15,7 +118,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh node /opt/startupcmdgen/startupcmdgen # Download Node.js directly from official source -FROM ${BASE_IMAGE} AS nodeDownloader +FROM oryx_runtime_base AS nodeDownloader ARG NODE20_VERSION WORKDIR /tmp/node-download RUN apt-get update \ @@ -31,8 +134,7 @@ RUN apt-get update \ && tar -xJf "node-v${NODE20_VERSION}-linux-x64.tar.xz" -C /opt/nodejs --strip-components=1 \ && rm -rf /tmp/node-download -#FROM oryxdevmcr.azurecr.io/private/oryx/oryx-node-run-base-bullseye:${BUILD_NUMBER} -FROM ${BASE_IMAGE} +FROM oryx_runtime_base RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node diff --git a/images/runtime/node/22/bookworm.Dockerfile b/images/runtime/node/22/bookworm.Dockerfile index 477e79fc5a..6db1b15401 100644 --- a/images/runtime/node/22/bookworm.Dockerfile +++ b/images/runtime/node/22/bookworm.Dockerfile @@ -1,4 +1,107 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bookworm +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base +ARG IMAGES_DIR=/tmp/oryx/images + +RUN apt-get update \ + && apt-get install -y \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# NOTE: This is a list of keys for ALL Node versions and also Yarn package installs. +# Receiving them once speeds up building of individual node versions as they all derive +# from this image. + +# Gpg keys listed at https://github.com/nodejs/node + +RUN ${IMAGES_DIR}/receiveGpgKeys.sh \ + 6A010C5166006599AA17F08146C2130DFD2497F5 + +ARG YARN_VERSION +ENV YARN_VERSION ${YARN_VERSION} + +COPY images/yarn-v${YARN_VERSION}.tar.gz . + +RUN mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -15,7 +118,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh node /opt/startupcmdgen/startupcmdgen # Download Node.js directly from official source -FROM ${BASE_IMAGE} AS nodeDownloader +FROM oryx_runtime_base AS nodeDownloader ARG NODE22_VERSION WORKDIR /tmp/node-download RUN apt-get update \ @@ -31,8 +134,7 @@ RUN apt-get update \ && tar -xJf "node-v${NODE22_VERSION}-linux-x64.tar.xz" -C /opt/nodejs --strip-components=1 \ && rm -rf /tmp/node-download -#FROM oryxdevmcr.azurecr.io/private/oryx/oryx-node-run-base-bookworm:${BUILD_NUMBER} -FROM ${BASE_IMAGE} +FROM oryx_runtime_base RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node diff --git a/images/runtime/node/22/bullseye.Dockerfile b/images/runtime/node/22/bullseye.Dockerfile index 3dea667a57..8c1c0e84aa 100644 --- a/images/runtime/node/22/bullseye.Dockerfile +++ b/images/runtime/node/22/bullseye.Dockerfile @@ -1,4 +1,107 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bullseye +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base +ARG IMAGES_DIR=/tmp/oryx/images + +RUN apt-get update \ + && apt-get install -y \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# NOTE: This is a list of keys for ALL Node versions and also Yarn package installs. +# Receiving them once speeds up building of individual node versions as they all derive +# from this image. + +# Gpg keys listed at https://github.com/nodejs/node + +RUN ${IMAGES_DIR}/receiveGpgKeys.sh \ + 6A010C5166006599AA17F08146C2130DFD2497F5 + +ARG YARN_VERSION +ENV YARN_VERSION ${YARN_VERSION} + +COPY images/yarn-v${YARN_VERSION}.tar.gz . + +RUN mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -15,7 +118,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh node /opt/startupcmdgen/startupcmdgen # Download Node.js directly from official source -FROM ${BASE_IMAGE} AS nodeDownloader +FROM oryx_runtime_base AS nodeDownloader ARG NODE22_VERSION WORKDIR /tmp/node-download RUN apt-get update \ @@ -31,8 +134,7 @@ RUN apt-get update \ && tar -xJf "node-v${NODE22_VERSION}-linux-x64.tar.xz" -C /opt/nodejs --strip-components=1 \ && rm -rf /tmp/node-download -#FROM oryxdevmcr.azurecr.io/private/oryx/oryx-node-run-base-bullseye:${BUILD_NUMBER} -FROM ${BASE_IMAGE} +FROM oryx_runtime_base RUN groupadd --gid 1000 node \ && useradd --uid 1000 --gid node --shell /bin/bash --create-home node diff --git a/images/runtime/node/24/noble.Dockerfile b/images/runtime/node/24/noble.Dockerfile index 39f849bcad..c258fb4251 100644 --- a/images/runtime/node/24/noble.Dockerfile +++ b/images/runtime/node/24/noble.Dockerfile @@ -1,6 +1,109 @@ -ARG BASE_IMAGE +ARG OS_TYPE=ubuntu +ARG OS_FLAVOR=noble +ARG INCLUDE_AZURELINUX_CERTS=true ARG FEED_ACCESSTOKEN +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base +ARG IMAGES_DIR=/tmp/oryx/images + +RUN apt-get update \ + && apt-get install -y \ + unzip \ + && rm -rf /var/lib/apt/lists/* + +# NOTE: This is a list of keys for ALL Node versions and also Yarn package installs. +# Receiving them once speeds up building of individual node versions as they all derive +# from this image. + +# Gpg keys listed at https://github.com/nodejs/node + +RUN ${IMAGES_DIR}/receiveGpgKeys.sh \ + 6A010C5166006599AA17F08146C2130DFD2497F5 + +ARG YARN_VERSION +ENV YARN_VERSION ${YARN_VERSION} + +COPY images/yarn-v${YARN_VERSION}.tar.gz . + +RUN mkdir -p /opt \ + && tar -xzf yarn-v$YARN_VERSION.tar.gz -C /opt/ \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarn /usr/local/bin/yarn \ + && ln -s /opt/yarn-v$YARN_VERSION/bin/yarnpkg /usr/local/bin/yarnpkg \ + && rm yarn-v$YARN_VERSION.tar.gz + # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -16,7 +119,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh node /opt/startupcmdgen/startupcmdgen # Download Node.js directly from official source -FROM ${BASE_IMAGE} AS nodeDownloader +FROM oryx_runtime_base AS nodeDownloader ARG NODE24_VERSION WORKDIR /tmp/node-download RUN apt-get update \ @@ -32,8 +135,7 @@ RUN apt-get update \ && tar -xJf "node-v${NODE24_VERSION}-linux-x64.tar.xz" -C /opt/nodejs --strip-components=1 \ && rm -rf /tmp/node-download -#FROM oryxdevmcr.azurecr.io/private/oryx/oryx-node-run-base-bullseye:${BUILD_NUMBER} -FROM ${BASE_IMAGE} +FROM oryx_runtime_base RUN groupadd --gid 1001 node \ && useradd --uid 1001 --gid node --shell /bin/bash --create-home node diff --git a/images/runtime/node/26/resolute.Dockerfile b/images/runtime/node/26/resolute.Dockerfile index a3c372144c..48250b1e1c 100644 --- a/images/runtime/node/26/resolute.Dockerfile +++ b/images/runtime/node/26/resolute.Dockerfile @@ -1,4 +1,54 @@ -ARG BASE_IMAGE +ARG OS_TYPE=ubuntu +ARG OS_FLAVOR=resolute +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_runtime_base +ARG INCLUDE_AZURELINUX_CERTS + +RUN apt-get update \ + && apt-get upgrade -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget \ + unzip \ + zstd \ + # Not shipped in Resolute, but will be required by Node runtime. It is tiny, would save from unexpected runtime failures in other frameworks too + libatomic1 \ + tzdata \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; # build the Oryx startup-script generator (the `oryx` CLI). FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -15,7 +65,7 @@ RUN chmod +x build.sh && ./build.sh node /opt/startupcmdgen/startupcmdgen # Download Node.js directly from official source and verify SHA256 -FROM ${BASE_IMAGE} AS nodeDownloader +FROM oryx_runtime_base AS nodeDownloader ARG NODE_FULL_VERSION WORKDIR /tmp/node-download RUN curl -fsSLO "https://nodejs.org/dist/v${NODE_FULL_VERSION}/node-v${NODE_FULL_VERSION}-linux-x64.tar.xz" \ @@ -30,7 +80,7 @@ RUN curl -fsSLO "https://nodejs.org/dist/v${NODE_FULL_VERSION}/node-v${NODE_FULL && rm -rf /tmp/node-download -FROM ${BASE_IMAGE} +FROM oryx_runtime_base RUN groupadd --gid 1001 node \ && useradd --uid 1001 --gid node --shell /bin/bash --create-home node diff --git a/images/runtime/node/README.md b/images/runtime/node/README.md index ee1e9c77a6..3d60011841 100644 --- a/images/runtime/node/README.md +++ b/images/runtime/node/README.md @@ -1,24 +1,21 @@ -# Node images +# Node runtime images -The Dockerfiles for our Node images are either produced by a template, which derives from the official image, or -created manually from the `buildpack-deps` base. +The active runtime Dockerfiles are checked in under each major version and OS: +20 and 22 use Bullseye/Bookworm, 24 uses Noble, and 26 uses Resolute. +Their common base and Node-specific base are stages in the same Dockerfile. +No separate base build, external `BASE_IMAGE`, or Dockerfile generator is required. -# Images derived from `buildpack-deps` +Build using the repository root as the Docker context. Supply exact Node and +tooling versions from `images/constants.yml`, and provide the configured package +feed credential using the `npmrc` BuildKit secret. -The reason we do rebuild some old images instead of relying on the official ones is security: since -the official images for older versions were made using the version of `buildpack-deps` available at the time, which -contained vulnerabilities, we rebuild them using the current version of that base image. The portion of our -Dockerfiles that install Node (which we always have in its own stage called `node-original-image`) are identical to the -ones used in the official Node image for each particular version. +The runtime retains signed Node download verification and the Go startup +generator. The Resolute profile has its own dependencies and Yarn installation; +it does not inherit the classic Node base. -# Generate images from template +## Adding a major version -Since our node images are identical except for the base image, which determines the node version, -our final node images are generated from a template file, `./template.Dockerfile`, which contains the placeholder -for the base image name. - -To generate the dockerfiles for all the images, run `./generateDockerfiles.sh`. - -## Adding new versions of Node - -To add a new Node version, add a new directory with the version name, and a base Dockerfile named `./base.Dockerfile`, that should contain the node binaries. The script `./generateDockerfiles.sh` will then produce the Dockerfile for the final image using the `./base.Dockerfile` image as its base. \ No newline at end of file +Declare its exact version and supported OS list in `images/constants.yml`, add +the corresponding runtime Dockerfile, and select it in the runtime pipeline. +Reuse the matching multi-stage profile where behavior is unchanged; preserve +intentional OS, startup-tooling, and user-ID differences. \ No newline at end of file diff --git a/images/runtime/php-fpm/8.1/bullseye.Dockerfile b/images/runtime/php-fpm/8.1/bullseye.Dockerfile index 2e2871aeb5..a3d1c82482 100644 --- a/images/runtime/php-fpm/8.1/bullseye.Dockerfile +++ b/images/runtime/php-fpm/8.1/bullseye.Dockerfile @@ -1,4 +1,153 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bullseye +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + rm -rf /var/lib/apt/lists/* + +RUN apt-get update \ + && ACCEPT_EULA=Y \ + DEBIAN_FRONTEND=noninteractive \ + apt-get upgrade --assume-yes \ + && rm -rf /var/lib/apt/lists/* # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -15,7 +164,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # do NOT merge this content with above line because the @@ -175,11 +324,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -335,67 +494,43 @@ RUN apt-mark hold msodbcsql17 msodbcsql18 odbcinst1debian2 odbcinst unixodbc uni && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h RUN set -eux; \ - if [[ $PHP_VERSION == 7.4.* || $PHP_VERSION == 8.0.* || $PHP_VERSION == 8.1.* || $PHP_VERSION == 8.2.* || $PHP_VERSION == 8.3.* ]]; then \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ - else \ - docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ - && docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ - fi - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends apache2-dev \ + && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ imap \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-source delete \ + && set -- gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip bcmath \ + pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem sysvshm pdo_odbc xsl \ + && docker-php-ext-enable "$@" +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files RUN set -eux; \ if [[ $PHP_VERSION != 8.3.* ]]; then \ - pecl install imagick && docker-php-ext-enable imagick; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imagick && docker-php-ext-enable imagick; \ fi # deprecated from 5.*, so should be avoided RUN set -eux; \ if [[ $PHP_VERSION != 5.* && $PHP_VERSION != 7.0.* ]]; then \ - pecl install mongodb && docker-php-ext-enable mongodb; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb; \ fi # https://github.com/microsoft/mysqlnd_azure, Supports 7.2*, 7.3* and 7.4* RUN set -eux; \ if [[ $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* || $PHP_VERSION == 7.4.* ]]; then \ echo "pecl/mysqlnd_azure requires PHP (version >= 7.2.*, version <= 7.99.99)"; \ - pecl install mysqlnd_azure \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mysqlnd_azure \ && docker-php-ext-enable mysqlnd_azure; \ fi @@ -404,7 +539,7 @@ RUN set -eux; \ # - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server # For php|8.1, latest stable version of pecl/sqlsrv, pecl/pdo_sqlsrv is 5.12.0 RUN set -eux; \ - pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini @@ -434,7 +569,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php-fpm/8.2/bookworm.Dockerfile b/images/runtime/php-fpm/8.2/bookworm.Dockerfile index 9f15c5bfc1..922c3053b5 100644 --- a/images/runtime/php-fpm/8.2/bookworm.Dockerfile +++ b/images/runtime/php-fpm/8.2/bookworm.Dockerfile @@ -1,4 +1,148 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bookworm +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes; \ + rm -rf /var/lib/apt/lists/* # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -15,7 +159,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # do NOT merge this content with above line because the @@ -182,11 +326,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -287,16 +441,15 @@ ENV NGINX_RUN_USER www-data # Edit the default DocumentRoot setting ENV NGINX_DOCUMENT_ROOT /home/site/wwwroot # Install NGINX version from official nginx.org repository -RUN apt-get update -RUN apt install curl gnupg2 nano -y -RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg \ - && gpg --no-default-keyring \ +RUN set -euxo pipefail; \ + curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg; \ + gpg --no-default-keyring \ --keyring /usr/share/keyrings/nginx-archive-keyring.gpg \ --list-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ - || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; } \ - && echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bookworm nginx" > /etc/apt/sources.list.d/nginx.list -RUN apt-get update -RUN yes '' | apt-get install nginx -y + || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; }; \ + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bookworm nginx" > /etc/apt/sources.list.d/nginx.list; \ + apt-get update; \ + apt-get install -y curl gnupg2 nano nginx RUN rm -f /etc/nginx/conf.d/default.conf \ && mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled COPY images/runtime/php-fpm/nginx_conf/default.conf /etc/nginx/sites-available/default @@ -344,62 +497,42 @@ RUN apt-mark hold msodbcsql17 msodbcsql18 odbcinst1debian2 odbcinst unixodbc uni && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h RUN set -eux; \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ imap \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-source delete \ + && set -- gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip bcmath \ + pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem sysvshm pdo_odbc xsl \ + && extension_dir="$(php-config --extension-dir)" \ + && for extension; do strip --strip-all "$extension_dir/$extension.so"; done \ + && docker-php-ext-enable "$@" +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files RUN set -eux; \ if [[ $PHP_VERSION != 8.3.* ]]; then \ - pecl install imagick && docker-php-ext-enable imagick; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imagick && docker-php-ext-enable imagick; \ fi # deprecated from 5.*, so should be avoided RUN set -eux; \ if [[ $PHP_VERSION != 5.* && $PHP_VERSION != 7.0.* ]]; then \ - pecl install mongodb && docker-php-ext-enable mongodb; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb; \ fi # https://github.com/microsoft/mysqlnd_azure, Supports 7.2*, 7.3* and 7.4* RUN set -eux; \ if [[ $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* || $PHP_VERSION == 7.4.* ]]; then \ echo "pecl/mysqlnd_azure requires PHP (version >= 7.2.*, version <= 7.99.99)"; \ - pecl install mysqlnd_azure \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mysqlnd_azure \ && docker-php-ext-enable mysqlnd_azure; \ fi @@ -408,7 +541,7 @@ RUN set -eux; \ # - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server # For php|8.2, latest stable version of pecl/sqlsrv, pecl/pdo_sqlsrv is 5.12.0 RUN set -eux; \ - pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini @@ -438,7 +571,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php-fpm/8.2/bullseye.Dockerfile b/images/runtime/php-fpm/8.2/bullseye.Dockerfile index 5cbadd61b9..d03e1e6bdd 100644 --- a/images/runtime/php-fpm/8.2/bullseye.Dockerfile +++ b/images/runtime/php-fpm/8.2/bullseye.Dockerfile @@ -1,4 +1,153 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bullseye +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + rm -rf /var/lib/apt/lists/* + +RUN apt-get update \ + && ACCEPT_EULA=Y \ + DEBIAN_FRONTEND=noninteractive \ + apt-get upgrade --assume-yes \ + && rm -rf /var/lib/apt/lists/* # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -15,7 +164,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ @@ -190,11 +339,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -353,59 +512,42 @@ RUN set -eux; \ apt-get update \ && apt-get upgrade -y \ && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ imap \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-source delete \ + && set -- gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip bcmath \ + pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem sysvshm pdo_odbc xsl \ + && extension_dir="$(php-config --extension-dir)" \ + && for extension; do strip --strip-all "$extension_dir/$extension.so"; done \ + && docker-php-ext-enable "$@" +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files RUN set -eux; \ if [[ $PHP_VERSION != 8.3.* ]]; then \ - pecl install imagick && docker-php-ext-enable imagick; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imagick && docker-php-ext-enable imagick; \ fi # deprecated from 5.*, so should be avoided RUN set -eux; \ if [[ $PHP_VERSION != 5.* && $PHP_VERSION != 7.0.* ]]; then \ - pecl install mongodb && docker-php-ext-enable mongodb; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb; \ fi # https://github.com/microsoft/mysqlnd_azure, Supports 7.2*, 7.3* and 7.4* RUN set -eux; \ if [[ $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* || $PHP_VERSION == 7.4.* ]]; then \ echo "pecl/mysqlnd_azure requires PHP (version >= 7.2.*, version <= 7.99.99)"; \ - pecl install mysqlnd_azure \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mysqlnd_azure \ && docker-php-ext-enable mysqlnd_azure; \ fi @@ -414,7 +556,7 @@ RUN set -eux; \ # - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server # For php|8.2, latest stable version of pecl/sqlsrv, pecl/pdo_sqlsrv is 5.12.0 RUN set -eux; \ - pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini @@ -444,7 +586,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php-fpm/8.3/bookworm.Dockerfile b/images/runtime/php-fpm/8.3/bookworm.Dockerfile index f4ba4b2da7..6a0a46a0cc 100644 --- a/images/runtime/php-fpm/8.3/bookworm.Dockerfile +++ b/images/runtime/php-fpm/8.3/bookworm.Dockerfile @@ -1,4 +1,149 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bookworm +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes; \ + rm -rf /var/lib/apt/lists/* + # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -14,7 +159,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # Install the Microsoft SQL Server PDO driver on supported versions only. @@ -182,11 +327,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -282,16 +437,15 @@ ENV NGINX_RUN_USER www-data # Edit the default DocumentRoot setting ENV NGINX_DOCUMENT_ROOT /home/site/wwwroot # Install NGINX version from official nginx.org repository -RUN apt-get update -RUN apt install curl gnupg2 nano -y -RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg \ - && gpg --no-default-keyring \ +RUN set -euxo pipefail; \ + curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg; \ + gpg --no-default-keyring \ --keyring /usr/share/keyrings/nginx-archive-keyring.gpg \ --list-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ - || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; } \ - && echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bookworm nginx" > /etc/apt/sources.list.d/nginx.list -RUN apt-get update -RUN yes '' | apt-get install nginx -y + || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; }; \ + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bookworm nginx" > /etc/apt/sources.list.d/nginx.list; \ + apt-get update; \ + apt-get install -y curl gnupg2 nano nginx RUN rm -f /etc/nginx/conf.d/default.conf \ && mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled COPY images/runtime/php-fpm/nginx_conf/default.conf /etc/nginx/sites-available/default @@ -339,62 +493,40 @@ RUN apt-mark hold msodbcsql17 msodbcsql18 odbcinst1debian2 odbcinst unixodbc uni && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h RUN set -eux; \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ imap \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-ext-enable gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip \ + bcmath pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem \ + sysvshm pdo_odbc xsl \ + && docker-php-source delete +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files RUN set -eux; \ if [[ $PHP_VERSION != 8.3.* ]]; then \ - pecl install imagick && docker-php-ext-enable imagick; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imagick && docker-php-ext-enable imagick; \ fi # deprecated from 5.*, so should be avoided RUN set -eux; \ if [[ $PHP_VERSION != 5.* && $PHP_VERSION != 7.0.* ]]; then \ - pecl install mongodb && docker-php-ext-enable mongodb; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb; \ fi # https://github.com/microsoft/mysqlnd_azure, Supports 7.2*, 7.3* and 7.4* RUN set -eux; \ if [[ $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* || $PHP_VERSION == 7.4.* ]]; then \ echo "pecl/mysqlnd_azure requires PHP (version >= 7.2.*, version <= 7.99.99)"; \ - pecl install mysqlnd_azure \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mysqlnd_azure \ && docker-php-ext-enable mysqlnd_azure; \ fi @@ -403,7 +535,7 @@ RUN set -eux; \ # - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server # Latest pecl/sqlsrv, pecl/pdo_sqlsrv requires PHP (version >= 8.3.0) RUN set -eux; \ - pecl install sqlsrv pdo_sqlsrv \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv pdo_sqlsrv \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini @@ -433,7 +565,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php-fpm/8.3/bullseye.Dockerfile b/images/runtime/php-fpm/8.3/bullseye.Dockerfile index a2d6d3614c..380df2f4a5 100644 --- a/images/runtime/php-fpm/8.3/bullseye.Dockerfile +++ b/images/runtime/php-fpm/8.3/bullseye.Dockerfile @@ -1,4 +1,148 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bullseye +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes; \ + rm -rf /var/lib/apt/lists/* # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -15,7 +159,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # do NOT merge this content with above line because the @@ -185,11 +329,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -287,16 +441,15 @@ ENV NGINX_RUN_USER www-data # Edit the default DocumentRoot setting ENV NGINX_DOCUMENT_ROOT /home/site/wwwroot # Install NGINX version from official nginx.org repository -RUN apt-get update -RUN apt install curl gnupg2 nano -y -RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg \ - && gpg --no-default-keyring \ +RUN set -euxo pipefail; \ + curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg; \ + gpg --no-default-keyring \ --keyring /usr/share/keyrings/nginx-archive-keyring.gpg \ --list-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ - || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; } \ - && echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bullseye nginx" > /etc/apt/sources.list.d/nginx.list -RUN apt-get update -RUN yes '' | apt-get install nginx -y + || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; }; \ + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bullseye nginx" > /etc/apt/sources.list.d/nginx.list; \ + apt-get update; \ + apt-get install -y curl gnupg2 nano nginx RUN rm -f /etc/nginx/conf.d/default.conf \ && mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled COPY images/runtime/php-fpm/nginx_conf/default.conf /etc/nginx/sites-available/default @@ -344,62 +497,39 @@ RUN apt-mark hold msodbcsql17 msodbcsql18 odbcinst1debian2 odbcinst unixodbc uni && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h RUN set -eux; \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ imap \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-source delete \ + && docker-php-ext-enable gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip bcmath \ + pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem sysvshm pdo_odbc xsl +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files RUN set -eux; \ if [[ $PHP_VERSION != 8.3.* ]]; then \ - pecl install imagick && docker-php-ext-enable imagick; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imagick && docker-php-ext-enable imagick; \ fi # deprecated from 5.*, so should be avoided RUN set -eux; \ if [[ $PHP_VERSION != 5.* && $PHP_VERSION != 7.0.* ]]; then \ - pecl install mongodb && docker-php-ext-enable mongodb; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb; \ fi # https://github.com/microsoft/mysqlnd_azure, Supports 7.2*, 7.3* and 7.4* RUN set -eux; \ if [[ $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* || $PHP_VERSION == 7.4.* ]]; then \ echo "pecl/mysqlnd_azure requires PHP (version >= 7.2.*, version <= 7.99.99)"; \ - pecl install mysqlnd_azure \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mysqlnd_azure \ && docker-php-ext-enable mysqlnd_azure; \ fi @@ -409,7 +539,7 @@ RUN set -eux; \ # For php|8.0, latest stable version of pecl/sqlsrv, pecl/pdo_sqlsrv is 5.11.0 RUN set -eux; \ if [[ $PHP_VERSION == 8.0.* ]]; then \ - pecl install sqlsrv-5.11.0 pdo_sqlsrv-5.11.0 \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv-5.11.0 pdo_sqlsrv-5.11.0 \ && echo extension=pdo_sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/20-sqlsrv.ini; \ fi @@ -417,7 +547,7 @@ RUN set -eux; \ # Latest pecl/sqlsrv, pecl/pdo_sqlsrv requires PHP (version >= 8.1.0) RUN set -eux; \ if [[ $PHP_VERSION == 8.1.* || $PHP_VERSION == 8.2.* || $PHP_VERSION == 8.3.* ]]; then \ - pecl install sqlsrv pdo_sqlsrv \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv pdo_sqlsrv \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini; \ fi @@ -448,7 +578,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php-fpm/8.4/bookworm.Dockerfile b/images/runtime/php-fpm/8.4/bookworm.Dockerfile index 16c4118114..a3e1335dea 100644 --- a/images/runtime/php-fpm/8.4/bookworm.Dockerfile +++ b/images/runtime/php-fpm/8.4/bookworm.Dockerfile @@ -1,4 +1,149 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bookworm +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes; \ + rm -rf /var/lib/apt/lists/* + # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -14,7 +159,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # Install the Microsoft SQL Server PDO driver on supported versions only. @@ -182,11 +327,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -282,16 +437,15 @@ ENV NGINX_RUN_USER www-data # Edit the default DocumentRoot setting ENV NGINX_DOCUMENT_ROOT /home/site/wwwroot # Install NGINX version from official nginx.org repository -RUN apt-get update -RUN apt install curl gnupg2 nano -y -RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg \ - && gpg --no-default-keyring \ +RUN set -euxo pipefail; \ + curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg; \ + gpg --no-default-keyring \ --keyring /usr/share/keyrings/nginx-archive-keyring.gpg \ --list-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ - || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; } \ - && echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bookworm nginx" > /etc/apt/sources.list.d/nginx.list -RUN apt-get update -RUN yes '' | apt-get install nginx -y + || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; }; \ + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bookworm nginx" > /etc/apt/sources.list.d/nginx.list; \ + apt-get update; \ + apt-get install -y curl gnupg2 nano nginx RUN rm -f /etc/nginx/conf.d/default.conf \ && mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled COPY images/runtime/php-fpm/nginx_conf/default.conf /etc/nginx/sites-available/default @@ -339,46 +493,21 @@ RUN apt-mark hold msodbcsql17 msodbcsql18 odbcinst1debian2 odbcinst unixodbc uni && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h RUN set -eux; \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - # From php 8.4 version imap is removed from php core and moved to pecl - # && PHP_OPENSSL=yes \docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ - && pecl install imap - -#33 2.797 bcmath bz2 calendar ctype curl dba dl_test dom enchant exif ffi fileinfo filter ftp gd gettext gmp hash iconv intl json ldap mbstring mysqli odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix random readline reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer xml xmlreader xmlwriter xsl zend_test zip - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imap \ + && docker-php-source extract \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-ext-enable gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip \ + bcmath pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem \ + sysvshm pdo_odbc xsl \ + && docker-php-source delete +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files @@ -388,11 +517,11 @@ RUN pecl install redis && docker-php-ext-enable redis # deprecated from 5.*, so should be avoided RUN set -eux; \ - pecl install mongodb && docker-php-ext-enable mongodb + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb # Latest pecl/sqlsrv, pecl/pdo_sqlsrv requires PHP (version >= 8.3.0) RUN set -eux; \ - pecl install sqlsrv pdo_sqlsrv \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv pdo_sqlsrv \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini @@ -422,7 +551,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php-fpm/8.4/bullseye.Dockerfile b/images/runtime/php-fpm/8.4/bullseye.Dockerfile index cc93201cdd..78ffd88369 100644 --- a/images/runtime/php-fpm/8.4/bullseye.Dockerfile +++ b/images/runtime/php-fpm/8.4/bullseye.Dockerfile @@ -1,4 +1,148 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bullseye +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes; \ + rm -rf /var/lib/apt/lists/* # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -15,7 +159,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # do NOT merge this content with above line because the @@ -185,11 +329,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -287,16 +441,15 @@ ENV NGINX_RUN_USER www-data # Edit the default DocumentRoot setting ENV NGINX_DOCUMENT_ROOT /home/site/wwwroot # Install NGINX version from official nginx.org repository -RUN apt-get update -RUN apt install curl gnupg2 nano -y -RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg \ - && gpg --no-default-keyring \ +RUN set -euxo pipefail; \ + curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg; \ + gpg --no-default-keyring \ --keyring /usr/share/keyrings/nginx-archive-keyring.gpg \ --list-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ - || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; } \ - && echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bullseye nginx" > /etc/apt/sources.list.d/nginx.list -RUN apt-get update -RUN yes '' | apt-get install nginx -y + || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; }; \ + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/debian bullseye nginx" > /etc/apt/sources.list.d/nginx.list; \ + apt-get update; \ + apt-get install -y curl gnupg2 nano nginx RUN rm -f /etc/nginx/conf.d/default.conf \ && mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled COPY images/runtime/php-fpm/nginx_conf/default.conf /etc/nginx/sites-available/default @@ -344,44 +497,21 @@ RUN apt-mark hold msodbcsql17 msodbcsql18 odbcinst1debian2 odbcinst unixodbc uni && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h RUN set -eux; \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ # From php 8.4 version imap is removed from php core and moved to pecl - # && PHP_OPENSSL=yes \docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ - && pecl install imap - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imap \ + && docker-php-source extract \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-source delete \ + && docker-php-ext-enable gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip bcmath \ + pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem sysvshm pdo_odbc xsl +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files @@ -391,11 +521,11 @@ RUN pecl install redis && docker-php-ext-enable redis # deprecated from 5.*, so should be avoided RUN set -eux; \ - pecl install mongodb && docker-php-ext-enable mongodb + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb # Latest pecl/sqlsrv, pecl/pdo_sqlsrv requires PHP (version >= 8.3.0) RUN set -eux; \ - pecl install sqlsrv pdo_sqlsrv \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv pdo_sqlsrv \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini @@ -425,7 +555,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php-fpm/8.5/noble.Dockerfile b/images/runtime/php-fpm/8.5/noble.Dockerfile index b5d28541c4..f08fb5153d 100644 --- a/images/runtime/php-fpm/8.5/noble.Dockerfile +++ b/images/runtime/php-fpm/8.5/noble.Dockerfile @@ -1,4 +1,152 @@ -ARG BASE_IMAGE +ARG OS_TYPE=ubuntu +ARG OS_FLAVOR=noble +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN set -eux; \ + apt-get update; \ + apt-get upgrade -y; \ + apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget; \ + if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi; \ + if [ "${OS_FLAVOR}" = "bookworm" ]; then \ + apt-get update; \ + apt-get install -y --no-install-recommends sq; \ + fi; \ + rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh; \ + rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +# Note: libjpeg62-turbo-dev is for Debian, libjpeg-turbo8-dev is for Ubuntu +ARG OS_TYPE +RUN set -eux; \ + apt-get update; \ + apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + $([ "$OS_TYPE" = "debian" ] && echo "libjpeg62-turbo-dev") \ + $([ "$OS_TYPE" = "ubuntu" ] && echo "libjpeg-turbo8-dev") \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + curl \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + libargon2-dev \ + libssl-dev \ + libxml2-dev \ + ; \ + # These core build dependencies were previously installed as automatic packages. + apt-mark auto libargon2-dev libssl-dev libxml2-dev; \ + ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes; \ + rm -rf /var/lib/apt/lists/* + # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -14,7 +162,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # Install the Microsoft SQL Server PDO driver on supported versions only. @@ -29,7 +177,8 @@ RUN set -eux \ && curl https://packages.microsoft.com/config/ubuntu/24.04/prod.list > /etc/apt/sources.list.d/mssql-release.list \ && curl -fsSL https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor -o /usr/share/keyrings/microsoft-prod.gpg \ && apt-get update \ - && ACCEPT_EULA=Y apt-get install -y msodbcsql18=18.6.1.1-1 libodbcinst2=2.3.12-1ubuntu0.24.04.1 odbcinst=2.3.12-1ubuntu0.24.04.1 unixodbc=2.3.12-1ubuntu0.24.04.1 unixodbc-dev=2.3.12-1ubuntu0.24.04.1 + && ACCEPT_EULA=Y apt-get install -y msodbcsql18=18.6.1.1-1 libodbcinst2=2.3.12-1ubuntu0.24.04.1 odbcinst=2.3.12-1ubuntu0.24.04.1 unixodbc=2.3.12-1ubuntu0.24.04.1 unixodbc-dev=2.3.12-1ubuntu0.24.04.1 \ + && rm -rf /var/lib/apt/lists/* ENV PHP_INI_DIR=/usr/local/etc/php RUN set -eux; \ @@ -68,9 +217,6 @@ ENV PHP_SOURCE_BASE_URL=${PHP_SOURCE_BASE_URL} RUN set -eux; \ \ savedAptMark="$(apt-mark showmanual)"; \ - apt-get update; \ - apt-get install -y --no-install-recommends gnupg dirmngr; \ - rm -rf /var/lib/apt/lists/*; \ \ mkdir -p /usr/src; \ cd /usr/src; \ @@ -111,20 +257,11 @@ RUN set -eux; \ \ savedAptMark="$(apt-mark showmanual)"; \ - apt-get update; \ - apt-get install -y --no-install-recommends \ - libargon2-dev \ - libcurl4-openssl-dev \ - libedit-dev \ - libonig-dev \ - libsodium-dev \ - libsqlite3-dev \ - libssl-dev \ - libxml2-dev \ - zlib1g-dev \ - ${PHP_EXTRA_BUILD_DEPS:-} \ - ; \ - rm -rf /var/lib/apt/lists/*; \ + if [ -n "${PHP_EXTRA_BUILD_DEPS:-}" ]; then \ + apt-get update; \ + apt-get install -y --no-install-recommends $PHP_EXTRA_BUILD_DEPS; \ + rm -rf /var/lib/apt/lists/*; \ + fi; \ \ export \ CFLAGS="$PHP_CFLAGS" \ @@ -182,11 +319,20 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -283,16 +429,18 @@ ENV NGINX_RUN_USER=www-data # Edit the default DocumentRoot setting ENV NGINX_DOCUMENT_ROOT=/home/site/wwwroot # Install NGINX version from official nginx.org repository -RUN apt-get update -RUN apt install curl gnupg2 nano -y -RUN curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg \ - && gpg --no-default-keyring \ +RUN set -euxo pipefail; \ + curl -fsSL https://nginx.org/keys/nginx_signing.key | gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg; \ + gpg --no-default-keyring \ --keyring /usr/share/keyrings/nginx-archive-keyring.gpg \ --list-keys 573BFD6B3D8FBC641079A6ABABF5BD827BD9BF62 \ - || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; } \ - && echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/ubuntu noble nginx" > /etc/apt/sources.list.d/nginx.list -RUN apt-get update -RUN apt-get install -y nginx + || { echo "ERROR: nginx signing key fingerprint mismatch"; exit 1; }; \ + echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/ubuntu noble nginx" > /etc/apt/sources.list.d/nginx.list; \ + apt-get update; \ + apt-get install -y curl gnupg2 nano nginx; \ + apt-mark hold msodbcsql18 unixodbc unixodbc-dev; \ + apt-get upgrade -y; \ + rm -rf /var/lib/apt/lists/* RUN rm -f /etc/nginx/conf.d/default.conf \ && mkdir -p /etc/nginx/sites-available /etc/nginx/sites-enabled COPY images/runtime/php-fpm/nginx_conf/default.conf /etc/nginx/sites-available/default @@ -331,53 +479,26 @@ RUN nginx -t ENV NGINX_PORT=8080 # Install common PHP extensions -# TEMPORARY: Holding odbc related packages from upgrading. -RUN apt-mark hold msodbcsql18 unixodbc unixodbc-dev \ - && apt-get update \ - && apt-get upgrade -y \ - && ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ +RUN ln -s /usr/lib/x86_64-linux-gnu/libldap.so /usr/lib/libldap.so \ && ln -s /usr/lib/x86_64-linux-gnu/liblber.so /usr/lib/liblber.so \ && ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h +# IMAP is external from PHP 8.4 onward. RUN set -eux; \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - # From php 8.4 version imap is removed from php core and moved to pecl - # && PHP_OPENSSL=yes \docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ - && pecl install imap - -#33 2.797 bcmath bz2 calendar ctype curl dba dl_test dom enchant exif ffi fileinfo filter ftp gd gettext gmp hash iconv intl json ldap mbstring mysqli odbc opcache pcntl pdo pdo_dblib pdo_firebird pdo_mysql pdo_odbc pdo_pgsql pdo_sqlite pgsql phar posix random readline reflection session shmop simplexml snmp soap sockets sodium spl standard sysvmsg sysvsem sysvshm tidy tokenizer xml xmlreader xmlwriter xsl zend_test zip - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - pdo \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imap \ + && docker-php-source extract \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ - pcntl \ - calendar \ - exif \ - gettext \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# xmlrpc \ - xsl -RUN pecl install redis && docker-php-ext-enable redis + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-source delete \ + && docker-php-ext-enable gd mysqli pdo_pgsql pgsql ldap intl gmp zip \ + bcmath pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem \ + sysvshm pdo_odbc xsl +RUN MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files @@ -387,11 +508,11 @@ RUN pecl install redis && docker-php-ext-enable redis # deprecated from 5.*, so should be avoided RUN set -eux; \ - pecl install mongodb && docker-php-ext-enable mongodb + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb # Latest pecl/sqlsrv, pecl/pdo_sqlsrv requires PHP (version >= 8.3.0) RUN set -eux; \ - pecl install sqlsrv pdo_sqlsrv \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv pdo_sqlsrv \ && echo extension=pdo_sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||" -e "s/\"//g")/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||" -e "s/\"//g")/20-sqlsrv.ini @@ -420,7 +541,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* ENV LANG="C.UTF-8" \ diff --git a/images/runtime/php/8.2/bullseye.Dockerfile b/images/runtime/php/8.2/bullseye.Dockerfile index a2ef643179..9075058dd2 100644 --- a/images/runtime/php/8.2/bullseye.Dockerfile +++ b/images/runtime/php/8.2/bullseye.Dockerfile @@ -1,4 +1,150 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bullseye +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +RUN set -eux; \ + apt-get update; \ + apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + rm -rf /var/lib/apt/lists/* + +RUN apt-get update \ + && ACCEPT_EULA=Y \ + DEBIAN_FRONTEND=noninteractive \ + apt-get upgrade --assume-yes \ + && rm -rf /var/lib/apt/lists/* # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bullseye as startupCmdGen @@ -15,7 +161,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # Install the Microsoft SQL Server PDO driver on supported versions only. @@ -236,9 +382,9 @@ RUN set -eux; \ \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -335,10 +481,9 @@ RUN set -eux; \ else \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ - fi - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ + fi \ + && docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ + && set -- gd \ mysqli \ opcache \ pdo \ @@ -367,32 +512,37 @@ RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ # deprecated from 7.4, so should be avoided in general template for all php versions # wddx \ # xmlrpc \ - xsl + xsl \ + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-source delete RUN set -eux; \ if [[ $PHP_VERSION != 5.* ]]; then \ - pecl install redis && docker-php-ext-enable redis; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis; \ fi # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files RUN set -eux; \ if [[ $PHP_VERSION != 8.3.* ]]; then \ - pecl install imagick && docker-php-ext-enable imagick; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imagick && docker-php-ext-enable imagick; \ fi # deprecated from 5.*, so should be avoided RUN set -eux; \ if [[ $PHP_VERSION != 5.* && $PHP_VERSION != 7.0.* ]]; then \ echo "pecl/mongodb requires PHP (version >= 7.1.0, version <= 7.99.99)"; \ - pecl install mongodb && docker-php-ext-enable mongodb; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb; \ fi # https://github.com/microsoft/mysqlnd_azure, Supports 7.2*, 7.3* and 7.4* RUN set -eux; \ if [[ $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* || $PHP_VERSION == 7.4.* ]]; then \ echo "pecl/mysqlnd_azure requires PHP (version >= 7.2.*, version <= 7.99.99)"; \ - pecl install mysqlnd_azure \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mysqlnd_azure \ && docker-php-ext-enable mysqlnd_azure; \ fi @@ -402,7 +552,7 @@ RUN set -eux; \ # For php|8.0, latest stable version of pecl/sqlsrv, pecl/pdo_sqlsrv is 5.11.0 RUN set -eux; \ if [[ $PHP_VERSION == 8.0.* ]]; then \ - pecl install sqlsrv-5.11.0 pdo_sqlsrv-5.11.0 \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv-5.11.0 pdo_sqlsrv-5.11.0 \ && echo extension=pdo_sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/20-sqlsrv.ini; \ fi @@ -410,7 +560,7 @@ RUN set -eux; \ # PHP 8.2 requires SQL Server drivers 5.12.0; newer drivers require PHP 8.3. RUN set -eux; \ if [[ $PHP_VERSION == 8.1.* || $PHP_VERSION == 8.2.* || $PHP_VERSION == 8.3.* ]]; then \ - pecl install sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv-5.12.0 pdo_sqlsrv-5.12.0 \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini; \ fi @@ -440,7 +590,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* RUN rm -rf /tmp/oryx diff --git a/images/runtime/php/8.3/bookworm.Dockerfile b/images/runtime/php/8.3/bookworm.Dockerfile index 6174ff0995..65ff66b0f1 100644 --- a/images/runtime/php/8.3/bookworm.Dockerfile +++ b/images/runtime/php/8.3/bookworm.Dockerfile @@ -1,4 +1,145 @@ -ARG BASE_IMAGE +ARG OS_TYPE=debian +ARG OS_FLAVOR=bookworm +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_run_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; + +FROM oryx_run_base AS oryx_runtime_base + +# prevent Debian's PHP packages from being installed +# https://github.com/docker-library/php/pull/542 +RUN set -eux; \ + { \ + echo 'Package: php*'; \ + echo 'Pin: release *'; \ + echo 'Pin-Priority: -1'; \ + } > /etc/apt/preferences.d/no-debian-php + +# dependencies required for running "phpize" +# (see persistent deps below) +ENV PHPIZE_DEPS \ + autoconf \ + dpkg-dev \ + file \ + g++ \ + gcc \ + libc-dev \ + make \ + pkg-config \ + re2c + +# persistent / runtime deps +RUN set -eux; \ + apt-get update; \ + apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + $PHPIZE_DEPS \ + ca-certificates \ + curl \ + xz-utils \ + libzip-dev \ + libpng-dev \ + libjpeg-dev \ + libpq-dev \ + libldap2-dev \ + libldb-dev \ + libicu-dev \ + libgmp-dev \ + libmagickwand-dev \ + libc-client-dev \ + libtidy-dev \ + libkrb5-dev \ + libxslt-dev \ + openssh-server \ + vim \ + wget \ + tcptraceroute \ + mariadb-client \ + openssl \ + libedit-dev \ + libsodium-dev \ + libfreetype6-dev \ + libjpeg62-turbo-dev \ + libonig-dev \ + libcurl4-openssl-dev \ + libldap2-dev \ + zlib1g-dev \ + apache2-dev \ + libsqlite3-dev \ + ; \ + ACCEPT_EULA=Y DEBIAN_FRONTEND=noninteractive apt-get upgrade --assume-yes; \ + rm -rf /var/lib/apt/lists/* # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -15,7 +156,7 @@ ENV BUILD_NUMBER=${BUILD_NUMBER} RUN chmod +x build.sh && ./build.sh php /opt/startupcmdgen/startupcmdgen # From https://github.com/docker-library/php.git -FROM ${BASE_IMAGE} +FROM oryx_runtime_base ARG IMAGES_DIR=/tmp/oryx/images # Install the Microsoft SQL Server PDO driver on supported versions only. @@ -234,11 +375,21 @@ RUN set -eux; \ $(test "$gnuArch" = 's390x-linux-gnu' && echo '--without-pcre-jit') \ --with-libdir="lib/$debMultiarch" \ \ + --enable-gd=shared --with-freetype --with-jpeg \ + --with-mysqli=shared --enable-opcache=shared \ + --with-pdo-pgsql=shared --with-pgsql=shared \ + --with-ldap=shared --enable-intl=shared --with-gmp=shared \ + --with-zip=shared --enable-bcmath=shared --enable-pcntl=shared \ + --enable-calendar=shared --enable-exif=shared --with-gettext=shared \ + --with-tidy=shared --enable-shmop=shared --enable-soap=shared \ + --enable-sysvmsg=shared --enable-sysvsem=shared --enable-sysvshm=shared \ + --with-pdo-odbc=shared,unixODBC,/usr --with-xsl=shared \ + \ ${PHP_EXTRA_CONFIGURE_ARGS:-} \ ; \ - make -j "$(nproc)"; \ + make -f Makefile -f "${IMAGES_DIR}/runtime/php/build-order.mk" -j "$(nproc)" oryx-runtime; \ find -type f -name '*.a' -delete; \ - make install; \ + make install INSTALL="install -c"; \ find /usr/local/bin /usr/local/sbin -type f -executable -exec strip --strip-all '{}' + || true; \ make clean; \ \ @@ -328,72 +479,49 @@ RUN apt-mark hold msodbcsql17 msodbcsql18 odbcinst1debian2 odbcinst unixodbc uni RUN set -eux; \ if [[ $PHP_VERSION == 7.4.* || $PHP_VERSION == 8.0.* || $PHP_VERSION == 8.1.* || $PHP_VERSION == 8.2.* || $PHP_VERSION == 8.3.* ]]; then \ - apt-get update \ - && apt-get upgrade -y \ - && apt-get install -y --no-install-recommends apache2-dev \ - && docker-php-ext-configure gd --with-freetype --with-jpeg \ - && PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ + PHP_OPENSSL=yes docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ else \ docker-php-ext-configure gd --with-png-dir=/usr --with-jpeg-dir=/usr \ && docker-php-ext-configure imap --with-kerberos --with-imap-ssl ; \ - fi - -RUN docker-php-ext-configure pdo_odbc --with-pdo-odbc=unixODBC,/usr \ - && docker-php-ext-install gd \ - mysqli \ - opcache \ - pdo \ + fi \ + && set -- pdo \ pdo_mysql \ - pdo_pgsql \ - pgsql \ - ldap \ - intl \ - gmp \ - zip \ - bcmath \ mbstring \ - pcntl \ - calendar \ - exif \ - gettext \ imap \ - tidy \ - shmop \ - soap \ sockets \ - sysvmsg \ - sysvsem \ - sysvshm \ - pdo_odbc \ -# deprecated from 7.4, so should be avoided in general template for all php versions -# wddx \ -# xmlrpc \ - xsl + && printf '%s\n' "$@" | xargs -r -n1 -P4 sh -ec \ + 'cd "/usr/src/php/ext/$2"; [ -e Makefile ] || docker-php-ext-configure "$2"; make -j"$1"' \ + -- "$(( ($(nproc) + 3) / 4 ))" \ + && docker-php-ext-install -j "$(nproc)" "$@" \ + && docker-php-ext-enable gd mysqli opcache pdo_pgsql pgsql ldap intl gmp zip \ + bcmath pcntl calendar exif gettext tidy shmop soap sysvmsg sysvsem \ + sysvshm pdo_odbc xsl \ + && docker-php-source delete RUN set -eux; \ if [[ $PHP_VERSION != 5.* ]]; then \ - pecl install redis && docker-php-ext-enable redis; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" redis && docker-php-ext-enable redis; \ fi # https://github.com/Imagick/imagick/issues/331 # https://github.com/ihneo/php/pull/24/files RUN set -eux; \ if [[ $PHP_VERSION != 8.3.* ]]; then \ - pecl install imagick && docker-php-ext-enable imagick; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" imagick && docker-php-ext-enable imagick; \ fi # deprecated from 5.*, so should be avoided RUN set -eux; \ if [[ $PHP_VERSION != 5.* && $PHP_VERSION != 7.0.* ]]; then \ echo "pecl/mongodb requires PHP (version >= 7.1.0, version <= 7.99.99)"; \ - pecl install mongodb && docker-php-ext-enable mongodb; \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mongodb && docker-php-ext-enable mongodb; \ fi # https://github.com/microsoft/mysqlnd_azure, Supports 7.2*, 7.3* and 7.4* RUN set -eux; \ if [[ $PHP_VERSION == 7.2.* || $PHP_VERSION == 7.3.* || $PHP_VERSION == 7.4.* ]]; then \ echo "pecl/mysqlnd_azure requires PHP (version >= 7.2.*, version <= 7.99.99)"; \ - pecl install mysqlnd_azure \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" mysqlnd_azure \ && docker-php-ext-enable mysqlnd_azure; \ fi @@ -403,7 +531,7 @@ RUN set -eux; \ # For php|8.0, latest stable version of pecl/sqlsrv, pecl/pdo_sqlsrv is 5.11.0 RUN set -eux; \ if [[ $PHP_VERSION == 8.0.* ]]; then \ - pecl install sqlsrv-5.11.0 pdo_sqlsrv-5.11.0 \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv-5.11.0 pdo_sqlsrv-5.11.0 \ && echo extension=pdo_sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> $(php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||")/20-sqlsrv.ini; \ fi @@ -411,7 +539,7 @@ RUN set -eux; \ # Latest pecl/sqlsrv, pecl/pdo_sqlsrv requires PHP (version >= 8.1.0) RUN set -eux; \ if [[ $PHP_VERSION == 8.1.* || $PHP_VERSION == 8.2.* || $PHP_VERSION == 8.3.* ]]; then \ - pecl install sqlsrv pdo_sqlsrv \ + MAKEFLAGS="-j$(nproc)" "${IMAGES_DIR}/runtime/php/install-pecl.sh" sqlsrv pdo_sqlsrv \ && echo extension=pdo_sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/30-pdo_sqlsrv.ini \ && echo extension=sqlsrv.so >> `php --ini | grep "Scan for additional .ini files" | sed -e "s|.*:\s*||"`/20-sqlsrv.ini; \ fi @@ -441,7 +569,9 @@ RUN set -x \ && sed -ri 's@^ *test +"\$PHP_.*" *= *"no" *&& *PHP_.*=yes *$@#&@g' configure \ && chmod +x ./configure \ && ./configure --with-unixODBC=shared,/usr \ - && docker-php-ext-install odbc \ + && docker-php-ext-install -j "$(nproc)" odbc \ + && cd / \ + && docker-php-source delete \ && rm -rf /var/lib/apt/lists/* RUN rm -rf /tmp/oryx diff --git a/images/runtime/php/build-order.mk b/images/runtime/php/build-order.mk new file mode 100644 index 0000000000..16c1d10632 --- /dev/null +++ b/images/runtime/php/build-order.mk @@ -0,0 +1,5 @@ +# Start the longest translation units early, using only configured JIT objects. +.PHONY: oryx-runtime +oryx-runtime: Zend/zend_execute.lo \ + $(filter ext/opcache/jit/zend_jit.lo ext/opcache/jit/ir/ir.lo ext/opcache/jit/ir/ir_emit.lo,$(PHP_GLOBAL_OBJS) $(shared_objects_opcache)) \ + all diff --git a/images/runtime/php/install-pecl.sh b/images/runtime/php/install-pecl.sh new file mode 100644 index 0000000000..672605a858 --- /dev/null +++ b/images/runtime/php/install-pecl.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT license. +# -------------------------------------------------------------------------------------------- + +set -euo pipefail + +if [ "$#" -eq 0 ]; then + echo "Usage: install-pecl.sh package [package ...]" >&2 + exit 2 +fi + +downloadDir=$(mktemp -d) +trap 'rm -rf -- "$downloadDir"' EXIT +archives=() + +for package in "$@"; do + for attempt in 1 2 3; do + mkdir "$downloadDir/${#archives[@]}-$attempt" + cd "$downloadDir/${#archives[@]}-$attempt" + if pecl download "$package"; then + files=("$PWD"/*.tgz) + if [ "${#files[@]}" -ne 1 ] || [ ! -s "${files[0]}" ]; then + echo "PECL download did not produce one archive for $package" >&2 + exit 1 + fi + archives+=("${files[0]}") + break + else + status=$? + fi + if [ "$attempt" -eq 3 ]; then + echo "PECL download failed for $package after $attempt attempts" >&2 + exit "$status" + fi + echo "PECL download failed for $package (attempt $attempt); retrying" >&2 + sleep "$((attempt * 2))" + done +done + +# Retry only network acquisition, never compilation or installation failures. +pecl install "${archives[@]}" diff --git a/images/runtime/python/noble.Dockerfile b/images/runtime/python/noble.Dockerfile index 0a0f585f08..a773e3effb 100644 --- a/images/runtime/python/noble.Dockerfile +++ b/images/runtime/python/noble.Dockerfile @@ -1,5 +1,79 @@ +ARG OS_TYPE=ubuntu +ARG OS_FLAVOR=noble +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_runtime_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS ARG OS_FLAVOR -ARG BASE_IMAGE + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-bookworm as startupCmdGen @@ -18,7 +92,7 @@ ENV PATH_CA_CERTIFICATE="/etc/ssl/certs/ca-certificate.crt" RUN chmod +x build.sh && ./build.sh python /opt/startupcmdgen/startupcmdgen # Build Python SDK from source in a disposable stage -FROM ${BASE_IMAGE} AS pythonSdkBuilder +FROM oryx_runtime_base AS pythonSdkBuilder ARG OS_FLAVOR ARG PYTHON_FULL_VERSION ARG PYTHON_VERSION @@ -35,7 +109,7 @@ RUN set -e \ && export OS_FLAVOR=${OS_FLAVOR} \ && /tmp/build.sh -FROM ${BASE_IMAGE} as main +FROM oryx_runtime_base AS main ARG IMAGES_DIR=/tmp/oryx/images @@ -53,6 +127,8 @@ RUN apt-get update \ ADD images ${IMAGES_DIR} RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN ${IMAGES_DIR}/runtime/python/install-dependencies.sh + ARG PYTHON_FULL_VERSION ARG PYTHON_VERSION ARG PYTHON_MAJOR_VERSION @@ -85,7 +161,6 @@ ENV PATH_CA_CERTIFICATE="/etc/ssl/certs/ca-certificate.crt" ENV CNB_STACK_ID="oryx.stacks.skeleton" LABEL io.buildpacks.stack.id="oryx.stacks.skeleton" -RUN ${IMAGES_DIR}/runtime/python/install-dependencies.sh RUN --mount=type=secret,id=pip_index_url,target=/run/secrets/pip_index_url \ pip install --index-url $(cat /run/secrets/pip_index_url) --upgrade pip && \ pip install --index-url $(cat /run/secrets/pip_index_url) gunicorn uvicorn==0.46.0 uvicorn-worker==0.4.0 debugpy viztracer==0.15.6 vizplugins==0.1.3 && \ diff --git a/images/runtime/python/resolute-based/resolute.Dockerfile b/images/runtime/python/resolute-based/resolute.Dockerfile index 3d3e4ef737..4047c0d68c 100644 --- a/images/runtime/python/resolute-based/resolute.Dockerfile +++ b/images/runtime/python/resolute-based/resolute.Dockerfile @@ -1,5 +1,54 @@ -ARG OS_FLAVOR -ARG BASE_IMAGE +ARG OS_TYPE=ubuntu +ARG OS_FLAVOR=resolute +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_runtime_base +ARG INCLUDE_AZURELINUX_CERTS + +RUN apt-get update \ + && apt-get upgrade -y \ + && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget \ + unzip \ + zstd \ + # Not shipped in Resolute, but will be required by Node runtime. It is tiny, would save from unexpected runtime failures in other frameworks too + libatomic1 \ + tzdata \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; # ----------------------------------------------------------------------------- # Stage 1: build the Oryx startup-script generator (the `oryx` CLI) @@ -24,7 +73,7 @@ RUN chmod +x build.sh && ./build.sh python /opt/startupcmdgen/startupcmdgen # build.sh now parses versionsToBuild.txt itself (gpg key + sha256). # Inputs are passed as ENV (ARGs are not visible to scripts). # ----------------------------------------------------------------------------- -FROM ${BASE_IMAGE} AS pythonRuntimeBinariesBuilder +FROM oryx_runtime_base AS pythonRuntimeBinariesBuilder ARG OS_FLAVOR ARG PYTHON_FULL_VERSION ENV OS_FLAVOR=${OS_FLAVOR} @@ -53,7 +102,7 @@ RUN chmod +x /tmp/build.sh /tmp/receiveGpgKeys.sh \ # 5. COPY oryx CLI (per-build, tiny -> last) # ----------------------------------------------------------------------------- -FROM ${BASE_IMAGE} as main +FROM oryx_runtime_base AS main ARG OS_FLAVOR ENV OS_FLAVOR=${OS_FLAVOR} diff --git a/images/runtime/python/template.Dockerfile b/images/runtime/python/template.Dockerfile index 21e4d91e83..e4f5cfc81c 100644 --- a/images/runtime/python/template.Dockerfile +++ b/images/runtime/python/template.Dockerfile @@ -1,5 +1,80 @@ -ARG DEBIAN_FLAVOR -ARG BASE_IMAGE +ARG DEBIAN_FLAVOR=bullseye +ARG OS_TYPE=debian +ARG OS_FLAVOR=${DEBIAN_FLAVOR} +ARG INCLUDE_AZURELINUX_CERTS=true + +# Stage: (optional) pull Azure Linux CA certificates so we can merge them into BaseOS trust store +# Debian images (especially slim variants) can lag in ca-certificates updates; we optionally add Azure Linux certs. +FROM mcr.microsoft.com/azurelinux/base/core:3.0 AS azurelinux-core +ARG INCLUDE_AZURELINUX_CERTS +COPY images/runtime/certs/blocklist/ /etc/pki/ca-trust/source/blacklist/ +COPY images/runtime/scripts/install-azurelinux-ca-packages.sh /usr/local/bin/ +RUN if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + set -eux; \ + sh /usr/local/bin/install-azurelinux-ca-packages.sh; \ + fi + +FROM mcr.microsoft.com/mirror/docker/library/${OS_TYPE}:${OS_FLAVOR} AS oryx_runtime_base +ARG IMAGES_DIR=/tmp/oryx/images +ARG BUILD_DIR=/tmp/oryx/build +ARG INCLUDE_AZURELINUX_CERTS +ARG OS_FLAVOR + +COPY images/runtime/scripts/configure-debian-bullseye-snapshot.sh /usr/local/bin/ +# TODO: Remove this once Debian Bullseye and Bookworm provide tzdata 2026e-1 or newer. +COPY images/runtime/scripts/install-debian-tzdata-2026e.sh /usr/local/bin/ +RUN if [ "${OS_FLAVOR}" = "bullseye" ]; then \ + chmod +x /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + /usr/local/bin/configure-debian-bullseye-snapshot.sh; \ + fi + +RUN apt-get update \ + && apt-get upgrade -y \ + && apt-get install -y --no-install-recommends \ + xz-utils \ + ca-certificates \ + curl \ + gnupg \ + netbase \ + wget + +RUN if [ "${OS_FLAVOR}" = "bullseye" ] || [ "${OS_FLAVOR}" = "bookworm" ]; then \ + chmod +x /usr/local/bin/install-debian-tzdata-2026e.sh; \ + /usr/local/bin/install-debian-tzdata-2026e.sh; \ + elif [ "${OS_FLAVOR}" = "noble" ] || [ "${OS_FLAVOR}" = "resolute" ]; then \ + apt-get update; \ + DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends tzdata; \ + fi + +RUN if [ "${OS_FLAVOR}" = "bookworm" ] ; then \ + apt-get update && apt-get install -y --no-install-recommends sq ; \ + fi + +RUN rm -f /usr/local/bin/configure-debian-bullseye-snapshot.sh /usr/local/bin/install-debian-tzdata-2026e.sh \ + && rm -rf /var/lib/apt/lists/* + +# Copy Azure linux certs to a temporary location +RUN mkdir -p /tmp/azurelinux-ca-certs && \ + chmod 755 /tmp/azurelinux-ca-certs; +COPY --from=azurelinux-core /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem /tmp/azurelinux-ca-certs/tls-ca-bundle.pem + +COPY images/runtime/scripts/install-azurelinux-certs.sh /usr/local/bin/install-azurelinux-certs.sh + +# Add Azure Linux certs to Debian's CA store if the flag is set to true +RUN set -e; \ + if [ "$(printf '%s' "$INCLUDE_AZURELINUX_CERTS" | tr '[:upper:]' '[:lower:]')" = "true" ]; then \ + chmod +x /usr/local/bin/install-azurelinux-certs.sh; \ + /usr/local/bin/install-azurelinux-certs.sh /tmp/azurelinux-ca-certs /tmp/azurelinux-ca-certs/tls-ca-bundle.pem; \ + fi; + +# Cleanup script and temporary files +RUN rm -f /usr/local/bin/install-azurelinux-certs.sh; \ + rm -rf /tmp/azurelinux-ca-certs; + +ADD images ${IMAGES_DIR} +ADD build ${BUILD_DIR} +RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN find ${BUILD_DIR} -type f -iname "*.sh" -exec chmod +x {} \; # Startup script generator FROM mcr.microsoft.com/oss/go/microsoft/golang:1.26-${DEBIAN_FLAVOR} as startupCmdGen @@ -17,7 +92,7 @@ ENV PATH_CA_CERTIFICATE="/etc/ssl/certs/ca-certificate.crt" RUN chmod +x build.sh && ./build.sh python /opt/startupcmdgen/startupcmdgen # Build Python SDK from source in a disposable stage -FROM ${BASE_IMAGE} AS pythonSdkBuilder +FROM oryx_runtime_base AS pythonSdkBuilder ARG DEBIAN_FLAVOR ARG PYTHON_FULL_VERSION ARG PYTHON_VERSION @@ -34,7 +109,7 @@ RUN set -e \ && export OS_FLAVOR=${DEBIAN_FLAVOR} \ && /tmp/build.sh -FROM ${BASE_IMAGE} as main +FROM oryx_runtime_base AS main ARG IMAGES_DIR=/tmp/oryx/images ARG SDK_STORAGE_BASE_URL_VALUE @@ -54,6 +129,8 @@ RUN apt-get update \ ADD images ${IMAGES_DIR} RUN find ${IMAGES_DIR} -type f -iname "*.sh" -exec chmod +x {} \; +RUN ${IMAGES_DIR}/runtime/python/install-dependencies.sh + ARG PYTHON_FULL_VERSION ARG PYTHON_VERSION ARG PYTHON_MAJOR_VERSION @@ -86,7 +163,6 @@ ENV PATH_CA_CERTIFICATE="/etc/ssl/certs/ca-certificate.crt" ENV CNB_STACK_ID="oryx.stacks.skeleton" LABEL io.buildpacks.stack.id="oryx.stacks.skeleton" -RUN ${IMAGES_DIR}/runtime/python/install-dependencies.sh RUN --mount=type=secret,id=pip_index_url,target=/run/secrets/pip_index_url \ pip install --index-url $(cat /run/secrets/pip_index_url) --upgrade pip && \ pip install --index-url $(cat /run/secrets/pip_index_url) gunicorn debugpy viztracer==0.15.6 vizplugins==0.1.3 && \ diff --git a/images/runtime/scripts/install-azurelinux-ca-packages.sh b/images/runtime/scripts/install-azurelinux-ca-packages.sh new file mode 100644 index 0000000000..669cea6493 --- /dev/null +++ b/images/runtime/scripts/install-azurelinux-ca-packages.sh @@ -0,0 +1,25 @@ +#!/bin/sh +set -eu + +retry_tdnf() { + for attempt in 1 2 3; do + if tdnf "$@"; then + return 0 + else + status=$? + fi + # tdnf connection error 1208 is returned as shell exit status 184. + if [ "$status" -ne 184 ] || [ "$attempt" -eq 3 ]; then + return "$status" + fi + delay=$((attempt * 2)) + printf 'tdnf %s failed to connect (attempt %s/3); retrying in %s seconds.\n' \ + "$*" "$attempt" "$delay" >&2 + sleep "$delay" + done +} + +retry_tdnf makecache '--disablerepo=*' --enablerepo=azurelinux-official-base +retry_tdnf install -y ca-certificates '--disablerepo=*' --enablerepo=azurelinux-official-base +update-ca-trust extract +tdnf clean all diff --git a/images/runtime/scripts/install-azurelinux-certs.sh b/images/runtime/scripts/install-azurelinux-certs.sh index 7522912064..8ce6ed4b30 100644 --- a/images/runtime/scripts/install-azurelinux-certs.sh +++ b/images/runtime/scripts/install-azurelinux-certs.sh @@ -61,21 +61,43 @@ sanitize_filename() { tr '[:space:]/,()' '_' | tr -cd 'A-Za-z0-9_.-' | tr -s '_.-' | sed -E 's/^[_.-]+//; s/[_.-]+$//' | cut -c1-60 } -fingerprint_sha256() { - openssl x509 -in "$1" -noout -fingerprint -sha256 | cut -d= -f2 +prepare_certificate_metadata() { + local metadata_dir="$1" + shift + mkdir -p "$metadata_dir" || return 1 + [ "$#" -gt 0 ] || return 0 + + # Inspect independently; consume results in original order below. + printf '%s\0' "$@" | xargs -0 -r -n16 -P4 bash -ec ' + metadata_dir="$1" + shift + for certificate; do + output="$metadata_dir/${certificate##*/}" + status=0 + openssl x509 -in "$certificate" -noout -subject -nameopt RFC2253 -fingerprint -sha256 \ + > "$output.txt" 2> "$output.stderr" || status=$? + printf "%s\n" "$status" > "$output.status" + done + ' -- "$metadata_dir" } process_certificate() { local azlCert="$1" dest_dir="$2" idx="$3" + local metadata fp="" subject="" line - # Validate the cert - if ! openssl x509 -in "$azlCert" -noout -subject >/dev/null 2>&1; then + local metadata_path="$TMP_CERTS_DIR/bundle-metadata/${azlCert##*/}" + if [ "$(< "$metadata_path.status")" != 0 ]; then err "Invalid cert: $azlCert" return 1 fi + metadata=$(< "$metadata_path.txt") + while IFS= read -r line; do + case "$line" in + subject=*) subject="$line" ;; + *Fingerprint=*) fp="${line#*=}" ;; + esac + done <<< "$metadata" - local fp - fp=$(fingerprint_sha256 "$azlCert") || true [ -n "$fp" ] || { err "Could not compute fingerprint for $azlCert"; return 1; } # Duplicate in already installed store? @@ -92,8 +114,7 @@ process_certificate() { printf '%s\n' "$fp" >> "$TMP_CERTS_DIR/imported-azl-fingerprints.txt" # Derive name - local subject cn - subject=$(openssl x509 -in "$azlCert" -noout -subject -nameopt RFC2253) + local cn cn=$(printf '%s' "$subject" | sed -n 's/.*CN=\([^,]*\).*/\1/p') # If CN extraction failed, fallback to full subject or fingerprint @@ -118,12 +139,28 @@ process_certificate() { } extract_system_fingerprints() { + local existing line metadata_path + local -a certificates=() if [ -d "/etc/ssl/certs" ]; then - for existing in /etc/ssl/certs/*.pem; do [ -f "$existing" ] || continue - fp_sys=$(fingerprint_sha256 "$existing") || true - [ -n "${fp_sys:-}" ] && printf '%s\n' "$fp_sys" >> "$TMP_CERTS_DIR/system-fingerprints.txt" + certificates+=("$existing") + done + if ! prepare_certificate_metadata "$TMP_CERTS_DIR/system-metadata" "${certificates[@]}"; then + err "Failed to inspect system certificates." + return 1 + fi + for existing in "${certificates[@]}"; do + metadata_path="$TMP_CERTS_DIR/system-metadata/${existing##*/}" + if [ -s "$metadata_path.stderr" ]; then + cat "$metadata_path.stderr" >&2 + fi + [ "$(< "$metadata_path.status")" = 0 ] || continue + while IFS= read -r line; do + case "$line" in + *Fingerprint=*) printf '%s\n' "${line#*=}" >> "$TMP_CERTS_DIR/system-fingerprints.txt" ;; + esac + done < "$metadata_path.txt" done if [ -s "$TMP_CERTS_DIR/system-fingerprints.txt" ]; then @@ -171,11 +208,19 @@ main() { return 1 fi - local count=0 idx=0 + local count=0 idx=0 pem + local -a certificates=() : > "$TMP_CERTS_DIR/imported-azl-fingerprints.txt" - for pem in "$TMP_CERTS_DIR"/cert-*.pem; do [ -f "$pem" ] || continue + certificates+=("$pem") + done + if ! prepare_certificate_metadata "$TMP_CERTS_DIR/bundle-metadata" "${certificates[@]}"; then + err "Failed to inspect bundle certificates." + return 1 + fi + + for pem in "${certificates[@]}"; do idx=$((idx+1)) if process_certificate "$pem" "$DEST_DIR" "$idx"; then diff --git a/platforms/python/buildPython.sh b/platforms/python/buildPython.sh index c5a8554c8b..90b955f63d 100755 --- a/platforms/python/buildPython.sh +++ b/platforms/python/buildPython.sh @@ -35,6 +35,7 @@ buildPython() { mkdir /usr/src/python cd /usr/src/python OS_FLAVOR=$osFlavor PYTHON_VERSION=$version GPG_KEY=$gpgKey PIP_VERSION=$PIP_VERSION PYTHON_SHA256=$python_sha INSTALL_UV=true /tmp/build.sh + tar -zcf "$targetDir/$pythonSdkFileName" -C "/opt/python/$version" . cd $REPO_DIR rm -r /opt/python/* diff --git a/platforms/python/prereqs/build.sh b/platforms/python/prereqs/build.sh index 04f3616159..b36e741786 100755 --- a/platforms/python/prereqs/build.sh +++ b/platforms/python/prereqs/build.sh @@ -7,7 +7,6 @@ set -ex pythonVersion=$PYTHON_VERSION -osFlavor=$OS_FLAVOR python_sha=$PYTHON_SHA256 gpgKey=$GPG_KEY @@ -57,7 +56,6 @@ fi PYTHON_GET_PIP_URL="https://bootstrap.pypa.io/get-pip.py" PIP_VERSION="21.2.4" -pythonSdkFileName=python-$osFlavor-$PYTHON_VERSION.tar.gz tar -xJf /python.tar.xz --strip-components=1 -C . @@ -82,7 +80,12 @@ fi --without-ensurepip \ "${configureArgs[@]}" -make -j $(nproc) +# Skip LTO only for the disposable training interpreter. +# Older CPython needs explicit balanced partitions for the final LTO links. +make -j "$(nproc)" \ + PGO_PROF_GEN_FLAG="-fprofile-generate -fno-lto" \ + LDFLAGS_NODIST="-flto=auto -flto-partition=balanced" \ + PROFILE_TASK="-m test --pgo --timeout=\$(TESTTIMEOUT) -j$(nproc)" make install @@ -180,8 +183,3 @@ pipReqSetPath=`find $INSTALLATION_PREFIX/lib -path "*site-packages/pip/_internal if [ -n "$pipReqSetPath" ]; then sed -i 's|logger\.debug('\''Cleaning up\.\.\.'\'')|logger\.info('\''Cleaning up\.\.\.'\'')|' "$pipReqSetPath" fi - -compressedSdkDir="/tmp/compressedSdk/python" -mkdir -p $compressedSdkDir -cd "$INSTALLATION_PREFIX" -tar -zcf $compressedSdkDir/$pythonSdkFileName .