From 853cb67e95cfe1b3d475cf672dfcd164e0069c3c Mon Sep 17 00:00:00 2001 From: Marc Date: Tue, 18 Nov 2025 08:48:06 +0100 Subject: [PATCH] shallow clone to save space in CI (#1987) * shallow clone * also remove source dir after building in CI * formatting * pass them through? * only CI * add as variable --- build-static.sh | 7 ++++++- docker-bake.hcl | 7 +++++++ static-builder-gnu.Dockerfile | 7 ++++++- static-builder-musl.Dockerfile | 3 +++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/build-static.sh b/build-static.sh index 4ec8c4b8..0fdedd82 100755 --- a/build-static.sh +++ b/build-static.sh @@ -201,10 +201,15 @@ if [ -f ../cache_key ] && [ "$(cat ../cache_key)" = "${cache_key}" ] && [ -f "bu else ${spcCommand} doctor --auto-fix # shellcheck disable=SC2086 - ${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" ${SPC_OPT_DOWNLOAD_ARGS} + ${spcCommand} download --with-php="${PHP_VERSION}" --shallow-clone --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" ${SPC_OPT_DOWNLOAD_ARGS} # shellcheck disable=SC2086 ${spcCommand} build --enable-zts --build-embed ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}" + if [ -n "$CI" ]; then + rm -rf ./downloads + rm -rf ./source + fi + echo -n "${cache_key}" >../cache_key fi diff --git a/docker-bake.hcl b/docker-bake.hcl index 0c92047c..9100515e 100644 --- a/docker-bake.hcl +++ b/docker-bake.hcl @@ -24,6 +24,11 @@ variable "CACHE" { default = "" } +variable "CI" { + # CI flag coming from the environment or --set; empty by default + default = "" +} + variable DEFAULT_PHP_VERSION { default = "8.4" } @@ -141,6 +146,7 @@ target "static-builder-musl" { } args = { FRANKENPHP_VERSION = VERSION + CI = CI } secret = ["id=github-token,env=GITHUB_TOKEN"] } @@ -165,6 +171,7 @@ target "static-builder-gnu" { args = { FRANKENPHP_VERSION = VERSION GO_VERSION = GO_VERSION + CI = CI } secret = ["id=github-token,env=GITHUB_TOKEN"] } diff --git a/static-builder-gnu.Dockerfile b/static-builder-gnu.Dockerfile index efc30d47..dea043b7 100644 --- a/static-builder-gnu.Dockerfile +++ b/static-builder-gnu.Dockerfile @@ -29,7 +29,12 @@ ENV GOTOOLCHAIN=local SHELL ["/bin/bash", "-o", "pipefail", "-c"] -# labels, same as static-builder-musl.Dockerfile +# Pass through CI environment flag so build-static.sh can detect CI context +ARG CI +ENV CI=${CI} + +# labels, same as static-builder.Dockerfile + LABEL org.opencontainers.image.title=FrankenPHP LABEL org.opencontainers.image.description="The modern PHP app server" LABEL org.opencontainers.image.url=https://frankenphp.dev diff --git a/static-builder-musl.Dockerfile b/static-builder-musl.Dockerfile index e353c9d7..8a653d0b 100644 --- a/static-builder-musl.Dockerfile +++ b/static-builder-musl.Dockerfile @@ -25,6 +25,9 @@ ENV GOTOOLCHAIN=local SHELL ["/bin/ash", "-eo", "pipefail", "-c"] +ARG CI +ENV CI=${CI} + LABEL org.opencontainers.image.title=FrankenPHP LABEL org.opencontainers.image.description="The modern PHP app server" LABEL org.opencontainers.image.url=https://frankenphp.dev