Dockerfile.metrics 531 B

1234567891011121314151617181920212223
  1. FROM golang:latest as build-env
  2. RUN mkdir /app
  3. WORKDIR /app
  4. COPY go.mod .
  5. COPY go.sum .
  6. # Get dependencies - will also be cached if we won't change mod/sum
  7. RUN go mod download
  8. # COPY the source code as the last step
  9. COPY . .
  10. # Build the binary
  11. RUN set -e ;\
  12. cd cmd/kubemetrics;\
  13. CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
  14. go build -a -installsuffix cgo -o /go/bin/app
  15. FROM alpine:latest
  16. RUN apk add --update --no-cache ca-certificates
  17. COPY --from=build-env /go/bin/app /go/bin/app
  18. USER 1001
  19. ENTRYPOINT ["/go/bin/app"]