Skip to content

Commit 5547b96

Browse files
hdonnaycrozzy
authored andcommitted
Dockerfile: remove sh loop
This invocation is equivalent and should be slightly faster by letting all the commands link in parallel. Signed-off-by: Hank Donnay <[email protected]>
1 parent e6378d0 commit 5547b96

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@
1414

1515
ARG GO_VERSION=1.20
1616
FROM quay.io/projectquay/golang:${GO_VERSION} AS build
17-
WORKDIR /build/
18-
ADD . /build/
17+
WORKDIR /build
18+
RUN --mount=type=cache,target=/root/.cache/go-build \
19+
--mount=type=cache,target=/go/pkg/mod \
20+
--mount=type=bind,source=go.mod,target=go.mod \
21+
--mount=type=bind,source=go.sum,target=go.sum \
22+
go mod download
23+
COPY . .
1924
ARG CLAIR_VERSION=""
20-
RUN for cmd in clair clairctl; do\
25+
RUN --mount=type=cache,target=/root/.cache/go-build \
26+
--mount=type=cache,target=/go/pkg/mod \
2127
go build \
22-
-trimpath -ldflags="-s -w$(test -n "$CLAIR_VERSION" && printf " -X 'github.com/quay/clair/v4/cmd.Version=%s (user)'" "${CLAIR_VERSION}")" \
23-
./cmd/$cmd; done
28+
-ldflags="-s -w$(test -n "$CLAIR_VERSION" && printf " -X 'github.com/quay/clair/v4/cmd.Version=%s (user)'" "${CLAIR_VERSION}")" \
29+
-o . \
30+
-trimpath \
31+
./cmd/...
2432

2533
FROM registry.access.redhat.com/ubi8/ubi-minimal AS final
2634
ENTRYPOINT ["/bin/clair"]

0 commit comments

Comments
 (0)