-
Notifications
You must be signed in to change notification settings - Fork 94
/
Makefile
76 lines (62 loc) · 1.74 KB
/
Makefile
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
COL_RED="\033[0;31m"
COL_GRN="\033[0;32m"
COL_END="\033[0m"
UID=$(shell id -u)
GID=$(shell id -g)
VM_DISK_SIZE_MB?=1024
REPO=docker-to-linux
.PHONY:
debian: debian.img
.PHONY:
ubuntu: ubuntu.img
.PHONY:
alpine: alpine.img
%.tar:
@echo ${COL_GRN}"[Dump $* directory structure to tar archive]"${COL_END}
docker build -f $*/Dockerfile -t ${REPO}/$* .
docker export -o $*.tar `docker run -d ${REPO}/$* /bin/true`
%.dir: %.tar
@echo ${COL_GRN}"[Extract $* tar archive]"${COL_END}
docker run -it \
-v `pwd`:/os:rw \
${REPO}/builder bash -c 'mkdir -p /os/$*.dir && tar -C /os/$*.dir --numeric-owner -xf /os/$*.tar'
%.img: builder %.dir
@echo ${COL_GRN}"[Create $* disk image]"${COL_END}
docker run -it \
-v `pwd`:/os:rw \
-e DISTR=$* \
--privileged \
--cap-add SYS_ADMIN \
${REPO}/builder bash /os/create_image.sh ${UID} ${GID} ${VM_DISK_SIZE_MB}
.PHONY:
builder:
@echo ${COL_GRN}"[Ensure builder is ready]"${COL_END}
@if [ "`docker images -q ${REPO}/builder`" = '' ]; then\
docker build -f Dockerfile -t ${REPO}/builder .;\
fi
.PHONY:
builder-interactive:
docker run -it \
-v `pwd`:/os:rw \
--cap-add SYS_ADMIN \
${REPO}/builder bash
.PHONY:
clean: clean-docker-procs clean-docker-images
@echo ${COL_GRN}"[Remove leftovers]"${COL_END}
rm -rf mnt debian.* alpine.* ubuntu.*
.PHONY:
clean-docker-procs:
@echo ${COL_GRN}"[Remove Docker Processes]"${COL_END}
@if [ "`docker ps -qa -f=label=com.iximiuz-project=${REPO}`" != '' ]; then\
docker rm `docker ps -qa -f=label=com.iximiuz-project=${REPO}`;\
else\
echo "<noop>";\
fi
.PHONY:
clean-docker-images:
@echo ${COL_GRN}"[Remove Docker Images]"${COL_END}
@if [ "`docker images -q ${REPO}/*`" != '' ]; then\
docker rmi `docker images -q ${REPO}/*`;\
else\
echo "<noop>";\
fi