-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
113 lines (97 loc) · 3.55 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
# This file is protected by Copyright. Please refer to the COPYRIGHT file
# distributed with this source distribution.
#
# This file is part of Docker REDHAWK.
#
# Docker REDHAWK is free software: you can redistribute it and/or modify it under
# the terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Docker REDHAWK is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see http://www.gnu.org/licenses/.
#
VERSION := 2.0.6
image_prefix := geontech/redhawk-ubuntu
base := $(image_prefix)-base
omni := $(image_prefix)-omniserver
runtime := $(image_prefix)-runtime
redhawk_images := \
$(image_prefix)-development \
$(image_prefix)-domain \
$(image_prefix)-gpp \
$(image_prefix)-usrp \
$(image_prefix)-rtl2832u \
$(image_prefix)-bu353s4
redhawk_webserver := $(image_prefix)-webserver
all_images := $(base) $(omni) $(runtime) $(redhawk_images) $(redhawk_webserver)
reversed := $(redhawk_webserver) $(redhawk_images) $(runtime) $(omni) $(base)
linked_scripts := omniserver domain sdrroot login gpp rhide volume-manager webserver usrp rtl2832u bu353s4 show-log
# Default REST-python server and branch
REST_PYTHON := http://github.com/GeonTech/rest-python.git
REST_PYTHON_BRANCH := master
# Macros for querying an image vs. building one.
image_check = $(strip $(shell docker images -q $1))
image_build = docker build --rm \
$2 \
-f ./Dockerfiles/$(subst $(image_prefix)-,,$1).Dockerfile \
-t $1:$(VERSION) \
./Dockerfiles \
&& \
docker tag $@:$(VERSION) $@:latest
.PHONY: all_pulled deliver clean $(all_images)
# Everything, pulled
all: $(linked_scripts)
@for image in $(all_images) ; do \
docker pull $$image:$(VERSION) ; \
docker tag $$image:$(VERSION) $$image:latest ; \
done
# Rebuild from scratch
build: $(all_images) $(linked_scripts)
deliver: $(all_images)
$(eval result := $(foreach image,$(all_images),\
$(shell docker push $(image):$(VERSION)) \
$(shell docker push $(image):latest))\
)
# Image building targets
$(base):
$(call image_build,$@)
$(omni) $(runtime): $(base)
$(call image_build,$@)
$(redhawk_images): $(runtime)
$(call image_build,$@)
$(redhawk_webserver): $(runtime)
$(eval BUILD_ARGS = --build-arg REST_PYTHON=$(REST_PYTHON) --build-arg REST_PYTHON_BRANCH=$(REST_PYTHON_BRANCH))
@echo Build Arguments: ${BUILD_ARGS}
$(call image_build,$@,$(BUILD_ARGS))
# Launcher/helper script targets
helper_scripts: $(linked_scripts)
$(linked_scripts):
@ln -s scripts/[email protected] ./$@
@chmod a+x ./$@
# Cleaning
remove_container = $(shell docker rm -f $1)
remove_image = $(shell docker rmi $1)
list_containers = $(shell docker ps -qa --filter="ancestor=$1")
for_each_container = $(foreach container,$(call list_containers,$1),\
$(call remove_container,$(container)) \
$(info --> Removed $(container)) \
)
for_each_image = $(foreach image,$1,\
$(info Checking $(image):$(VERSION)...) \
$(if $(call image_check,$(image):$(VERSION)),\
$(call for_each_container,$(image)) \
$(call remove_image,$(image):$(VERSION)) \
$(call remove_image,$(image):latest) \
$(info Removed with $(image):$(VERSION) and latest), \
$(info Nothing to do for $(image):$(VERSION)) \
)\
)
clean:
@$(eval result := $(call for_each_image,$(reversed)))
@rm -f $(linked_scripts)