Skip to content

Commit

Permalink
Improve build time with build caches
Browse files Browse the repository at this point in the history
Signed-off-by: Souyama <[email protected]>
  • Loading branch information
sansmoraxz authored Dec 25, 2023
1 parent da70147 commit 931f894
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ COPY go.sum go.sum
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
ARG TARGETOS
ARG TARGETARCH
RUN VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH make manager
ARG GOCACHE=/root/.cache/go-build
RUN go env -w GOCACHE=${GOCACHE}
RUN --mount=type=cache,target=${GOCACHE} \
VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH \
make manager

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile.adapter
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ COPY go.sum go.sum
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
ARG TARGETOS
ARG TARGETARCH
RUN VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH make adapter
ARG GOCACHE=/root/.cache/go-build
RUN go env -w GOCACHE=${GOCACHE}
RUN --mount=type=cache,target=${GOCACHE} \
VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH \
make adapter

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down
6 changes: 5 additions & 1 deletion Dockerfile.webhooks
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ COPY go.sum go.sum
# https://www.docker.com/blog/faster-multi-platform-builds-dockerfile-cross-compilation-guide/
ARG TARGETOS
ARG TARGETARCH
RUN VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH make webhooks
ARG GOCACHE=/root/.cache/go-build
RUN go env -w GOCACHE=${GOCACHE}
RUN --mount=type=cache,target=${GOCACHE} \
VERSION=${BUILD_VERSION} GIT_COMMIT=${GIT_COMMIT} GIT_VERSION=${GIT_VERSION} TARGET_OS=$TARGETOS ARCH=$TARGETARCH \
make webhooks

# Use distroless as minimal base image to package the manager binary
# Refer to https://github.com/GoogleContainerTools/distroless for more details
Expand Down

0 comments on commit 931f894

Please sign in to comment.