1
0
mirror of https://github.com/rancher/os.git synced 2025-09-09 18:50:04 +00:00
Files
os/Dockerfile

149 lines
4.5 KiB
Docker
Raw Normal View History

2021-08-31 11:14:03 -07:00
FROM opensuse/leap:15.3 AS build
2021-10-12 10:24:39 -07:00
RUN zypper ref
2021-10-20 10:58:54 -07:00
RUN zypper in -y squashfs xorriso go1.16 upx busybox-static curl tar git gzip
2021-10-12 10:24:39 -07:00
RUN curl -Lo /usr/bin/luet https://github.com/mudler/luet/releases/download/0.18.1/luet-0.18.1-linux-$(go env GOARCH) && \
chmod +x /usr/bin/luet
2021-10-20 10:58:54 -07:00
RUN curl -Lo /usr/bin/rancherd https://github.com/rancher/rancherd/releases/download/v0.0.1-alpha9/rancherd-$(go env GOARCH) && \
chmod +x /usr/bin/rancherd
RUN curl -L https://get.helm.sh/helm-v3.7.1-linux-$(go env GOARCH).tar.gz | tar xzf - -C /usr/bin --strip-components=1
2021-08-31 11:14:03 -07:00
COPY go.mod go.sum /usr/src/
COPY cmd /usr/src/cmd
COPY pkg /usr/src/pkg
2021-10-20 10:58:54 -07:00
COPY scripts /usr/src/scripts
COPY chart /usr/src/chart
ARG IMAGE_TAG=latest
RUN TAG=${IMAGE_TAG} /usr/src/scripts/package-helm && \
cp /usr/src/dist/artifacts/rancheros-operator-*.tgz /usr/src/dist/rancheros-operator-chart.tgz
RUN cd /usr/src && \
CGO_ENABLED=0 go build -ldflags "-extldflags -static -s" -o /usr/sbin/ros-operator ./cmd/ros-operator && \
upx /usr/sbin/ros-operator
2021-08-31 11:14:03 -07:00
RUN cd /usr/src && \
CGO_ENABLED=0 go build -ldflags "-extldflags -static -s" -o /usr/sbin/ros-installer ./cmd/ros-installer && \
upx /usr/sbin/ros-installer
2021-08-31 11:14:03 -07:00
FROM scratch AS framework
COPY --from=build /usr/bin/busybox-static /usr/bin/busybox
2021-10-20 10:58:54 -07:00
COPY --from=build /usr/bin/rancherd /usr/bin/rancherd
2021-10-12 10:24:39 -07:00
COPY --from=build /usr/bin/luet /usr/bin/luet
2021-10-20 10:58:54 -07:00
COPY --from=build /usr/bin/helm /usr/bin/helm
COPY --from=build /usr/src/dist/rancheros-operator-chart.tgz /usr/share/rancher/os/
2021-08-31 11:14:03 -07:00
COPY framework/files/etc/luet/luet.yaml /etc/luet/luet.yaml
COPY --from=build /etc/ssl/certs /etc/ssl/certs
2021-08-31 11:14:03 -07:00
ARG CACHEBUST
ENV LUET_NOLOCK=true
2021-10-20 10:58:54 -07:00
RUN ["/usr/bin/busybox", "sh", "-c", "if [ -e /etc/luet/luet.yaml.$(busybox uname -m) ]; then busybox mv -f /etc/luet/luet.yaml.$(busybox uname -m) /etc/luet/luet.yaml; fi && busybox rm -f /etc/luet/luet.yaml.*"]
2021-08-31 11:14:03 -07:00
RUN ["luet", \
"install", "--no-spinner", "-d", "-y", \
"selinux/k3s", \
"selinux/rancher", \
2021-10-12 10:24:39 -07:00
"meta/cos-minimal", \
2021-08-31 11:14:03 -07:00
"utils/k9s", \
"utils/nerdctl"]
2021-06-25 11:01:35 -07:00
2021-08-31 11:14:03 -07:00
COPY --from=build /usr/sbin/ros-installer /usr/sbin/ros-installer
2021-10-20 10:58:54 -07:00
COPY --from=build /usr/sbin/ros-operator /usr/sbin/ros-operator
2021-08-31 11:14:03 -07:00
COPY framework/files/ /
RUN ["/usr/bin/busybox", "rm", "-rf", "/var", "/etc/ssl", "/usr/bin/busybox"]
# Make OS image
FROM opensuse/leap:15.3 as os
2021-10-12 10:24:39 -07:00
RUN zypper ref
2021-06-05 17:31:50 -07:00
RUN zypper in -y \
2021-10-02 22:27:31 -07:00
apparmor-parser \
2021-08-31 11:14:03 -07:00
avahi \
2021-06-05 17:31:50 -07:00
bash-completion \
conntrack-tools \
coreutils \
curl \
device-mapper \
2021-10-02 22:27:31 -07:00
dmidecode \
2021-06-05 17:31:50 -07:00
dosfstools \
dracut \
e2fsprogs \
2021-10-02 22:27:31 -07:00
ethtool \
2021-06-05 17:31:50 -07:00
findutils \
gawk \
2021-06-25 11:01:35 -07:00
gptfdisk \
2021-06-05 17:31:50 -07:00
grub2-i386-pc \
grub2-x86_64-efi \
haveged \
2021-10-02 22:27:31 -07:00
hdparm \
iotop \
2021-06-05 17:31:50 -07:00
iproute2 \
iptables \
2021-06-18 16:48:33 -07:00
iputils \
2021-06-25 11:01:35 -07:00
issue-generator \
2021-06-05 17:31:50 -07:00
jq \
kernel-default \
kernel-firmware-bnx2 \
2021-10-02 22:27:31 -07:00
kernel-firmware-chelsio \
2021-06-05 17:31:50 -07:00
kernel-firmware-i915 \
kernel-firmware-intel \
kernel-firmware-iwlwifi \
2021-10-02 22:27:31 -07:00
kernel-firmware-liquidio \
kernel-firmware-marvell \
kernel-firmware-mediatek \
2021-06-05 17:31:50 -07:00
kernel-firmware-mellanox \
kernel-firmware-network \
kernel-firmware-platform \
2021-10-02 22:27:31 -07:00
kernel-firmware-qlogic \
2021-06-05 17:31:50 -07:00
kernel-firmware-realtek \
2021-10-02 22:27:31 -07:00
kernel-firmware-usb-network \
2021-06-05 17:31:50 -07:00
less \
2021-10-02 22:27:31 -07:00
lshw \
lsof \
2021-06-05 17:31:50 -07:00
lsscsi \
lvm2 \
mdadm \
multipath-tools \
nano \
2021-08-31 11:14:03 -07:00
netcat-openbsd \
2021-06-05 17:31:50 -07:00
nfs-utils \
open-iscsi \
open-vm-tools \
parted \
2021-10-02 22:27:31 -07:00
pciutils \
2021-06-25 11:01:35 -07:00
pigz \
policycoreutils \
procps \
2021-10-02 22:27:31 -07:00
psmisc \
2021-06-05 17:31:50 -07:00
python-azure-agent \
qemu-guest-agent \
2021-10-02 22:27:31 -07:00
rng-tools \
2021-06-05 17:31:50 -07:00
rsync \
squashfs \
strace \
2021-08-31 11:14:03 -07:00
SUSEConnect \
2021-10-02 22:27:31 -07:00
sysstat \
2021-06-05 17:31:50 -07:00
systemd \
systemd-sysvinit \
tar \
2021-10-02 22:27:31 -07:00
tcpdump \
2021-06-05 17:31:50 -07:00
timezone \
vim \
2021-10-02 22:27:31 -07:00
which \
zstd
2021-06-05 17:31:50 -07:00
2021-08-31 11:14:03 -07:00
# Copy in some local OS customizations
COPY opensuse/files /
2021-06-05 17:31:50 -07:00
2021-08-31 11:14:03 -07:00
# Starting from here are the lines needed for RancherOS to work
# IMPORTANT: Setup rancheros-release used for versioning/upgrade. The
2021-10-02 22:27:31 -07:00
# values here should reflect the tag of the image being built
2021-08-31 11:14:03 -07:00
ARG IMAGE_REPO=norepo
ARG IMAGE_TAG=latest
RUN echo "IMAGE_REPO=${IMAGE_REPO}" > /usr/lib/rancheros-release && \
echo "IMAGE_TAG=${IMAGE_TAG}" >> /usr/lib/rancheros-release && \
echo "IMAGE=${IMAGE_REPO}:${IMAGE_TAG}" >> /usr/lib/rancheros-release
2021-06-05 17:31:50 -07:00
2021-08-31 11:14:03 -07:00
# Copy in framework runtime
COPY --from=framework / /
# Rebuild initrd to setup dracut with the boot configurations
2021-10-12 10:24:39 -07:00
RUN mkinitrd && \
# aarch64 has an uncompressed kernel so we need to link it to vmlinuz
kernel=$(ls /boot/Image-* | head -n1) && \
if [ -e "$kernel" ]; then ln -sf "${kernel#/boot/}" /boot/vmlinuz; fi