-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
91 lines (70 loc) · 3.74 KB
/
Copy pathMakefile
File metadata and controls
91 lines (70 loc) · 3.74 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
90
91
IMAGE := micro-containers
WASM_IMG := micro-containers-wasm
PORT := 8080
.PHONY: build build-wasm \
run-distroless run-gvisor run-kata run-firecracker run-wasm \
bench bench-md bench-fast \
check health sizes clean
# ── Build ──────────────────────────────────────────────────────────────────
build:
docker build -t $(IMAGE) .
build-wasm:
docker build -f runtimes/wasm/Dockerfile -t $(WASM_IMG) .
# ── Run (each target opens the server on :PORT) ────────────────────────────
run-distroless: build
IMAGE=$(IMAGE) PORT=$(PORT) bash runtimes/distroless/run.sh
run-gvisor: build
IMAGE=$(IMAGE) PORT=$(PORT) bash runtimes/gvisor/run.sh
run-kata: build
IMAGE=$(IMAGE) PORT=$(PORT) bash runtimes/kata/run.sh
run-firecracker: build
IMAGE=$(IMAGE) PORT=$(PORT) bash runtimes/firecracker/run.sh
run-wasm: build-wasm
WASM_IMAGE=$(WASM_IMG) bash runtimes/wasm/run.sh
# ── Benchmark (verify + capture performance) ──────────────────────────────
# Full benchmark: builds images, runs all available runtimes, writes bench/results.json
bench:
go run -buildvcs=false ./bench/
# Same but also prints a Markdown table (paste directly into the article)
bench-md:
go run -buildvcs=false ./bench/ -md
# Quick smoke-test: 20 samples, 5 warmup (builds images if needed)
bench-fast:
go run -buildvcs=false ./bench/ -samples=20 -warmup=5
# ── Introspection ──────────────────────────────────────────────────────────
# Check which runtimes are available on this machine
check:
@echo "=== Runtime availability ==="; \
docker version --format 'Docker {{.Server.Version}}' 2>/dev/null \
&& echo " runc: OK (default)" \
|| echo " Docker: NOT FOUND"; \
docker info 2>/dev/null | grep -q '"runsc"' \
&& echo " gVisor (runsc): OK" \
|| echo " gVisor (runsc): not registered → runtimes/gvisor/install.sh"; \
docker info 2>/dev/null | grep -q '"kata-runtime"' \
&& echo " Kata (QEMU): OK" \
|| echo " Kata (QEMU): not registered → runtimes/kata/install.sh"; \
docker info 2>/dev/null | grep -q '"kata-fc"' \
&& echo " Kata (FC): OK" \
|| echo " Kata (FC): not registered → runtimes/firecracker/install.sh"; \
[ -c /dev/kvm ] \
&& echo " KVM (/dev/kvm): OK" \
|| echo " KVM (/dev/kvm): NOT available (required for Kata/Firecracker)"; \
command -v wasmtime &>/dev/null \
&& echo " wasmtime: OK ($(wasmtime --version))" \
|| echo " wasmtime: not found → runtimes/wasm/install.sh"; \
command -v wasmedge &>/dev/null \
&& echo " wasmedge: OK" \
|| echo " wasmedge: not found"
# Probe the running container
health:
@curl -sf http://localhost:$(PORT)/health | python3 -m json.tool \
|| echo "Nothing listening on :$(PORT)"
# ── Sizes ─────────────────────────────────────────────────────────────────
sizes: build build-wasm
@echo "=== Image sizes ==="; \
docker images --format "{{.Repository}}:{{.Tag}}\t{{.Size}}" \
| grep -E "$(IMAGE)|$(WASM_IMG)"
# ── Cleanup ───────────────────────────────────────────────────────────────
clean:
docker rmi -f $(IMAGE) $(WASM_IMG) 2>/dev/null || true