forked from project-koku/koku-metrics-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
57 lines (48 loc) · 1.78 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
50
51
52
53
54
55
56
57
# Build the manager binary
FROM --platform=${BUILDPLATFORM:-linux/amd64} registry.access.redhat.com/ubi8/go-toolset:1.20.10-3 AS builder
ARG TARGETOS
ARG TARGETARCH
USER root
RUN yum -y update && yum clean all
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 main.go main.go
COPY api/ api/
COPY clusterversion/ clusterversion/
COPY collector/ collector/
COPY controllers/ controllers/
COPY crhchttp/ crhchttp/
COPY dirconfig/ dirconfig/
COPY packaging/ packaging/
COPY sources/ sources/
COPY storage/ storage/
COPY strset/ strset/
# 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/controllers.GitCommit=$GIT_COMMIT" -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
# 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 <[email protected]>" \
name="koku-metrics-operator" \
summary="Koku Metrics Operator"
WORKDIR /
COPY --from=builder /workspace/manager .
USER nonroot:nonroot
ENTRYPOINT ["/manager"]