9a089c8af7
Updates the Dockerfile to use uppercase for multi-stage build definitions. This change enhances readability and maintains consistency across the build stages, ensuring alignment with common best practices in Dockerfile conventions.
29 lines
1.1 KiB
Docker
29 lines
1.1 KiB
Docker
FROM golang:1.25.6@sha256:fc24d3881a021e7b968a4610fc024fba749f98fe5c07d4f28e6cfa14dc65a84c AS deps
|
|
WORKDIR /build
|
|
ADD go.* /build
|
|
RUN go mod download
|
|
|
|
FROM deps AS build
|
|
ARG TARGETOS
|
|
ARG TARGETARCH
|
|
|
|
ENV CGO_ENABLED=0
|
|
ADD . /build
|
|
RUN if [ $(go mod tidy -v 2>&1 | grep -c unused) != 0 ]; then echo "Unused modules, please run 'go mod tidy'"; exit 1; fi
|
|
RUN go fmt ./...
|
|
RUN go vet ./...
|
|
RUN CGO_ENABLED=1 go test -mod=readonly -race -coverprofile=coverage.txt.tmp -covermode=atomic -coverpkg=$(go list ./... | tr '\n' , | sed 's/,$//') ./...
|
|
RUN ["/bin/bash", "-c", "cat coverage.txt.tmp | grep -v -f <(find . -type f | xargs grep -l 'Code generated') > coverage.txt"]
|
|
RUN go tool cover -html=coverage.txt -o coverage.html
|
|
RUN go tool cover -func=coverage.txt
|
|
RUN rm coverage.txt.tmp
|
|
RUN GOOS=${TARGETOS} GOARCH=${TARGETARCH} CGO_ENABLED=0 go build -mod=readonly -o release/default-request-adder -ldflags '-w -s'
|
|
|
|
FROM scratch AS export
|
|
COPY --from=build /build/coverage.txt /
|
|
|
|
FROM scratch
|
|
COPY --from=build /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
|
|
COPY --from=build /build/release/default-request-adder /
|
|
CMD ["/default-request-adder"]
|