summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 705647d552d2c1aa55921955e298fc60e1509097 (plain)
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
docker := $(shell sh -c '[ -f "/usr/bin/docker" ] && echo "docker" || echo "podman"')
voldir := "/home/docker/volumes"
bindir := "$(voldir)/binpkgs"
distdir := "$(voldir)/distfiles"
confdir := "$(voldir)/darklin"
vols := "-v $(bindir):/var/cache/binpkgs -v $(distdir):/var/cache/distfiles -v $(confdir):/darklin"


all: build
install: push

.PHONY: rebuild builder update bash connect start stop restart bash logs debug cancel bootstrap reinit check

# This is bootstrap image
bootstrap: bootstrap/Dockerfile
	$(docker) build --tag chsa/gbootstrap:latest bootstrap

reinit: bootstrap/Dockerfile
	$(docker) build --no-cache --tag chsa/gbootstrap:latest bootstrap

check: bootstrap/Dockerfile
	mkdir -p $(bindir) $(distdir) $(confdir);\
	if [ `$(docker) ps -a | grep chsa/gbootstrap | wc -l` -gt 0 ]; then \
	        $(docker) rm gbootstrap ;\
	fi ;\
	eval $(docker) run --privileged $(vols) --name gbootstrap -it chsa/gbootstrap:latest /bin/bash


# This is builder itself
builder: bootstrap bootstrap/Dockerfile
	$(docker) build --tag chsa/gbuilder:latest builder

update: builder/Dockerfile
	$(docker) build --no-cache --tag chsa/gbuilder:latest builder

bash:
	mkdir -p $(bindir) ;\
	if [ `$(docker) ps | grep chsa/gbuilder:latest | wc -l` -eq 0 ]; then \
	    if [ `$(docker) ps -a | grep gbuilder:latest | wc -l` -gt 0 ]; then \
	        echo "Stalled copy... Remove to continue..." ;\
	        echo "$(docker) rm gbuilder" ;\
	        exit 1 ;\
	    fi ;\
	    eval $(docker) run --privileged $(vols) --name gbuilder -it chsa/gbuilder:latest /bin/bash ;\
	else \
	    echo "Already running..." ;\
	fi

build:
	mkdir -p $(bindir) $(distdir) $(confdir) ;\
	if [ `$(docker) ps | grep chsa/gbuilder:latest | wc -l` -eq 0 ]; then \
	    if [ `$(docker) ps -a | grep gbuilder:latest | wc -l` -gt 0 ]; then \
	        echo "Stalled copy... Remove to continue..." ;\
	        echo "$(docker) rm gbuilder" ;\
	        exit 1 ;\
	    fi ;\
	    eval $(docker) run --privileged $(vols) --name gbuilder -t -d chsa/gbuilder:latest ;\
	else \
	    echo "Already running..." ;\
	fi

stop:
	@if [ `$(docker) ps | grep gbuilder | wc -l` -gt 0 ]; then \
	    $(docker) stop gbuilder ;\
	fi

cancel:
	@if [ `$(docker) ps -a | grep gbuilder | wc -l` -gt 0 ]; then \
	    $(docker) stop gbuilder ;\
	    $(docker) rm -f gbuilder ;\
	fi

restart:
	make cancel
	make build

# Control
logs:
	$(docker) logs -f gbuilder

connect:
	$(docker) exec -it gbuilder /bin/bash

# Slow & big, avoid if possible
debug: stop
	echo "Generating image from container. Thats slow!" ; \
	$(docker) commit gbuilder gbuilder-debug ;\
	mkdir -p $(bindir)  $(distdir) $(confdir) ;\
	eval $(docker) run --privileged $(vols) --name gbuilder-debug -ti bash