From 4109eb1df3e7cca916a094169592e33b73ad0a37 Mon Sep 17 00:00:00 2001 From: Kornilios Kourtis Date: Wed, 20 Jul 2022 14:12:28 +0200 Subject: [PATCH] initial version Signed-off-by: Kornilios Kourtis --- Makefile | 11 +++++++++++ README.md | 12 ++++++++++++ _data/.dockerignore | 2 ++ _data/.gitignore | 2 ++ _data/images.json | 24 ++++++++++++++++++++++++ dockerfiles/root-builder | 9 +++++++++ dockerfiles/root-images | 10 ++++++++++ 7 files changed, 70 insertions(+) create mode 100644 Makefile create mode 100644 README.md create mode 100644 _data/.dockerignore create mode 100644 _data/.gitignore create mode 100644 _data/images.json create mode 100644 dockerfiles/root-builder create mode 100644 dockerfiles/root-images diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..9fc999de --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ + +OCIORG ?= quay.io/lvh-images +LVH ?= $(OCIORG)/lvh +ROOT_BUILDER ?= $(OCIORG)/root-builder +ROOT_IMAGES ?= $(OCIORG)/root-images +DOCKER ?= docker + +.PHONY: images +images: + $(DOCKER) build -f dockerfiles/root-builder -t $(ROOT_BUILDER) . + $(DOCKER) build -f dockerfiles/root-images -t $(ROOT_IMAGES) . diff --git a/README.md b/README.md new file mode 100644 index 00000000..d2c28183 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +This repository contains (little-vm-helper)[https://github.com/cilium/little-vm-helper] +configuration files and dockerfiles for building kernel and rootfs images. + +- [configuration](_data/images.json) for building root images (single image for now) +- [dockerfile](./dockerfiles/root-builder) for a container that can be used to build root images +- [dockerfile](./dockerfiles/root-images) for a container with the root images + +### Issues + - Using docker build means that there will be no /dev/kvm device in the builder which will + unfortunately result in slower builds than what you would get otherwise. There are some hints + in https://github.com/moby/moby/issues/1916 that this might be solved using buildx, but I'm not + sure how. diff --git a/_data/.dockerignore b/_data/.dockerignore new file mode 100644 index 00000000..5f5e92e3 --- /dev/null +++ b/_data/.dockerignore @@ -0,0 +1,2 @@ +images +kernels diff --git a/_data/.gitignore b/_data/.gitignore new file mode 100644 index 00000000..a2b24a48 --- /dev/null +++ b/_data/.gitignore @@ -0,0 +1,2 @@ +/images +/kernels diff --git a/_data/images.json b/_data/images.json new file mode 100644 index 00000000..a87e0584 --- /dev/null +++ b/_data/images.json @@ -0,0 +1,24 @@ +[ + { + "name": "base.qcow2", + "packages": [ + "less", + "vim", + "sudo", + "openssh-server", + "curl", + "bpftool", + "iproute2", + "util-linux" + ], + "actions": [ + { + "comment": "disable password for root", + "op": { + "Cmd": "passwd -d root" + }, + "type": "run-command" + } + ] + } +] diff --git a/dockerfiles/root-builder b/dockerfiles/root-builder new file mode 100644 index 00000000..6a784572 --- /dev/null +++ b/dockerfiles/root-builder @@ -0,0 +1,9 @@ +# vim: set ft=dockerfile: +FROM quay.io/lvh-images/lvh AS lvh + +FROM debian:sid +WORKDIR / +RUN apt-get update -yq && \ + apt-get upgrade -yq && \ + apt-get install -yq mmdebstrap libguestfs-tools qemu-utils extlinux +COPY --from=lvh /usr/bin/lvh /usr/bin/lvh diff --git a/dockerfiles/root-images b/dockerfiles/root-images new file mode 100644 index 00000000..966d6bd2 --- /dev/null +++ b/dockerfiles/root-images @@ -0,0 +1,10 @@ +# vim: set ft=dockerfile: +FROM quay.io/lvh-images/root-builder AS builder +COPY _data /data +WORKDIR /data +# mmdebstrap outputs messages in stderr, so we redirect stderr +RUN lvh images build --dir . 2>&1 + +FROM busybox +COPY --from=builder /data/images/base.qcow2 /images/base.qcow2 +RUN gzip /images/base.qcow2