-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
89 lines (81 loc) · 3.02 KB
/
Makefile
File metadata and controls
89 lines (81 loc) · 3.02 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
image_name := ghcr.io/jdobes/myserver
tag := $(shell date "+%Y%m%d")
platform := $(shell uname -sm)
user := $(shell whoami)
.PHONY: all
all: clean build-oci build-qcow ## clean and build OCI + qcow2 image (default)
.PHONY: help
help: ## show help
@awk 'BEGIN {FS = ":.*##"; printf "Usage:\n make \033[36m\033[0m\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: clean
clean: ## clean build artifacts
sudo podman rmi -i $(image_name):$(tag) $(image_name):latest
sudo rm -rf output
.PHONY: build-oci
build-oci: ## build OCI image
# --pull=newer is broken currently - https://github.com/containers/podman/issues/22845
sudo podman build --label=org.opencontainers.image.version=$(tag) --squash -t $(image_name):$(tag) -t $(image_name):latest .
.PHONY: build-qcow
build-qcow: ## build qcow2 image
mkdir -p output
sudo podman run --rm -it --privileged --pull=newer --security-opt label=type:unconfined_t \
-v ./config.toml:/config.toml:ro \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest --type qcow2 --rootfs xfs $(image_name):latest
ifeq ($(platform),Linux x86_64)
sudo chown -R $(user):$(user) output/
else ifeq ($(platform),Darwin arm64)
sudo chown -R $(user):staff output/
else
@echo "Unsupported platform"
endif
.PHONY: build-iso
build-iso: ## build anaconda ISO
# --rootfs is broken currently - https://github.com/osbuild/bootc-image-builder/issues/924
mkdir -p output
sudo podman run --rm -it --privileged --pull=newer --security-opt label=type:unconfined_t \
-v ./config.toml:/config.toml:ro \
-v ./output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest --type anaconda-iso --rootfs xfs $(image_name):latest
ifeq ($(platform),Linux x86_64)
sudo chown -R $(user):$(user) output/
else ifeq ($(platform),Darwin arm64)
sudo chown -R $(user):staff output/
else
@echo "Unsupported platform"
endif
.PHONY: run-container
run-container: ## run as a container
sudo podman run --rm -it $(image_name):latest bash
.PHONY: run-vm
run-vm: ## run as a virtual machine
ifeq ($(platform),Linux x86_64)
qemu-system-x86_64 \
-M accel=kvm \
-cpu host \
-smp 2 \
-m 4096 \
-bios /usr/share/OVMF/OVMF_CODE.fd \
-monitor stdio \
-vnc none \
-net nic \
-net user,hostfwd=tcp::2222-:57657,hostfwd=tcp::5353-:53,hostfwd=tcp::8080-:80,hostfwd=tcp::8443-:443 \
output/qcow2/disk.qcow2
else ifeq ($(platform),Darwin arm64)
qemu-system-aarch64 \
-M accel=hvf \
-cpu host \
-smp 2 \
-m 4096 \
-bios $(shell brew info qemu | grep /opt/homebrew/Cellar/qemu/ | awk '{print $$1}')/share/qemu/edk2-aarch64-code.fd \
-monitor stdio \
-vnc none \
-machine virt \
-net nic \
-net user,hostfwd=tcp::2222-:57657,hostfwd=tcp::5353-:53,hostfwd=tcp::8080-:80,hostfwd=tcp::8443-:443 \
output/qcow2/disk.qcow2
else
@echo "Unsupported platform"
endif