-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathmakefile
130 lines (97 loc) · 3.72 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# {{{ -- meta
HOSTARCH := $(shell uname -m | sed "s_armv6l_armhf_")# x86_64 on travis.ci, armhf in test
ARCH := $(shell uname -m | sed "s_armv6l_armhf_")# armhf/x86_64 auto-detect on build and run
OPSYS := alpine
SHCOMMAND := /bin/bash
SVCNAME := pulseaudio
USERNAME := woahbase
PUID := $(shell id -u)
PGID := $(shell id -g)# gid 100(users) usually pre exists
DOCKERSRC := $(OPSYS)-s6#
DOCKEREPO := $(OPSYS)-$(SVCNAME)
IMAGETAG := $(USERNAME)/$(DOCKEREPO):$(ARCH)
CNTNAME := $(SVCNAME) # name for container name : docker_name, hostname : name
BUILD_NUMBER := 0#assigned in .travis.yml
BRANCH := master
# -- }}}
# {{{ -- flags
BUILDFLAGS := --rm --force-rm --compress \
-f $(CURDIR)/Dockerfile_$(ARCH) \
-t $(IMAGETAG) \
--build-arg DOCKERSRC=$(USERNAME)/$(DOCKERSRC):$(ARCH) \
--build-arg PUID=$(PUID) \
--build-arg PGID=$(PGID) \
--build-arg http_proxy=$(http_proxy) \
--build-arg https_proxy=$(https_proxy) \
--build-arg no_proxy=$(no_proxy) \
--label online.woahbase.source-image=$(DOCKERSRC) \
--label online.woahbase.build-number=$(BUILD_NUMBER) \
--label online.woahbase.branch=$(BRANCH) \
--label org.label-schema.build-date=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ") \
--label org.label-schema.name=$(DOCKEREPO) \
--label org.label-schema.schema-version="1.0" \
--label org.label-schema.url="https://woahbase.online/" \
--label org.label-schema.usage="https://woahbase.online/\#/images/$(DOCKEREPO)" \
--label org.label-schema.vcs-ref=$(shell git rev-parse --short HEAD) \
--label org.label-schema.vcs-url="https://github.com/$(USERNAME)/$(DOCKEREPO)" \
--label org.label-schema.vendor=$(USERNAME)
CACHEFLAGS := --no-cache=true --pull
MOUNTFLAGS := -v /var/run/dbus:/var/run/dbus
# -v $(CURDIR)/config/pulse:/etc/pulse \
# -v $(CURDIR)/config/bluetooth:/etc/bluetooth \
# -v $(CURDIR)/config/devices:/var/lib/bluetooth \
# -v $(CURDIR)/config/dbus:/etc/dbus-1
NAMEFLAGS := --name docker_$(CNTNAME) --hostname $(CNTNAME)
OTHERFLAGS := -v /etc/hosts:/etc/hosts:ro -v /etc/localtime:/etc/localtime:ro # -e TZ=Asia/Kolkata
PORTFLAGS := -p 4713:4713
RUNFLAGS := -c 256 -m 256m \
-e PGID=$(PGID) -e PUID=$(PUID) \
--cap-add NET_ADMIN \
--device /dev/snd \
--net=host \
--device /dev/bus/usb
# -e DISABLEBLUETOOTH=false
# -- }}}
# {{{ -- docker targets
all : run
build :
echo "Building for $(ARCH) from $(HOSTARCH)";
if [ "$(ARCH)" != "$(HOSTARCH)" ]; then make regbinfmt ; fi;
docker build $(BUILDFLAGS) $(CACHEFLAGS) .
clean :
docker images | awk '(NR>1) && ($$2!~/none/) {print $$1":"$$2}' | grep "$(USERNAME)/$(DOCKEREPO)" | xargs -n1 docker rmi
logs :
docker logs -f docker_$(CNTNAME)
pull :
docker pull $(IMAGETAG)
push :
docker push $(IMAGETAG);
if [ "$(ARCH)" = "$(HOSTARCH)" ]; \
then \
LATESTTAG=$$(echo $(IMAGETAG) | sed 's/:$(ARCH)/:latest/'); \
docker tag $(IMAGETAG) $${LATESTTAG}; \
docker push $${LATESTTAG}; \
fi;
restart :
docker ps -a | grep 'docker_$(CNTNAME)' -q && docker restart docker_$(CNTNAME) || echo "Service not running.";
rm :
docker rm -f docker_$(CNTNAME)
run :
docker run --rm -it $(NAMEFLAGS) $(RUNFLAGS) $(PORTFLAGS) $(MOUNTFLAGS) $(OTHERFLAGS) $(IMAGETAG)
shell :
docker run --rm -it $(NAMEFLAGS) $(RUNFLAGS) $(PORTFLAGS) $(MOUNTFLAGS) $(OTHERFLAGS) --entrypoint $(SHCOMMAND) $(IMAGETAG)
mixer :
docker exec -u root -it docker_$(CNTNAME) /usr/local/bin/pulsemixer
rdebug :
docker exec -u root -it docker_$(CNTNAME) $(SHCOMMAND)
debug :
docker exec -u pulse -it docker_$(CNTNAME) $(SHCOMMAND)
stop :
docker stop -t 2 docker_$(CNTNAME)
test :
docker run --rm -it $(NAMEFLAGS) --entrypoint sh $(IMAGETAG) -ec 'pulseaudio --version'
# -- }}}
# {{{ -- other targets
regbinfmt :
docker run --rm --privileged multiarch/qemu-user-static:register --reset
# -- }}}