Skip to content
This repository was archived by the owner on Oct 10, 2023. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 42e71cd

Browse files
committedMar 15, 2023
Copy component code within separate layer
1 parent 0e42e52 commit 42e71cd

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed
 

‎Dockerfile

+10-6
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,41 @@ ARG COMPONENT
1111
ARG GOPROXY_ARG
1212
ENV GOPROXY=${GOPROXY_ARG}
1313
WORKDIR /workspace
14-
COPY "$COMPONENT" "$COMPONENT"
14+
COPY "$COMPONENT"/go.* "$COMPONENT"/
1515
RUN --mount=type=cache,target=/go/pkg/mod \
1616
cd $COMPONENT && go mod download
1717

18+
# Component code
19+
FROM base as component-base
20+
COPY "$COMPONENT" "$COMPONENT"
21+
1822
# Linting
1923
FROM harbor-repo.vmware.com/dockerhub-proxy-cache/golangci/golangci-lint:v1.50 AS lint-base
20-
FROM base AS lint
24+
FROM component-base AS lint
2125
RUN --mount=from=lint-base,src=/usr/bin/golangci-lint,target=/usr/bin/golangci-lint \
2226
--mount=type=cache,target=/go/pkg/mod \
2327
--mount=type=cache,target=/root/.cache/go-build \
2428
--mount=type=cache,target=/root/.cache/golangci-lint \
2529
cd $COMPONENT && golangci-lint run --config /workspace/.golangci.yaml --timeout 10m0s ./...
2630

27-
FROM base AS fmt
31+
FROM component-base AS fmt
2832
RUN --mount=type=cache,target=/go/pkg/mod \
2933
--mount=type=cache,target=/root/.cache/go-build \
3034
cd $COMPONENT && go fmt ./...
3135

32-
FROM base AS vet
36+
FROM component-base AS vet
3337
RUN --mount=type=cache,target=/go/pkg/mod \
3438
--mount=type=cache,target=/root/.cache/go-build \
3539
cd $COMPONENT && go vet ./...
3640

3741
# Testing
38-
FROM base AS test
42+
FROM component-base AS test
3943
RUN --mount=type=cache,target=/go/pkg/mod \
4044
--mount=type=cache,target=/root/.cache/go-build \
4145
cd $COMPONENT && mkdir /out && go test -v -coverprofile=/out/cover.out ./...
4246

4347
# Build the manager binary
44-
FROM base as builder
48+
FROM component-base as builder
4549
ARG TARGETOS
4650
ARG TARGETARCH
4751
ARG LD_FLAGS

0 commit comments

Comments
 (0)
This repository has been archived.