forked from rancher/k3os
/
Dockerfile
39 lines (33 loc) · 1.18 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
ARG REPO
ARG TAG
FROM ${REPO}/k3os-tar:${TAG} as tar
ARG REPO
ARG TAG
FROM ${REPO}/k3os-kernel:${TAG} as kernel
ARG REPO
ARG TAG
FROM ${REPO}/k3os-base:${TAG} as base
ARG VERSION
ARG ARCH
RUN apk add xorriso grub grub-efi mtools libvirt qemu-img
RUN if [ "$ARCH" == "amd64" ]; then \
apk add qemu-system-x86_64 grub-bios ovmf \
;elif [ "$ARCH" == "arm64" ]; then \
apk add qemu-system-aarch64 \
;fi
RUN ln -s /usr/bin/qemu-system-* /usr/bin/qemu-system
RUN qemu-img create -f qcow2 /hd.img 40G
COPY run-kvm.sh /usr/bin/
COPY grub.cfg /usr/src/iso/boot/grub/grub.cfg
COPY --from=kernel /output/ /usr/src/kernel/
RUN cd /usr/src/kernel && \
mkdir -p /usr/src/iso/k3os/system/kernel/$(cat version) && \
cp initrd kernel.squashfs /usr/src/iso/k3os/system/kernel/$(cat version) && \
ln -s $(cat version) /usr/src/iso/k3os/system/kernel/current
COPY --from=tar /output/userspace.tar /usr/src/tars/
RUN tar xvf /usr/src/tars/userspace.tar --strip-components=1 -C /usr/src/iso
RUN mkdir -p /output && \
cd /usr/src/iso && \
grub-mkrescue -o /output/k3os.iso . -V K3OS && \
[ -e /output/k3os.iso ] # grub-mkrescue doesn't exit non-zero on failure
CMD ["run-kvm.sh"]