forked from google/go-licenses
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
34 lines (23 loc) · 682 Bytes
/
Dockerfile
File metadata and controls
34 lines (23 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
FROM golang:1.18 as build
WORKDIR /go-licenses
ARG GOFLAGS=""
ENV GOFLAGS=$GOFLAGS
ENV GO111MODULE=on
# Download dependencies first - this should be cacheable.
COPY go.mod go.sum ./
RUN go mod download
# Now add the local repo, which typically isn't cacheable.
COPY . .
# Check that all of the Go code builds
RUN go build ./...
# Run the tests
RUN go test -v ./...
# Install the binary into /go/bin
RUN go install .
# Save licenses, etc.
RUN go run . save . --save_path /THIRD_PARTY_NOTICES
# Make a minimal image.
FROM gcr.io/distroless/base
COPY --from=build /go/bin/go-licenses /
COPY --from=build /THIRD_PARTY_NOTICES /THIRD_PARTY_NOTICES
ENTRYPOINT ["/go-licenses"]