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
27 changes: 12 additions & 15 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,15 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS
ARG TAGS=""
WORKDIR /go/src/github.com/openshift/machine-config-operator
COPY . .
# FIXME once we can depend on a new enough host that supports globs for COPY,
# just use that. For now we work around this by copying a tarball.
ENV GOCACHE="/go/rhel9/.cache"
ENV GOMODCACHE="/go/rhel9/pkg/mod"
RUN make install DESTDIR=./instroot-rhel9 && tar -C instroot-rhel9 -cf instroot-rhel9.tar .
RUN make install DESTDIR=./instroot-rhel9

# Add a RHEL 8 builder to compile the RHEL 8 compatible binaries
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.24-openshift-4.21 AS rhel8-builder
ARG TAGS=""
WORKDIR /go/src/github.com/openshift/machine-config-operator
# Copy the RHEL 8 machine-config-daemon binary and rename
COPY . .
ENV GOCACHE="/go/rhel8/.cache"
ENV GOMODCACHE="/go/rhel8/pkg/mod"
RUN make install DESTDIR=./instroot-rhel8 && tar -C instroot-rhel8 -cf instroot-rhel8.tar .
RUN make install DESTDIR=./instroot-rhel8

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
ARG TAGS=""
Expand All @@ -36,18 +30,21 @@ RUN if [ "${TAGS}" = "fcos" ]; then \
sed -i '/- name: rhel-coreos-10/,+3 s/^/#/' /manifests/* && \
# rewrite image names for scos
sed -i 's/rhel-coreos/stream-coreos/g' /manifests/*; fi && \
dnf --setopt=keepcache=true -y install 'nmstate >= 2.2.10' && \
if ! rpm -q util-linux; then dnf install --setopt=keepcache=true -y util-linux; fi && \
dnf -y install 'nmstate >= 2.2.10' && \
if ! rpm -q util-linux; then dnf install -y util-linux; fi && \
# We also need to install fuse-overlayfs and cpp for Buildah to work correctly.
if ! rpm -q buildah; then dnf install --setopt=keepcache=true -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
if ! rpm -q buildah; then dnf install -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
# Create the build user which will be used for doing OS image builds. We
# use the username "build" and the uid 1000 since this matches what is in
# the official Buildah image.
# Conditional checks if "build" user does not exist before adding user.
if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi
# Copy the binaries *after* we install nmstate so we don't invalidate our cache for local builds.
COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9.tar /tmp/instroot-rhel9.tar
RUN cd / && tar xf /tmp/instroot-rhel9.tar && rm -f /tmp/instroot-rhel9.tar
if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi && \
dnf clean all && \
rm -rf /var/cache/dnf/*
# Copy the binaries directly from their build stages into their final location.
# Do this after package installation to avoid invalidating state for faster
# local builds.
COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9/usr/bin/* /usr/bin/
# Copy the RHEL 8 machine-config-daemon binary and rename
COPY --from=rhel8-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel8/usr/bin/machine-config-daemon /usr/bin/machine-config-daemon.rhel8
COPY templates /etc/mcc/templates
Expand Down
27 changes: 12 additions & 15 deletions Dockerfile.rhel7
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@ FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.24-openshift-4.21 AS
ARG TAGS=""
WORKDIR /go/src/github.com/openshift/machine-config-operator
COPY . .
# FIXME once we can depend on a new enough host that supports globs for COPY,
# just use that. For now we work around this by copying a tarball.
ENV GOCACHE="/go/rhel9/.cache"
ENV GOMODCACHE="/go/rhel9/pkg/mod"
RUN make install DESTDIR=./instroot-rhel9 && tar -C instroot-rhel9 -cf instroot-rhel9.tar .
RUN make install DESTDIR=./instroot-rhel9

# Add a RHEL 8 builder to compile the RHEL 8 compatible binaries
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.24-openshift-4.21 AS rhel8-builder
ARG TAGS=""
WORKDIR /go/src/github.com/openshift/machine-config-operator
# Copy the RHEL 8 machine-config-daemon binary and rename
COPY . .
ENV GOCACHE="/go/rhel8/.cache"
ENV GOMODCACHE="/go/rhel8/pkg/mod"
RUN make install DESTDIR=./instroot-rhel8 && tar -C instroot-rhel8 -cf instroot-rhel8.tar .
RUN make install DESTDIR=./instroot-rhel8

FROM registry.ci.openshift.org/ocp/4.21:base-rhel9
ARG TAGS=""
Expand All @@ -37,18 +31,21 @@ RUN if [ "${TAGS}" = "fcos" ]; then \
sed -i '/- name: rhel-coreos-10/,+3 s/^/#/' /manifests/* && \
# rewrite image names for scos
sed -i 's/rhel-coreos/stream-coreos/g' /manifests/*; fi && \
dnf --setopt=keepcache=true -y install 'nmstate >= 2.2.10' && \
if ! rpm -q util-linux; then dnf install --setopt=keepcache=true -y util-linux; fi && \
dnf -y install 'nmstate >= 2.2.10' && \
if ! rpm -q util-linux; then dnf install -y util-linux; fi && \
# We also need to install fuse-overlayfs and cpp for Buildah to work correctly.
if ! rpm -q buildah; then dnf install --setopt=keepcache=true -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
if ! rpm -q buildah; then dnf install -y buildah fuse-overlayfs cpp --exclude container-selinux; fi && \
# Create the build user which will be used for doing OS image builds. We
# use the username "build" and the uid 1000 since this matches what is in
# the official Buildah image.
# Conditional checks if "build" user does not exist before adding user.
if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi
# Copy the binaries *after* we install nmstate so we don't invalidate our cache for local builds.
COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9.tar /tmp/instroot-rhel9.tar
RUN cd / && tar xf /tmp/instroot-rhel9.tar && rm -f /tmp/instroot-rhel9.tar
if ! id -u "build" >/dev/null 2>&1; then useradd --uid 1000 build; fi && \
dnf clean all && \
rm -rf /var/cache/dnf/*
# Copy the binaries directly from their build stages into their final location.
# Do this after package installation to avoid invalidating state for faster
# local builds.
COPY --from=rhel9-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel9/usr/bin/* /usr/bin/
# Copy the RHEL 8 machine-config-daemon binary and rename
COPY --from=rhel8-builder /go/src/github.com/openshift/machine-config-operator/instroot-rhel8/usr/bin/machine-config-daemon /usr/bin/machine-config-daemon.rhel8
COPY templates /etc/mcc/templates
Expand Down