Skip to content

Commit 84376e9

Browse files
committed
Build VM disk image for bootc installation VM
The image contains a disk image for the installation VM. The installation VM can be use in order to run privileged commands unsing rootless podman. It already contains podman, it has a systemd service which proxies the vsock to the local podman unix socket. It also mounts on boot a bunch of directories which contain shared mount points with the host in order to shared the build artifacts, configurations and the container storage. Signed-off-by: Alice Frosi <[email protected]>
1 parent 0125ec1 commit 84376e9

File tree

3 files changed

+62
-0
lines changed

3 files changed

+62
-0
lines changed

Makefile

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ binary_name = podman-bootc
22
output_dir = bin
33
build_tags = exclude_graphdriver_btrfs,btrfs_noversion,exclude_graphdriver_devicemapper,containers_image_openpgp,remote
44

5+
registry = quay.io/containers
6+
vm_image_name = bootc-vm
7+
vm_image_tag = latest
8+
vm_image = $(registry)/$(vm_image_name):$(vm_image_tag)
9+
510
all: out_dir docs
611
go build -tags $(build_tags) $(GOOPTS) -o $(output_dir)/$(binary_name)
712

@@ -18,6 +23,11 @@ integration_tests:
1823
e2e_test: all
1924
ginkgo -tags $(build_tags) ./test/...
2025

26+
image:
27+
podman build -t $(vm_image) --device /dev/kvm \
28+
-f containerfiles/vm/Containerfile \
29+
containerfiles/vm
30+
2131
.PHONY: docs
2232
docs:
2333
make -C docs

containerfiles/vm/Containerfile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
FROM quay.io/fedora/fedora:42 as builder
2+
3+
ENV URL https://download.fedoraproject.org/pub/fedora/linux/releases/42/Cloud/x86_64/images
4+
ENV IMAGE Fedora-Cloud-Base-Generic-42-1.1.x86_64.qcow2
5+
ENV CHECKSUM Fedora-Cloud-42-1.1-x86_64-CHECKSUM
6+
ENV LIBGUESTFS_BACKEND direct
7+
8+
RUN dnf install -y curl libguestfs guestfs-tools curl
9+
10+
RUN curl -L -O $URL/$IMAGE \
11+
&& curl -L -O $URL/$CHECKSUM \
12+
&& curl -O https://fedoraproject.org/fedora.gpg \
13+
&& gpgv --keyring ./fedora.gpg $CHECKSUM \
14+
&& sha256sum --ignore-missing -c $CHECKSUM \
15+
&& mv $IMAGE /disk.img
16+
17+
RUN mkdir -p /systemd-services
18+
COPY ./podman-vsock-proxy.service /systemd-services/podman-vsock-proxy.service
19+
RUN virt-copy-in -a /disk.img /systemd-services/* /etc/systemd/system
20+
21+
# Configuration of the guest image
22+
RUN virt-customize -a /disk.img --install socat,podman \
23+
--root-password password:bootc \
24+
--run-command "sed -i 's/SELINUX=.*/SELINUX=disabled/g' /etc/selinux/config" \
25+
--run-command "mkdir -p /usr/lib/bootc/config" \
26+
--run-command "echo \"config /usr/lib/bootc/config virtiofs rw,relatime,nofail 0 0\" >> /etc/fstab" \
27+
--run-command "mkdir -p /usr/lib/bootc/storage" \
28+
--run-command "echo \"storage /usr/lib/bootc/storage virtiofs rw,relatime,nofail 0 0\" >> /etc/fstab" \
29+
--run-command "mkdir -p /usr/lib/bootc/output" \
30+
--run-command "echo \"output /var/lib/bootc/output virtiofs rw,relatime,nofail 0 0\" >> /etc/fstab" \
31+
--run-command "systemctl enable podman.socket" \
32+
--run-command "systemctl enable podman-vsock-proxy" \
33+
--run-command "sed -i '/^additionalimagestores = \[/a\ \"/usr/lib/bootc/storage\",' /usr/share/containers/storage.conf" \
34+
--run-command "dnf clean all -y" \
35+
&& virt-sparsify --in-place /disk.img
36+
37+
FROM scratch
38+
COPY --from=builder /disk.img /disk.img
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[Unit]
2+
Description=Proxy vsock (PORT: 1234) to Unix podman socket
3+
After=network.target
4+
Requires=network.target
5+
6+
[Service]
7+
Type=simple
8+
ExecStart=/usr/bin/socat VSOCK-LISTEN:1234,reuseaddr,fork UNIX-CONNECT:/var/run/podman/podman.sock
9+
Restart=always
10+
RestartSec=3
11+
12+
[Install]
13+
WantedBy=multi-user.target
14+

0 commit comments

Comments
 (0)