-
Notifications
You must be signed in to change notification settings - Fork 6
/
Dockerfile
40 lines (31 loc) · 1.11 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
# We do not use --platform feature to auto fill this ARG because of incompatibility between podman and docker
ARG TARGETARCH=amd64
# Build the manager binary
FROM docker.io/library/golang:1.22 as builder
ARG TARGETARCH
ARG LDFLAGS
WORKDIR /opt/app-root
COPY cmd cmd
COPY main.go main.go
COPY go.mod go.mod
COPY go.sum go.sum
COPY vendor/ vendor/
# Build collector
RUN GOARCH=$TARGETARCH go build -ldflags "$LDFLAGS" -mod vendor -a -o build/network-observability-cli
# We still need Makefile & resources for oc-commands; copy them after go build for caching
COPY commands/ commands/
COPY res/ res/
COPY scripts/ scripts/
COPY Makefile Makefile
COPY .mk/ .mk/
# Embed commands in case users want to pull it from collector image
RUN USER=netobserv VERSION=main make oc-commands
# Prepare output dir
RUN mkdir -p output
# Create final image from ubi + built binary and command
FROM --platform=linux/$TARGETARCH registry.access.redhat.com/ubi9/ubi:9.4
WORKDIR /
COPY --from=builder /opt/app-root/build .
COPY --from=builder --chown=65532:65532 /opt/app-root/output /output
USER 65532:65532
ENTRYPOINT ["/network-observability-cli"]