Skip to content

Commit 4b7338d

Browse files
authored
Merge pull request #193 from Fedosin/dockerimage_compile
🌱 compile capi operator binary only once in the Dockerfile
2 parents f55e815 + 80696e2 commit 4b7338d

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

Dockerfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,13 @@ RUN --mount=type=cache,target=/go/pkg/mod \
3838
# Copy the sources
3939
COPY ./ ./
4040

41-
# Cache the go build into the the Go’s compiler cache folder so we take benefits of compiler caching across docker build calls
42-
RUN --mount=type=cache,target=/root/.cache/go-build \
43-
--mount=type=cache,target=/go/pkg/mod \
44-
go build cmd/main.go
45-
4641
# Build
4742
ARG path=cmd/main.go
4843
ARG ARCH
4944
ARG ldflags
5045

51-
# Do not force rebuild of up-to-date packages (do not use -a) and use the compiler cache folder
52-
RUN --mount=type=cache,target=/root/.cache/go-build \
53-
--mount=type=cache,target=/go/pkg/mod \
46+
# Do not force rebuild of up-to-date packages (do not use -a)
47+
RUN --mount=type=cache,target=/go/pkg/mod \
5448
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} \
5549
go build -ldflags "${ldflags} -extldflags '-static'" \
5650
-o manager ${path}

0 commit comments

Comments
 (0)