forked from lima-vm/alpine-lima
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (87 loc) · 3.33 KB
/
Makefile
File metadata and controls
99 lines (87 loc) · 3.33 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
92
93
94
95
96
97
98
99
ALPINE_VERSION ?= 3.23.0
REPO_VERSION ?= $(shell echo "$(ALPINE_VERSION)" | sed -E 's/^([0-9]+\.[0-9]+).*/v\1/')
GIT_TAG ?= $(shell echo "v$(ALPINE_VERSION)" | sed 's/^vedge$$/origin\/master/')
BUILD_ID ?= $(shell git describe --tags)
DOCKER ?= docker
# Editions should be 5 chars or less because the full name is used as
# the volume id, and cannot exceed 32 characters.
# len("alpine-lima-12345-3.13.5-x86_64") == 31
EDITION ?= std
# Architecture defaults to the current system's.
ARCH ?= $(shell uname -m)
ifeq ($(strip $(ARCH)),arm64)
ARCH = aarch64
endif
# ARCH is derived from `uname -m` but the alternate architecture name (e.g. amd64, arm64)
# is required for Docker and asset downloads.
ARCH_ALIAS_x86_64 = amd64
ARCH_ALIAS_aarch64 = arm64
ARCH_ALIAS = $(shell echo "$(ARCH_ALIAS_$(ARCH))")
BINFMT_IMAGE=tonistiigi/binfmt:qemu-$(QEMU_VERSION)
CRI_DOCKERD_ORG=Mirantis
CRI_DOCKERD_VERSION=0.3.17
NERDCTL_VERSION=2.3.1
OPENRESTY_VERSION=0.0.7
QEMU_VERSION=v9.2.2-52
.PHONY: mkimage
mkimage: openresty-v$(OPENRESTY_VERSION)-$(ARCH).tar
cd src/aports && git fetch && git checkout $(GIT_TAG)
$(DOCKER) build \
--progress plain --no-cache \
--tag mkimage:$(ALPINE_VERSION)-$(ARCH) \
--build-arg ALPINE_VERSION=$(ALPINE_VERSION) \
--build-arg ARCH=$(ARCH) \
--build-arg BINFMT_IMAGE=$(BINFMT_IMAGE) \
--build-arg OPENRESTY_VERSION=$(OPENRESTY_VERSION) \
--platform linux/$(ARCH_ALIAS) \
.
.PHONY: iso
iso:
ALPINE_VERSION=$(ALPINE_VERSION) \
CRI_DOCKERD_VERSION=$(CRI_DOCKERD_VERSION) \
NERDCTL_VERSION=$(NERDCTL_VERSION) \
QEMU_VERSION=$(QEMU_VERSION) \
ARCH=$(ARCH) \
ARCH_ALIAS=$(ARCH_ALIAS) \
BUILD_ID=$(BUILD_ID) \
EDITION=$(EDITION) \
REPO_VERSION=$(REPO_VERSION) \
./build.sh
iso: cri-dockerd-$(CRI_DOCKERD_VERSION)-$(ARCH)
cri-dockerd-$(CRI_DOCKERD_VERSION)-$(ARCH):
curl -o $@ -Ls https://github.com/$(CRI_DOCKERD_ORG)/cri-dockerd/releases/download/v$(CRI_DOCKERD_VERSION)/cri-dockerd-$(CRI_DOCKERD_VERSION).$(ARCH_ALIAS).tgz
curl -o $@.LICENSE -Ls https://raw.githubusercontent.com/$(CRI_DOCKERD_ORG)/cri-dockerd/v$(CRI_DOCKERD_VERSION)/LICENSE
iso: nerdctl-full-$(NERDCTL_VERSION)-$(ARCH)
nerdctl-full-$(NERDCTL_VERSION)-$(ARCH):
curl -o $@ -Ls https://github.com/containerd/nerdctl/releases/download/v$(NERDCTL_VERSION)/nerdctl-full-$(NERDCTL_VERSION)-linux-$(ARCH_ALIAS).tar.gz
iso: openresty-v$(OPENRESTY_VERSION)-$(ARCH).tar
openresty-v$(OPENRESTY_VERSION)-$(ARCH).tar:
curl -o $@ -Ls https://github.com/rancher-sandbox/openresty-packaging/releases/download/v$(OPENRESTY_VERSION)/$@
iso: qemu-$(QEMU_VERSION)-copying
qemu-$(QEMU_VERSION)-copying:
curl -o $@ -Ls https://raw.githubusercontent.com/qemu/qemu/$(QEMU_VERSION)/COPYING
.PHONY: lima
lima:
ALPINE_VERSION=$(ALPINE_VERSION) EDITION=$(EDITION) ARCH=$(ARCH) ./lima.sh
.PHONY: run
run:
accel=tcg; display=sdl; \
case "$(shell uname)" in \
Darwin) accel=hvf; display=cocoa;; \
Linux) accel=kvm; display=gtk;; \
esac; \
qemu-system-$(ARCH) \
-boot order=d,splash-time=0,menu=on \
-cdrom iso/alpine-lima-$(EDITION)-$(ALPINE_VERSION)-$(ARCH).iso \
-cpu host \
-machine q35,accel=$$accel \
-smp 4,sockets=1,cores=4,threads=1 \
-m 4096 \
-net nic,model=virtio \
-net user,net=192.168.5.0/24,hostfwd=tcp:127.0.0.1:20022-:22 \
-display $$display \
-device virtio-rng-pci \
-device virtio-vga \
-device virtio-keyboard-pci \
-device virtio-mouse-pci \
-parallel none