Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 8 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,15 @@
#
# The standard name for this image is ovn-kube

# Build RHEL-9 binaries
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.25-openshift-4.22 AS builder

WORKDIR /go/src/github.com/openshift/ovn-kubernetes
COPY . .
RUN cd go-controller; CGO_ENABLED=1 make
RUN cd go-controller; CGO_ENABLED=0 make windows
RUN cd go-controller; CGO_ENABLED=1 LDFLAGS="-w -s" make
RUN cd go-controller; CGO_ENABLED=0 LDFLAGS="-w -s" make windows
RUN cd openshift; CGO_ENABLED=0 ./hack/build-tests-ext.sh && \
gzip ./bin/ovn-kubernetes-tests-ext

# Build RHEL-8 binaries (for upgrades from 4.12 and earlier)
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.25-openshift-4.22 AS rhel8
WORKDIR /go/src/github.com/openshift/ovn-kubernetes
COPY . .
RUN cd go-controller; CGO_ENABLED=1 make

# ovn-kubernetes-base image is built from Dockerfile.base
# The following changes are included in ovn-kubernetes-base
# image and removed from this Dockerfile:
Expand Down Expand Up @@ -62,14 +55,12 @@ COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/go-controller/_o
COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/go-controller/_output/go/bin/ovnkube-observ /usr/bin/
COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/openshift/bin/ovn-kubernetes-tests-ext.gz /usr/bin/

# Copy RHEL-8 and RHEL-9 shim binaries where the CNO's ovnkube-node container startup script can find them
RUN mkdir -p /usr/libexec/cni/rhel9
COPY --from=builder /go/src/github.com/openshift/ovn-kubernetes/go-controller/_output/go/bin/ovn-k8s-cni-overlay /usr/libexec/cni/rhel9/
RUN mkdir -p /usr/libexec/cni/rhel8
COPY --from=rhel8 /go/src/github.com/openshift/ovn-kubernetes/go-controller/_output/go/bin/ovn-k8s-cni-overlay /usr/libexec/cni/rhel8/
# Copy RHEL-8 ovnkube-trace file into /usr/lib/rhel8 directory so that user can download and run it on RHEL-8 platform.
RUN mkdir -p /usr/lib/rhel8
COPY --from=rhel8 /go/src/github.com/openshift/ovn-kubernetes/go-controller/_output/go/bin/ovnkube-trace /usr/lib/rhel8/
# Create RHEL version-specific CNI directories with hard links so the
# CNO's ovnkube-node container startup script can find the right binary.
# RHEL 10 uses the same RHEL 9 binaries until a separate build is needed.
RUN mkdir -p /usr/libexec/cni/rhel9 /usr/libexec/cni/rhel10 && \
ln /usr/libexec/cni/ovn-k8s-cni-overlay /usr/libexec/cni/rhel9/ovn-k8s-cni-overlay && \
ln /usr/libexec/cni/ovn-k8s-cni-overlay /usr/libexec/cni/rhel10/ovn-k8s-cni-overlay

RUN stat /usr/bin/oc

Expand Down
4 changes: 2 additions & 2 deletions go-controller/hack/build-go.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ build_binaries() {
-X ${OVN_KUBE_GO_PACKAGE}/pkg/config.BuildUser=${BUILD_USER} \
-X ${OVN_KUBE_GO_PACKAGE}/pkg/config.BuildDate=${BUILD_DATE} \
-X k8s.io/client-go/pkg/version.gitVersion=${K8S_CLIENT_VERSION} \
`if [ "$binbase" != "ovnkube" ]; then echo ${LDFLAGS}; fi`" \
${LDFLAGS}" \
-o "${OVN_KUBE_OUTPUT_BINPATH}/${binbase}"\
"./${bin}"
done
Expand All @@ -54,7 +54,7 @@ build_windows_binaries() {
-mod vendor \
-gcflags "${GCFLAGS}" \
-ldflags "-B ${BUILDID} \
`if [ "$binbase" != "ovnkube" ]; then echo ${LDFLAGS}; fi`" \
${LDFLAGS}" \
-o "${OVN_KUBE_OUTPUT_BINPATH_WINDOWS}/${binbase}.exe"\
"./${bin}"
done
Expand Down