Skip to content

Commit 853cb67

Browse files
authored
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
1 parent eeb7d1a commit 853cb67

4 files changed

Lines changed: 22 additions & 2 deletions

File tree

build-static.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,10 +201,15 @@ if [ -f ../cache_key ] && [ "$(cat ../cache_key)" = "${cache_key}" ] && [ -f "bu
201201
else
202202
${spcCommand} doctor --auto-fix
203203
# shellcheck disable=SC2086
204-
${spcCommand} download --with-php="${PHP_VERSION}" --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" ${SPC_OPT_DOWNLOAD_ARGS}
204+
${spcCommand} download --with-php="${PHP_VERSION}" --shallow-clone --for-extensions="${PHP_EXTENSIONS}" --for-libs="${PHP_EXTENSION_LIBS}" ${SPC_OPT_DOWNLOAD_ARGS}
205205
# shellcheck disable=SC2086
206206
${spcCommand} build --enable-zts --build-embed ${SPC_OPT_BUILD_ARGS} "${PHP_EXTENSIONS}" --with-libs="${PHP_EXTENSION_LIBS}"
207207

208+
if [ -n "$CI" ]; then
209+
rm -rf ./downloads
210+
rm -rf ./source
211+
fi
212+
208213
echo -n "${cache_key}" >../cache_key
209214
fi
210215

docker-bake.hcl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ variable "CACHE" {
2424
default = ""
2525
}
2626

27+
variable "CI" {
28+
# CI flag coming from the environment or --set; empty by default
29+
default = ""
30+
}
31+
2732
variable DEFAULT_PHP_VERSION {
2833
default = "8.4"
2934
}
@@ -141,6 +146,7 @@ target "static-builder-musl" {
141146
}
142147
args = {
143148
FRANKENPHP_VERSION = VERSION
149+
CI = CI
144150
}
145151
secret = ["id=github-token,env=GITHUB_TOKEN"]
146152
}
@@ -165,6 +171,7 @@ target "static-builder-gnu" {
165171
args = {
166172
FRANKENPHP_VERSION = VERSION
167173
GO_VERSION = GO_VERSION
174+
CI = CI
168175
}
169176
secret = ["id=github-token,env=GITHUB_TOKEN"]
170177
}

static-builder-gnu.Dockerfile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,12 @@ ENV GOTOOLCHAIN=local
2929

3030
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
3131

32-
# labels, same as static-builder-musl.Dockerfile
32+
# Pass through CI environment flag so build-static.sh can detect CI context
33+
ARG CI
34+
ENV CI=${CI}
35+
36+
# labels, same as static-builder.Dockerfile
37+
3338
LABEL org.opencontainers.image.title=FrankenPHP
3439
LABEL org.opencontainers.image.description="The modern PHP app server"
3540
LABEL org.opencontainers.image.url=https://frankenphp.dev

static-builder-musl.Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ ENV GOTOOLCHAIN=local
2525

2626
SHELL ["/bin/ash", "-eo", "pipefail", "-c"]
2727

28+
ARG CI
29+
ENV CI=${CI}
30+
2831
LABEL org.opencontainers.image.title=FrankenPHP
2932
LABEL org.opencontainers.image.description="The modern PHP app server"
3033
LABEL org.opencontainers.image.url=https://frankenphp.dev

0 commit comments

Comments
 (0)