-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJustfile
More file actions
46 lines (39 loc) · 2.11 KB
/
Justfile
File metadata and controls
46 lines (39 loc) · 2.11 KB
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
40
41
42
43
44
45
46
mod bcvk 'bcvk.just'
image_name := env("BUILD_IMAGE_NAME", "")
image_tag := env("BUILD_IMAGE_TAG", "latest")
base_dir := env("BUILD_BASE_DIR", ".")
filesystem := env("BUILD_FILESYSTEM", "ext4")
selinux := env("BUILD_SELINUX", "true")
options := if selinux == "true" { "-v /var/lib/containers:/var/lib/containers:Z -v /etc/containers:/etc/containers:Z -v /sys/fs/selinux:/sys/fs/selinux --security-opt label=type:unconfined_t" } else { "-v /var/lib/containers:/var/lib/containers -v /etc/containers:/etc/containers" }
container_runtime := env("CONTAINER_RUNTIME", `command -v podman >/dev/null 2>&1 && echo podman || echo docker`)
sudo_prefix := if env("NOSUDO", "") == "" { "sudo " } else { "" }
# Build image and run an ephemeral VM for boot testing
test IMAGE=image_name:
just bcvk build-and-test {{IMAGE}}
build $image_name=image_name:
{{sudo_prefix}}{{container_runtime}} build -f {{image_name}}/Containerfile -t "${image_name}-bootc:latest" .
bootc $image_name=image_name $image_tag=image_tag *ARGS:
sudo {{container_runtime}} run \
--rm --privileged --pid=host \
-it \
{{options}} \
-v /dev:/dev \
-e RUST_LOG=debug \
-v "{{base_dir}}:/data" \
"${image_name}-bootc:${image_tag}" bootc {{ARGS}}
disk-image $image_name=image_name $image_tag=image_tag $base_dir=base_dir $filesystem=filesystem:
#!/usr/bin/env bash
if [ ! -e "${base_dir}/bootable.img" ] ; then
fallocate -l 20G "${base_dir}/bootable.img"
fi
just bootc $image_name $image_tag install to-disk --composefs-backend --via-loopback /data/bootable.img --filesystem "${filesystem}" --wipe --bootloader systemd
rechunk $image_name=image_name:
#!/usr/bin/env bash
export CHUNKAH_CONFIG_STR="$(podman inspect "${image_name}-bootc")"
podman run --rm "--mount=type=image,src=${image_name}-bootc,dest=/chunkah" -e CHUNKAH_CONFIG_STR quay.io/coreos/chunkah build --label ostree.bootable=1 --compressed --max-layers 128 | \
podman load | \
sort -n | \
head -n1 | \
cut -d, -f2 | \
cut -d: -f3 | \
xargs -I{} podman tag {} "${image_name}-bootc"