mirror of https://github.com/grafana/loki
operator: Build and publish images for docker hub (#6086)
parent
b3b3da67b8
commit
1c8ebaff61
@ -0,0 +1,33 @@ |
||||
ARG BUILD_IMAGE=grafana/loki-build-image:0.18.0 |
||||
|
||||
FROM golang:1.17.9-alpine as goenv |
||||
RUN go env GOARCH > /goarch && \ |
||||
go env GOARM > /goarm |
||||
|
||||
FROM --platform=linux/amd64 $BUILD_IMAGE as builder |
||||
COPY --from=goenv /goarch /goarm / |
||||
WORKDIR /workspace |
||||
# Copy the Go Modules manifests |
||||
COPY operator/go.mod go.mod |
||||
COPY operator/go.sum go.sum |
||||
# cache deps before building and copying source so that we don't need to re-download as much |
||||
# and so that source changes don't invalidate our downloaded layer |
||||
RUN go mod download |
||||
|
||||
# Copy the go source |
||||
COPY operator/main.go main.go |
||||
COPY operator/apis/ apis/ |
||||
COPY operator/controllers/ controllers/ |
||||
COPY operator/internal/ internal/ |
||||
|
||||
# Build |
||||
RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on GOARCH=$(cat /goarch) GOARM=$(cat /goarm) go build -a -o manager main.go |
||||
|
||||
# Use distroless as minimal base image to package the manager binary |
||||
# Refer to https://github.com/GoogleContainerTools/distroless for more details |
||||
FROM gcr.io/distroless/static:nonroot |
||||
WORKDIR / |
||||
COPY --from=builder /workspace/manager . |
||||
USER 65532:65532 |
||||
|
||||
ENTRYPOINT ["/manager"] |
Loading…
Reference in new issue