-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathDockerfile
49 lines (39 loc) · 1.52 KB
/
Dockerfile
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Build the manager binary
FROM --platform=${BUILDPLATFORM:-linux/amd64} docker.io/library/golang:1.23.4 AS builder
ARG TARGETOS
ARG TARGETARCH
USER root
WORKDIR /workspace
# Copy the Go Modules manifests
COPY go.mod go.mod
COPY go.sum go.sum
COPY vendor/ vendor/
# Copy the go source
COPY cmd/ cmd/
COPY api/ api/
COPY internal/ internal/
# Copy git to inject the commit during build
COPY .git .git
# Build
RUN GIT_COMMIT=$(git rev-list -1 HEAD) && \
echo " injecting GIT COMMIT: $GIT_COMMIT" && \
CGO_ENABLED=0 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} GOFLAGS=-mod=vendor \
go build -ldflags "-w -s -X github.com/project-koku/koku-metrics-operator/internal/controller.GitCommit=$GIT_COMMIT" -a -o manager cmd/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
# For terminal access, use this image:
# FROM gcr.io/distroless/base:debug-nonroot
LABEL \
com.redhat.component="koku-metrics-operator-container" \
description="Koku Metrics Operator" \
io.k8s.description="Operator to deploy and manage instances of Koku Metrics" \
io.k8s.display-name="Koku Metrics Operator" \
io.openshift.tags="cost,cost-management,prometheus,servicetelemetry,operators" \
maintainer="Cost Management <cost-mgmt@redhat.com>" \
name="koku-metrics-operator" \
summary="Koku Metrics Operator"
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
ENTRYPOINT ["/manager"]