Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hack: do not cache some stages on release #3543

Merged
merged 1 commit into from
Feb 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ jobs:
run: |
./hack/images "${{ needs.release-base.outputs.tag }}" "$REPO_SLUG_TARGET" "${{ needs.release-base.outputs.push }}"
env:
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
TARGET: ${{ matrix.target-stage }}
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }} type=gha,scope=image${{ matrix.target-stage }}
CACHE_TO: type=gha,scope=image${{ matrix.target-stage }}
Expand Down Expand Up @@ -373,6 +374,7 @@ jobs:
run: |
./hack/release-tar "${{ needs.release-base.outputs.tag }}" release-out
env:
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
PLATFORMS: ${{ env.PLATFORMS }},darwin/amd64,darwin/arm64,windows/amd64,windows/arm64
CACHE_FROM: type=gha,scope=${{ env.CACHE_GHA_SCOPE_BINARIES }} type=gha,scope=${{ env.CACHE_GHA_SCOPE_CROSS }}
-
Expand Down Expand Up @@ -468,6 +470,7 @@ jobs:
run: |
./frontend/dockerfile/cmd/dockerfile-frontend/hack/release "${{ needs.frontend-base.outputs.typ }}" "${{ matrix.tag }}" "$DF_REPO_SLUG_TARGET" "${{ needs.frontend-base.outputs.push }}"
env:
RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
PLATFORMS: ${{ env.PLATFORMS }},linux/386,linux/mips,linux/mipsle,linux/mips64,linux/mips64le
CACHE_FROM: type=gha,scope=${{ env.CACHE_SCOPE }}
CACHE_TO: type=gha,scope=${{ env.CACHE_SCOPE }}
14 changes: 10 additions & 4 deletions frontend/dockerfile/cmd/dockerfile-frontend/hack/release
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
. $(dirname $0)/../../../../../hack/util
set -eu

: "${RELEASE=false}"
: "${PLATFORMS=}"
: "${DAILY_TARGETS=}"

Expand Down Expand Up @@ -70,6 +71,11 @@ if [ "$PUSH" = "push" ]; then
pushFlag="push=true"
fi

nocacheFilterFlag=""
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
nocacheFilterFlag="--no-cache-filter=base"
fi

case $TYP in
"master")
tagf=./frontend/dockerfile/release/$TAG/tags
Expand All @@ -84,7 +90,7 @@ case $TYP in
pushTag=${pushTag}-$TAG
fi

buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $(buildAttestFlags) \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag $(buildAttestFlags) \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
--output "type=image,name=$REPO:$pushTag,buildinfo-attrs=true,$pushFlag" \
Expand All @@ -101,7 +107,7 @@ case $TYP in
fi
buildTags=$(cat $tagf)

buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $(buildAttestFlags) \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag $(buildAttestFlags) \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
--output "type=image,\"name=$publishedNames\",buildinfo-attrs=true,$pushFlag" \
Expand All @@ -127,7 +133,7 @@ case $TYP in

tmp=$(mktemp -d -t buildid.XXXXXXXXXX)
dt=$(date +%Y%m%d)
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag \
--target "buildid" \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
Expand All @@ -141,7 +147,7 @@ case $TYP in
buildid=$(cat $tmp/buildid)
echo "buildid: $buildid"

buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $(buildAttestFlags) \
buildxCmd build $platformFlag $cacheFromFlags $cacheToFlags $nocacheFilterFlag $(buildAttestFlags) \
--build-arg "CHANNEL=$TAG" \
--build-arg "BUILDTAGS=$buildTags" \
--output "type=image,name=$REPO:$dt-$TAG,buildinfo-attrs=true,$pushFlag" \
Expand Down
8 changes: 7 additions & 1 deletion hack/images
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ PUSH=$3
. $(dirname $0)/util
set -eu -o pipefail

: ${RELEASE=false}
: ${PLATFORMS=}
: ${TARGET=}

Expand Down Expand Up @@ -91,5 +92,10 @@ for tagName in $tagNames; do
tagFlags="$tagFlags--tag=$tagName "
done

buildxCmd build $platformFlag $targetFlag $importCacheFlags $exportCacheFlags $tagFlags $outputFlag $attestFlags \
nocacheFilterFlag=""
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
nocacheFilterFlag="--no-cache-filter=git,buildkit-export,gobuild-base"
fi

buildxCmd build $platformFlag $targetFlag $importCacheFlags $exportCacheFlags $tagFlags $outputFlag $nocacheFilterFlag $attestFlags \
$currentcontext
8 changes: 7 additions & 1 deletion hack/release-tar
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ OUT=$2
. $(dirname $0)/util
set -eu -o pipefail

: ${RELEASE=false}
: ${PLATFORMS=}

usage() {
Expand All @@ -22,9 +23,14 @@ if [ -n "$PLATFORMS" ]; then
platformFlag="--platform=$PLATFORMS"
fi

nocacheFilterFlag=""
if [[ "$RELEASE" = "true" ]] && [[ "$GITHUB_ACTIONS" = "true" ]]; then
nocacheFilterFlag="--no-cache-filter=git,gobuild-base"
fi

output=$(mktemp -d -t buildkit-output.XXXXXXXXXX)

buildxCmd build $platformFlag $cacheFromFlags $(buildAttestFlags) \
buildxCmd build $platformFlag $cacheFromFlags $nocacheFilterFlag $(buildAttestFlags) \
--build-arg "BUILDKIT_MULTI_PLATFORM=true" \
--target release \
--output "type=local,dest=$output" \
Expand Down