From 232d186af86c6ee81cd7fa2cc5e0d2fb4566df56 Mon Sep 17 00:00:00 2001 From: Xun Jiang Date: Thu, 28 Sep 2023 20:30:05 +0800 Subject: [PATCH] Add go clean in Dockerfile and action. Signed-off-by: Xun Jiang --- .github/workflows/push.yml | 5 ++++- Dockerfile | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 3e01a97d7f..3c0a8b710f 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -48,7 +48,10 @@ jobs: version: latest - name: Build - run: make local + run: | + make local + # Clean go cache to ease the build environment storage pressure. + go clean -modcache -cache - name: Test run: make test diff --git a/Dockerfile b/Dockerfile index 167dc5f040..b95f3108a8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,7 +43,8 @@ RUN mkdir -p /output/usr/bin && \ go build -o /output/${BIN} \ -ldflags "${LDFLAGS}" ${PKG}/cmd/${BIN} && \ go build -o /output/velero-helper \ - -ldflags "${LDFLAGS}" ${PKG}/cmd/velero-helper + -ldflags "${LDFLAGS}" ${PKG}/cmd/velero-helper && \ + go clean -modcache -cache # Restic binary build section FROM --platform=$BUILDPLATFORM golang:1.20.7-bullseye as restic-builder @@ -65,7 +66,8 @@ COPY . /go/src/github.com/vmware-tanzu/velero RUN mkdir -p /output/usr/bin && \ export GOARM=$(echo "${GOARM}" | cut -c2-) && \ - /go/src/github.com/vmware-tanzu/velero/hack/build-restic.sh + /go/src/github.com/vmware-tanzu/velero/hack/build-restic.sh && \ + go clean -modcache -cache # Velero image packing section FROM gcr.io/distroless/base-nossl-debian11@sha256:f10e1fbf558c630a4b74a987e6c754d45bf59f9ddcefce090f6b111925996767