8005: Document installing Git on CentOS 6 from RepoForge.
[arvados.git] / docker / build_tools / Makefile
1 # This is the 'shell hack'. Call make with DUMP=1 to see the effect.
2 ifdef DUMP
3 OLD_SHELL := $(SHELL)
4 SHELL = $(warning [$@])$(OLD_SHELL) -x
5 endif
6
7 all: skydns-image skydock-image api-image compute-image doc-image workbench-image keep-image keep-proxy-image sso-image shell-image
8
9 IMAGE_FILES := $(shell ls *-image 2>/dev/null |grep -v -E 'debian-arvados-image|skydns-image|skydock-image')
10 GENERATED_DIRS := $(shell ls */generated 2>/dev/null)
11
12 # `make clean' removes the files generated in the build directory
13 # but does not remove any docker images generated in previous builds
14 clean:
15         @echo "make clean"
16         -@rm -rf build
17         +@[ "$(IMAGE_FILES)" = "" ] || rm -f $(IMAGE_FILES) 2>/dev/null
18         +@[ "$(GENERATED_DIRS)" = "" ] || rm -rf */generated 2>/dev/null
19
20 DEBIAN_IMAGE := $(shell $(DOCKER) images -q arvados/debian |head -n1)
21
22 REALCLEAN_CONTAINERS := $(shell $(DOCKER) ps -a |grep -e arvados -e api_server -e keep_server -e keep_proxy_server -e doc_server -e workbench_server |cut -f 1 -d' ')
23 # Generate a list of docker images tagged as arvados/*
24 # but exclude those tagged as arvados/build
25 ADI_TEMPFILE := $(shell mktemp)
26 ARVADOS_DOCKER_IMAGES := $(shell $(DOCKER) images -q arvados/* |sort > $(ADI_TEMPFILE))
27 ABDI_TEMPFILE := $(shell mktemp)
28 ARVADOS_BUILD_DOCKER_IMAGES := $(shell $(DOCKER) images -q arvados/build |sort > $(ABDI_TEMPFILE))
29 REALCLEAN_IMAGES := $(shell comm -3 $(ADI_TEMPFILE) $(ABDI_TEMPFILE) |grep -v $(DEBIAN_IMAGE) 2>/dev/null)
30 DEEPCLEAN_IMAGES := $(shell comm -3 $(ADI_TEMPFILE) $(ABDI_TEMPFILE))
31 SKYDNS_CONTAINERS := $(shell $(DOCKER) ps -a |grep -e crosbymichael/skydns -e crosbymichael/skydock |cut -f 1 -d' ')
32 SKYDNS_IMAGES := $(shell $(DOCKER) images -q crosbymichael/skyd*)
33
34 # `make realclean' will also remove the Arvados docker images (but not the
35 # arvados/debian image) and force subsequent makes to build the entire chain
36 # from the ground up
37 realclean: clean
38         @echo "make realclean"
39         +@[ "`$(DOCKER) ps -q`" = '' ] || $(DOCKER) stop `$(DOCKER) ps -q`
40         +@[ "$(REALCLEAN_CONTAINERS)" = '' ] || $(DOCKER) rm $(REALCLEAN_CONTAINERS)
41         +@[ "$(REALCLEAN_IMAGES)" = '' ] || $(DOCKER) rmi $(REALCLEAN_IMAGES)
42
43 # `make deepclean' will remove all Arvados docker images and the skydns/skydock
44 # images and force subsequent makes to build the entire chain from the ground up
45 deepclean: clean
46         @echo "make deepclean"
47         -@rm -f debian-arvados-image 2>/dev/null
48         -@rm -f skydns-image skydock-image 2>/dev/null
49         +@[ "`$(DOCKER) ps -q`" = '' ] || $(DOCKER) stop `$(DOCKER) ps -q`
50         +@[ "$(REALCLEAN_CONTAINERS)" = '' ] || $(DOCKER) rm $(REALCLEAN_CONTAINERS)
51         +@[ "$(DEEPCLEAN_IMAGES)" = '' ] || $(DOCKER) rmi $(DEEPCLEAN_IMAGES)
52         +@[ "$(SKYDNS_CONTAINERS)" = '' ] || $(DOCKER) rm $(SKYDNS_CONTAINERS)
53         +@[ "$(SKYDNS_IMAGES)" = '' ] || $(DOCKER) rmi $(SKYDNS_IMAGES)
54
55 # ============================================================
56 # Dependencies for */generated files which are prerequisites
57 # for building docker images.
58
59 CONFIG_RB = build_tools/config.rb
60
61 BUILD = build/.buildstamp
62
63 BASE_DEPS = base/Dockerfile config.yml $(BASE_GENERATED)
64
65 SLURM_DEPS = slurm/Dockerfile config.yml $(SLURM_GENERATED)
66
67 JOBS_DEPS = jobs/Dockerfile
68
69 ARV_WEB_DEPS = arv-web/Dockerfile arv-web/apache2_foreground.sh arv-web/apache2_vhost
70
71 JAVA_BWA_SAMTOOLS_DEPS = java-bwa-samtools/Dockerfile
72
73 API_DEPS = api/* config.yml $(API_GENERATED)
74
75 SHELL_DEPS = shell/* config.yml $(SHELL_GENERATED)
76
77 COMPUTE_DEPS = compute/* config.yml $(COMPUTE_GENERATED)
78
79 DOC_DEPS = doc/Dockerfile $(DOC_GENERATED)
80
81 WORKBENCH_DEPS = workbench/Dockerfile \
82                  config.yml \
83                  $(WORKBENCH_GENERATED)
84
85 KEEP_DEPS = keep/Dockerfile config.yml $(KEEP_GENERATED)
86
87 KEEP_PROXY_DEPS = keepproxy/Dockerfile config.yml $(KEEP_PROXY_GENERATED)
88
89 SSO_DEPS = config.yml $(SSO_GENERATED)
90
91 BCBIO_NEXTGEN_DEPS = bcbio-nextgen/Dockerfile
92
93 BASE_GENERATED = base/generated/arvados.tar.gz
94
95 COMPUTE_GENERATED_IN   = compute/*.in
96 COMPUTE_GENERATED      = compute/generated/*
97
98 KEEP_GENERATED_IN      = keep/*.in
99 KEEP_GENERATED         = keep/generated/*
100
101 KEEP_PROXY_GENERATED_IN      = keepproxy/*.in
102 KEEP_PROXY_GENERATED         = keepproxy/generated/*
103
104 API_GENERATED_IN       = api/*.in
105 API_GENERATED          = api/generated/*
106
107 SHELL_GENERATED_IN     = shell/*.in
108 SHELL_GENERATED        = shell/generated/*
109
110 SLURM_GENERATED_IN     = slurm/*.in
111 SLURM_GENERATED        = slurm/generated/*
112
113 WORKBENCH_GENERATED_IN = workbench/*.in
114 WORKBENCH_GENERATED    = workbench/generated/*
115
116 SSO_GENERATED_IN       = sso/*.in
117 SSO_GENERATED          = sso/generated/*
118
119 DOC_GENERATED_IN       = doc/*.in
120 DOC_GENERATED          = doc/generated/*
121
122 KEEP_DEPS += keep/generated/bin/keepproxy
123 KEEP_DEPS += keep/generated/bin/keepstore
124 keep/generated/bin/%: $(wildcard build/services/%/*.go)
125         mkdir -p keep/generated/src/git.curoverse.com
126         ln -sfn ../../../../.. keep/generated/src/git.curoverse.com/arvados.git
127         GOPATH=$(shell pwd)/keep/generated go get $(@:keep/generated/bin/%=git.curoverse.com/arvados.git/services/%)
128
129 KEEP_PROXY_DEPS += keepproxy/generated/bin/keepproxy
130 keepproxy/generated/bin/%: $(wildcard build/services/%/*.go)
131         mkdir -p keepproxy/generated/src/git.curoverse.com
132         ln -sfn ../../../../.. keepproxy/generated/src/git.curoverse.com/arvados.git
133         GOPATH=$(shell pwd)/keepproxy/generated go get $(@:keepproxy/generated/bin/%=git.curoverse.com/arvados.git/services/%)
134
135 $(BUILD):
136         mkdir -p build
137         rsync -rlp --exclude=docker/ --exclude='**/log/*' --exclude='**/tmp/*' \
138                 --chmod=Da+rx,Fa+rX ../ build/
139         find build/ -name \*.gem -delete
140         cd build/services/fuse/ && python setup.py build
141         cd build/sdk/python/ && python setup.py build
142         cd build/sdk/cli && gem build arvados-cli.gemspec
143         cd build/sdk/ruby && gem build arvados.gemspec
144         touch build/.buildstamp
145
146 $(SLURM_GENERATED): $(BUILD)
147         $(CONFIG_RB) slurm
148         mkdir -p slurm/generated
149
150 $(BASE_GENERATED): $(BUILD)
151         $(CONFIG_RB) base
152         mkdir -p base/generated
153         tar -czf base/generated/arvados.tar.gz -C build .
154
155 $(API_GENERATED): $(API_GENERATED_IN)
156         $(CONFIG_RB) api
157
158 $(SHELL_GENERATED): $(SHELL_GENERATED_IN)
159         $(CONFIG_RB) shell
160
161 $(WORKBENCH_GENERATED): $(WORKBENCH_GENERATED_IN)
162         $(CONFIG_RB) workbench
163
164 $(COMPUTE_GENERATED): $(COMPUTE_GENERATED_IN)
165         $(CONFIG_RB) compute
166
167 $(SSO_GENERATED): $(SSO_GENERATED_IN)
168         $(CONFIG_RB) sso
169
170 $(DOC_GENERATED): $(DOC_GENERATED_IN)
171         $(CONFIG_RB) doc
172
173 $(KEEP_GENERATED): $(KEEP_GENERATED_IN)
174         $(CONFIG_RB) keep
175
176 $(KEEP_PROXY_GENERATED): $(KEEP_PROXY_GENERATED_IN)
177         $(CONFIG_RB) keepproxy
178
179 DOCKER_BUILD = $(DOCKER) build --rm=true
180
181 # ============================================================
182 # The main Arvados servers: api, doc, workbench, compute
183
184 api-image: passenger-image $(BUILD) $(API_DEPS)
185         @echo "Building api-image"
186         mkdir -p api/generated
187         tar -czf api/generated/api.tar.gz -C build/services api
188         $(DOCKER_BUILD) -t arvados/api api
189         date >api-image
190
191 shell-image: base-image $(BUILD) $(SHELL_DEPS)
192         @echo "Building shell-image"
193         mkdir -p shell/generated
194         $(DOCKER_BUILD) -t arvados/shell shell
195         date >shell-image
196
197 compute-image: slurm-image $(BUILD) $(COMPUTE_DEPS)
198         @echo "Building compute-image"
199         $(DOCKER_BUILD) -t arvados/compute compute
200         date >compute-image
201
202 doc-image: base-image $(BUILD) $(DOC_DEPS)
203         @echo "Building doc-image"
204         mkdir -p doc/generated
205         tar -czf doc/generated/doc.tar.gz -C build doc
206         $(DOCKER_BUILD) -t arvados/doc doc
207         date >doc-image
208
209 keep-image: debian-arvados-image $(BUILD) $(KEEP_DEPS)
210         @echo "Building keep-image"
211         $(DOCKER_BUILD) -t arvados/keep keep
212         date >keep-image
213
214 keep-proxy-image: debian-arvados-image $(BUILD) $(KEEP_PROXY_DEPS)
215         @echo "Building keep-proxy-image"
216         $(DOCKER_BUILD) -t arvados/keepproxy keepproxy
217         date >keep-proxy-image
218
219 jobs-image: debian-arvados-image $(BUILD) $(JOBS_DEPS)
220         $(DOCKER_BUILD) -t arvados/jobs jobs
221         date >jobs-image
222
223 java-bwa-samtools-image: jobs-image $(BUILD) $(JAVA_BWA_SAMTOOLS_DEPS)
224         $(DOCKER_BUILD) -t arvados/jobs-java-bwa-samtools java-bwa-samtools
225         date >java-bwa-samtools-image
226
227 bcbio-nextgen-image: $(BUILD) $(BASE_GENERATED) $(BCBIO_NEXTGEN_DEPS)
228         rm -rf bcbio-nextgen/generated
229         cp -r base/generated bcbio-nextgen
230         $(DOCKER_BUILD) -t arvados/bcbio-nextgen bcbio-nextgen
231         date >bcbio-nextgen-image
232
233 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
234         @echo "Building workbench-image"
235         mkdir -p workbench/generated
236         tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
237         $(DOCKER_BUILD) -t arvados/workbench workbench
238         date >workbench-image
239
240 sso-image: passenger-image $(SSO_DEPS)
241         @echo "Building sso-image"
242         $(DOCKER_BUILD) -t arvados/sso sso
243         date >sso-image
244
245 arv-web-image: passenger-image $(ARV_WEB_DEPS)
246         $(DOCKER_BUILD) -t arvados/arv-web arv-web
247         date >arv-web-image
248
249 # ============================================================
250 # The arvados/base image is the base Debian image plus packages
251 # that are dependencies for every Arvados service.
252
253 passenger-image: base-image
254         @echo "Building passenger-image"
255         $(DOCKER_BUILD) -t arvados/passenger passenger
256         date >passenger-image
257
258 slurm-image: base-image $(SLURM_DEPS)
259         @echo "Building slurm-image"
260         $(DOCKER_BUILD) -t arvados/slurm slurm
261         date >slurm-image
262
263 base-image: debian-arvados-image $(BASE_DEPS)
264         @echo "Building base-image"
265         $(DOCKER_BUILD) -t arvados/base base
266         date >base-image
267
268 debian-arvados-image:
269         @echo "Building debian-arvados-image"
270         ./mkimage-debootstrap.sh arvados/debian wheezy http://ftp.us.debian.org/debian/
271         date >debian-arvados-image
272
273 skydns-image:
274         @echo "Downloading skydns-image"
275         $(DOCKER) pull crosbymichael/skydns
276         date >skydns-image
277
278 skydock-image:
279         @echo "Downloading skydock-image"
280         $(DOCKER) pull crosbymichael/skydock
281         date >skydock-image