-
Notifications
You must be signed in to change notification settings - Fork 11
/
Dockerfile
36 lines (26 loc) · 1.02 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
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-openshift-4.17 as builder
ARG TARGETOS
ARG TARGETARCH
WORKDIR /opt/app-root/src
COPY go.mod go.mod
COPY go.sum go.sum
RUN go mod download
# Copy the go source
COPY cmd/ cmd/
COPY api/ api/
COPY controllers/ controllers/
COPY internal/ internal/
COPY vendor/ vendor/
RUN CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o build/manager cmd/manager/main.go
RUN CGO_ENABLED=1 GOOS=${TARGETOS:-linux} GOARCH=${TARGETARCH} go build -a -o build/server cmd/server/main.go
FROM registry.ci.openshift.org/ocp/4.17:base-rhel9
ARG DATA_DIR=/data
RUN mkdir $DATA_DIR && chmod 775 $DATA_DIR
RUN dnf install -y nmstate-libs-2.2.33-1.el9_4.x86_64 nmstate-2.2.33-1.el9_4.x86_64 && dnf clean all && rm -rf /var/cache/dnf/*
WORKDIR /
COPY --from=builder /opt/app-root/src/build/manager /usr/local/bin/
COPY --from=builder /opt/app-root/src/build/server /usr/local/bin/
USER 65532:65532
ENV GODEBUG=madvdontneed=1
ENV GOGC=50
ENTRYPOINT ["/usr/local/bin/manager"]