Skip to content

Commit

Permalink
build(dockerfile): run go build with mount=type=cache
Browse files Browse the repository at this point in the history
  • Loading branch information
plaffitt committed Feb 8, 2024
1 parent 127b4b0 commit 79b7506
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ ENV LD_FLAGS="\
-X 'github.com/enix/kube-image-keeper/internal/metrics.Revision=${REVISION}' \
-X 'github.com/enix/kube-image-keeper/internal/metrics.BuildDateTime=BUILD_DATE_TIME'"

RUN BUILD_DATE_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S") && \
RUN --mount=type=cache,target="/root/.cache/go-build" \
BUILD_DATE_TIME=$(date -u +"%Y-%m-%dT%H:%M:%S") && \
LD_FLAGS=$(/bin/ash -c "set -o pipefail && echo $LD_FLAGS | sed -e \"s/BUILD_DATE_TIME/$BUILD_DATE_TIME/g\"") && \
controller-gen object paths="./..." && \
go build -a -ldflags="$LD_FLAGS" -o manager cmd/cache/main.go && \
go build -a -ldflags="$LD_FLAGS" -o registry-proxy cmd/proxy/main.go
go build -ldflags="$LD_FLAGS" -o manager cmd/cache/main.go && \
go build -ldflags="$LD_FLAGS" -o registry-proxy cmd/proxy/main.go

FROM alpine:3.17 AS alpine

Expand Down

0 comments on commit 79b7506

Please sign in to comment.