@@ -3,21 +3,15 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.22 AS
33ARG TAGS=""
44WORKDIR /go/src/github.com/openshift/machine-config-operator
55COPY . .
6- # FIXME once we can depend on a new enough host that supports globs for COPY,
7- # just use that. For now we work around this by copying a tarball.
8- ENV GOCACHE="/go/rhel9/.cache"
9- ENV GOMODCACHE="/go/rhel9/pkg/mod"
10- RUN make install DESTDIR=./instroot-rhel9 && tar -C instroot-rhel9 -cf instroot-rhel9.tar .
6+ RUN make install DESTDIR=./instroot-rhel9
117
128# Add a RHEL 8 builder to compile the RHEL 8 compatible binaries
139FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.24-openshift-4.22 AS rhel8-builder
1410ARG TAGS=""
1511WORKDIR /go/src/github.com/openshift/machine-config-operator
1612# Copy the RHEL 8 machine-config-daemon binary and rename
1713COPY . .
18- ENV GOCACHE="/go/rhel8/.cache"
19- ENV GOMODCACHE="/go/rhel8/pkg/mod"
20- RUN make install DESTDIR=./instroot-rhel8 && tar -C instroot-rhel8 -cf instroot-rhel8.tar .
14+ RUN make install DESTDIR=./instroot-rhel8
2115
2216FROM registry.ci.openshift.org/ocp/4.22:base-rhel9
2317ARG TAGS=""
@@ -36,18 +30,21 @@ RUN if [ "${TAGS}" = "fcos" ]; then \
3630 sed -i '/- name: rhel-coreos-10/,+3 s/^/#/' /manifests/* && \
3731 # rewrite image names for scos
3832 sed -i 's/rhel-coreos/stream-coreos/g' /manifests/*; fi && \
39- dnf --setopt=keepcache=true - y install 'nmstate >= 2.2.10' && \
40- if ! rpm -q util-linux; then dnf install --setopt=keepcache=true - y util-linux; fi && \
33+ dnf -y install 'nmstate >= 2.2.10' && \
34+ if ! rpm -q util-linux; then dnf install -y util-linux; fi && \
4135 # We also need to install fuse-overlayfs and cpp for Buildah to work correctly.
42- if ! rpm -q buildah; then dnf install --setopt=keepcache=true - y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
36+ if ! rpm -q buildah; then dnf install -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
4337 # Create the build user which will be used for doing OS image builds. We
4438 # use the username "build" and the uid 1000 since this matches what is in
4539 # the official Buildah image.
4640 # Conditional checks if "build" user does not exist before adding user.
47- if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi
48- # Copy the binaries *after* we install nmstate so we don't invalidate our cache for local builds.
49- COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9.tar /tmp/instroot-rhel9.tar
50- RUN cd / && tar xf /tmp/instroot-rhel9.tar && rm -f /tmp/instroot-rhel9.tar
41+ if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi && \
42+ dnf clean all && \
43+ rm -rf /var/cache/dnf/*
44+ # Copy the binaries directly from their build stages into their final location.
45+ # Do this after package installation to avoid invalidating state for faster
46+ # local builds.
47+ COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9/usr/bin/* /usr/bin/
5148# Copy the RHEL 8 machine-config-daemon binary and rename
5249COPY --from=rhel8-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel8/usr/bin/machine-config-daemon /usr/bin/machine-config-daemon.rhel8
5350COPY templates /etc/mcc/templates
0 commit comments