Skip to content

Commit 0752503

Browse files
authored
refactor: improved Dockerfile (#672)
1 parent 4b0315c commit 0752503

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

Dockerfile

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
1-
FROM golang:bullseye as builder
1+
FROM --platform=${BUILDPLATFORM} golang:bullseye as builder
22

33
WORKDIR /build
4-
COPY go.mod go.sum ./
5-
RUN go mod download
64
COPY . .
7-
RUN CGO_ENABLED=0 go build -a -o trufflehog main.go
5+
ENV CGO_ENABLED=0
6+
ARG TARGETOS TARGETARCH
7+
RUN --mount=type=cache,target=/go/pkg/mod \
8+
--mount=type=cache,target=/root/.cache/go-build \
9+
GOOS=${TARGETOS} GOARCH=${TARGETARCH} go build -o trufflehog .
810

911
FROM alpine:3.15
1012
RUN apk add --no-cache git
1113
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
1214
COPY --from=builder /build/trufflehog /usr/bin/trufflehog
1315
ENTRYPOINT ["/usr/bin/trufflehog"]
16+

0 commit comments

Comments
 (0)