Last active
March 19, 2024 14:22
-
-
Save frelon/575cec9de6555e740137ab35918215a4 to your computer and use it in GitHub Desktop.
Elemental toolkit RISCV64
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG GO_VERSION=1.20 | |
FROM --platform=linux/riscv64 riscv64/debian:sid AS elemental-bin | |
RUN apt update -y && apt-get install golang | |
ENV CGO_ENABLED=0 | |
WORKDIR /src/ | |
# Add specific dirs to the image so cache is not invalidated when modifying non go files | |
ADD go.mod . | |
ADD go.sum . | |
ADD vendor vendor | |
RUN go mod download | |
ADD cmd cmd | |
ADD internal internal | |
ADD pkg pkg | |
ADD main.go . | |
# Set arg/env after go mod download, otherwise we invalidate the cached layers due to the commit changing easily | |
ARG ELEMENTAL_VERSION=0.0.1 | |
ARG ELEMENTAL_COMMIT="" | |
ENV ELEMENTAL_VERSION=${ELEMENTAL_VERSION} | |
ENV ELEMENTAL_COMMIT=${ELEMENTAL_COMMIT} | |
RUN go build \ | |
-ldflags "-w -s \ | |
-X github.com/rancher/elemental-toolkit/internal/version.version=$ELEMENTAL_VERSION \ | |
-X github.com/rancher/elemental-toolkit/internal/version.gitCommit=$ELEMENTAL_COMMIT" \ | |
-o /usr/bin/elemental | |
FROM --platform=linux/amd64 golang:${GO_VERSION}-alpine AS elemental-bin | |
ENV CGO_ENABLED=0 | |
WORKDIR /src/ | |
# Add specific dirs to the image so cache is not invalidated when modifying non go files | |
ADD go.mod . | |
ADD go.sum . | |
ADD vendor vendor | |
RUN go mod download | |
ADD cmd cmd | |
ADD internal internal | |
ADD pkg pkg | |
ADD main.go . | |
# Set arg/env after go mod download, otherwise we invalidate the cached layers due to the commit changing easily | |
ARG ELEMENTAL_VERSION=0.0.1 | |
ARG ELEMENTAL_COMMIT="" | |
ENV ELEMENTAL_VERSION=${ELEMENTAL_VERSION} | |
ENV ELEMENTAL_COMMIT=${ELEMENTAL_COMMIT} | |
RUN go build \ | |
-ldflags "-w -s \ | |
-X github.com/rancher/elemental-toolkit/internal/version.version=$ELEMENTAL_VERSION \ | |
-X github.com/rancher/elemental-toolkit/internal/version.gitCommit=$ELEMENTAL_COMMIT" \ | |
-o /usr/bin/elemental | |
FROM --platform=linux/arm64 golang:${GO_VERSION}-alpine AS elemental-bin | |
ENV CGO_ENABLED=0 | |
WORKDIR /src/ | |
# Add specific dirs to the image so cache is not invalidated when modifying non go files | |
ADD go.mod . | |
ADD go.sum . | |
ADD vendor vendor | |
RUN go mod download | |
ADD cmd cmd | |
ADD internal internal | |
ADD pkg pkg | |
ADD main.go . | |
# Set arg/env after go mod download, otherwise we invalidate the cached layers due to the commit changing easily | |
ARG ELEMENTAL_VERSION=0.0.1 | |
ARG ELEMENTAL_COMMIT="" | |
ENV ELEMENTAL_VERSION=${ELEMENTAL_VERSION} | |
ENV ELEMENTAL_COMMIT=${ELEMENTAL_COMMIT} | |
RUN go build \ | |
-ldflags "-w -s \ | |
-X github.com/rancher/elemental-toolkit/internal/version.version=$ELEMENTAL_VERSION \ | |
-X github.com/rancher/elemental-toolkit/internal/version.gitCommit=$ELEMENTAL_COMMIT" \ | |
-o /usr/bin/elemental | |
FROM --platform=linux/amd64 registry.opensuse.org/opensuse/tumbleweed:latest AS elemental | |
# This helps invalidate the cache on each build so the following steps are really run again getting the latest packages | |
# versions, as long as the elemental commit has changed | |
ARG ELEMENTAL_COMMIT="" | |
ENV ELEMENTAL_COMMIT=${ELEMENTAL_COMMIT} | |
RUN zypper install -y --no-recommends xfsprogs \ | |
parted \ | |
util-linux-systemd \ | |
e2fsprogs \ | |
util-linux \ | |
udev \ | |
rsync \ | |
grub2 \ | |
dosfstools \ | |
grub2-x86_64-efi \ | |
squashfs \ | |
mtools \ | |
xorriso \ | |
cosign \ | |
gptfdisk \ | |
lvm2 | |
COPY --from=elemental-bin /usr/bin/elemental /usr/bin/elemental | |
# Fix for blkid only using udev on opensuse | |
RUN echo "EVALUATE=scan" >> /etc/blkid.conf | |
ENTRYPOINT ["/usr/bin/elemental"] | |
# Add to /system/oem folder so install/upgrade/reset hooks will run when running this container. | |
# Needed for boot-assessment | |
COPY pkg/features/embedded/cloud-config-essentials/system/oem /system/oem/ | |
FROM --platform=linux/arm64 registry.opensuse.org/opensuse/tumbleweed:latest AS elemental | |
# This helps invalidate the cache on each build so the following steps are really run again getting the latest packages | |
# versions, as long as the elemental commit has changed | |
ARG ELEMENTAL_COMMIT="" | |
ENV ELEMENTAL_COMMIT=${ELEMENTAL_COMMIT} | |
RUN zypper install -y --no-recommends xfsprogs \ | |
parted \ | |
util-linux-systemd \ | |
e2fsprogs \ | |
util-linux \ | |
udev \ | |
rsync \ | |
grub2 \ | |
dosfstools \ | |
grub2-arm64-efi \ | |
squashfs \ | |
mtools \ | |
xorriso \ | |
cosign \ | |
gptfdisk \ | |
lvm2 | |
COPY --from=elemental-bin /usr/bin/elemental /usr/bin/elemental | |
# Fix for blkid only using udev on opensuse | |
RUN echo "EVALUATE=scan" >> /etc/blkid.conf | |
ENTRYPOINT ["/usr/bin/elemental"] | |
# Add to /system/oem folder so install/upgrade/reset hooks will run when running this container. | |
# Needed for boot-assessment | |
COPY pkg/features/embedded/cloud-config-essentials/system/oem /system/oem/ | |
FROM --platform=linux/riscv64 registry.opensuse.org/opensuse/factory/riscv/images/opensuse/tumbleweed:latest AS elemental | |
# This helps invalidate the cache on each build so the following steps are really run again getting the latest packages | |
# versions, as long as the elemental commit has changed | |
ARG ELEMENTAL_COMMIT="" | |
ENV ELEMENTAL_COMMIT=${ELEMENTAL_COMMIT} | |
RUN zypper --non-interactive removerepo repo-update && \ | |
zypper install -y --no-recommends xfsprogs \ | |
parted \ | |
util-linux-systemd \ | |
e2fsprogs \ | |
util-linux \ | |
udev \ | |
rsync \ | |
grub2 \ | |
dosfstools \ | |
grub2-riscv64-efi \ | |
squashfs \ | |
mtools \ | |
xorriso \ | |
cosign \ | |
gptfdisk \ | |
lvm2 | |
COPY --from=elemental-bin /usr/bin/elemental /usr/bin/elemental | |
# Fix for blkid only using udev on opensuse | |
RUN echo "EVALUATE=scan" >> /etc/blkid.conf | |
ENTRYPOINT ["/usr/bin/elemental"] | |
# Add to /system/oem folder so install/upgrade/reset hooks will run when running this container. | |
# Needed for boot-assessment | |
COPY pkg/features/embedded/cloud-config-essentials/system/oem /system/oem/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment