-
Notifications
You must be signed in to change notification settings - Fork 413
/
Dockerfile
56 lines (54 loc) · 3.37 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# Use RHEL 9 as the primary builder base for the Machine Config Operator
FROM registry.ci.openshift.org/ocp/builder:rhel-9-golang-1.22-builder-multi-openshift-4.18 AS rhel9-builder
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 --mount=type=cache,target=/go/rhel9/.cache,z \
--mount=type=cache,target=/go/rhel9/pkg/mod,z \
make install DESTDIR=./instroot-rhel9 && tar -C instroot-rhel9 -cf instroot-rhel9.tar .
# Add a RHEL 8 builder to compile the RHEL 8 compatible binaries
FROM registry.ci.openshift.org/ocp/builder:rhel-8-golang-1.22-builder-multi-openshift-4.18 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 --mount=type=cache,target=/go/rhel8/.cache,z \
--mount=type=cache,target=/go/rhel8/pkg/mod,z \
make install DESTDIR=./instroot-rhel8 && tar -C instroot-rhel8 -cf instroot-rhel8.tar .
FROM registry.ci.openshift.org/ocp/builder:rhel-9-enterprise-base-multi-openshift-4.18
ARG TAGS=""
COPY install /manifests
RUN --mount=type=cache,target=/var/cache/dnf,z \
if [ "${TAGS}" = "fcos" ]; then \
# comment out non-base/extensions image-references entirely for fcos
sed -i '/- name: rhel-coreos-/,+3 s/^/#/' /manifests/image-references && \
# also remove extensions from the osimageurl configmap (if we don't, oc won't rewrite it, and the placeholder value will survive and get used)
sed -i '/baseOSExtensionsContainerImage:/ s/^/#/' /manifests/0000_80_machine-config_05_osimageurl.yaml && \
# rewrite image names for fcos
sed -i 's/rhel-coreos/fedora-coreos/g' /manifests/*; \
elif [ "${TAGS}" = "scos" ]; then \
# 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 && \
# 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 && \
# 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
# 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
ENTRYPOINT ["/usr/bin/machine-config-operator"]
LABEL io.openshift.release.operator true