Skip to content

Commit

Permalink
Dockerfile: remove sh loop
Browse files Browse the repository at this point in the history
This invocation is equivalent and should be slightly faster by letting
all the commands link in parallel.

Signed-off-by: Hank Donnay <hdonnay@redhat.com>
  • Loading branch information
hdonnay authored and crozzy committed Apr 29, 2024
1 parent e6378d0 commit 5547b96
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@

ARG GO_VERSION=1.20
FROM quay.io/projectquay/golang:${GO_VERSION} AS build
WORKDIR /build/
ADD . /build/
WORKDIR /build
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=bind,source=go.mod,target=go.mod \
--mount=type=bind,source=go.sum,target=go.sum \
go mod download
COPY . .
ARG CLAIR_VERSION=""
RUN for cmd in clair clairctl; do\
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
go build \
-trimpath -ldflags="-s -w$(test -n "$CLAIR_VERSION" && printf " -X 'github.com/quay/clair/v4/cmd.Version=%s (user)'" "${CLAIR_VERSION}")" \
./cmd/$cmd; done
-ldflags="-s -w$(test -n "$CLAIR_VERSION" && printf " -X 'github.com/quay/clair/v4/cmd.Version=%s (user)'" "${CLAIR_VERSION}")" \
-o . \
-trimpath \
./cmd/...

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

0 comments on commit 5547b96

Please sign in to comment.