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