github.com/glimps-jbo/go-licenses@v0.0.0-20230908151000-e06d3c113277/Dockerfile (about) 1 FROM golang:1.18 as build 2 3 WORKDIR /go-licenses 4 5 ARG GOFLAGS="" 6 ENV GOFLAGS=$GOFLAGS 7 ENV GO111MODULE=on 8 9 # Download dependencies first - this should be cacheable. 10 COPY go.mod go.sum ./ 11 RUN go mod download 12 13 # Now add the local repo, which typically isn't cacheable. 14 COPY . . 15 16 # Check that all of the Go code builds 17 RUN go build ./... 18 19 # Run the tests 20 RUN go test -v ./... 21 22 # Install the binary into /go/bin 23 RUN go install . 24 25 # Save licenses, etc. 26 RUN go run . save . --save_path /THIRD_PARTY_NOTICES 27 28 # Make a minimal image. 29 FROM gcr.io/distroless/base 30 31 COPY --from=build /go/bin/go-licenses / 32 COPY --from=build /THIRD_PARTY_NOTICES /THIRD_PARTY_NOTICES 33 34 ENTRYPOINT ["/go-licenses"]