1 # This is the 'shell hack'. Call make with DUMP=1 to see the effect.
4 SHELL = $(warning [$@])$(OLD_SHELL) -x
8 all: skydns-image skydock-image api-image compute-image doc-image workbench-image keep-image keep-proxy-image sso-image
10 IMAGE_FILES := $(shell ls *-image 2>/dev/null |grep -v -E 'debian-arvados-image|skydns-image|skydock-image')
11 GENERATED_DIRS := $(shell ls */generated 2>/dev/null)
13 # `make clean' removes the files generated in the build directory
14 # but does not remove any docker images generated in previous builds
18 +@[ "$(IMAGE_FILES)" = "" ] || rm -f $(IMAGE_FILES) 2>/dev/null
19 +@[ "$(GENERATED_DIRS)" = "" ] || rm -rf */generated 2>/dev/null
21 DEBIAN_IMAGE := $(shell $(DOCKER) images -q arvados/debian |head -n1)
23 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' ')
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*)
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
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)
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
41 @echo "make deepclean"
42 -@rm -f debian-arvados-image 2>/dev/null
43 -@rm -f skydns-image skydock-image 2>/dev/null
44 +@[ "`$(DOCKER) ps -q`" = '' ] || $(DOCKER) stop `$(DOCKER) ps -q`
45 +@[ "$(REALCLEAN_CONTAINERS)" = '' ] || $(DOCKER) rm $(REALCLEAN_CONTAINERS)
46 +@[ "$(DEEPCLEAN_IMAGES)" = '' ] || $(DOCKER) rmi $(DEEPCLEAN_IMAGES)
47 +@[ "$(SKYDNS_CONTAINERS)" = '' ] || $(DOCKER) rm $(SKYDNS_CONTAINERS)
48 +@[ "$(SKYDNS_IMAGES)" = '' ] || $(DOCKER) rmi $(SKYDNS_IMAGES)
50 # ============================================================
51 # Dependencies for */generated files which are prerequisites
52 # for building docker images.
54 CONFIG_RB = build_tools/config.rb
56 BUILD = build/.buildstamp
58 BASE_DEPS = base/Dockerfile config.yml $(BASE_GENERATED)
60 SLURM_DEPS = slurm/Dockerfile config.yml $(SLURM_GENERATED)
62 JOBS_DEPS = jobs/Dockerfile
64 ARV_WEB_DEPS = arv-web/Dockerfile arv-web/apache2_foreground.sh arv-web/apache2_vhost
66 JAVA_BWA_SAMTOOLS_DEPS = java-bwa-samtools/Dockerfile
68 API_DEPS = api/* config.yml $(API_GENERATED)
70 SHELL_DEPS = shell/* config.yml $(SHELL_GENERATED)
72 COMPUTE_DEPS = compute/* config.yml $(COMPUTE_GENERATED)
74 DOC_DEPS = doc/Dockerfile $(DOC_GENERATED)
76 WORKBENCH_DEPS = workbench/Dockerfile \
78 $(WORKBENCH_GENERATED)
80 KEEP_DEPS = keep/Dockerfile config.yml $(KEEP_GENERATED)
82 KEEP_PROXY_DEPS = keepproxy/Dockerfile config.yml $(KEEP_PROXY_GENERATED)
84 SSO_DEPS = config.yml $(SSO_GENERATED)
86 BCBIO_NEXTGEN_DEPS = bcbio-nextgen/Dockerfile
88 BASE_GENERATED = base/generated/arvados.tar.gz
90 COMPUTE_GENERATED_IN = compute/*.in
91 COMPUTE_GENERATED = compute/generated/*
93 KEEP_GENERATED_IN = keep/*.in
94 KEEP_GENERATED = keep/generated/*
96 KEEP_PROXY_GENERATED_IN = keepproxy/*.in
97 KEEP_PROXY_GENERATED = keepproxy/generated/*
99 API_GENERATED_IN = api/*.in
100 API_GENERATED = api/generated/*
102 SHELL_GENERATED_IN = shell/*.in
103 SHELL_GENERATED = shell/generated/*
105 SLURM_GENERATED_IN = slurm/*.in
106 SLURM_GENERATED = slurm/generated/*
108 WORKBENCH_GENERATED_IN = workbench/*.in
109 WORKBENCH_GENERATED = workbench/generated/*
111 SSO_GENERATED_IN = sso/*.in
112 SSO_GENERATED = sso/generated/*
114 DOC_GENERATED_IN = doc/*.in
115 DOC_GENERATED = doc/generated/*
117 KEEP_DEPS += keep/generated/bin/keepproxy
118 KEEP_DEPS += keep/generated/bin/keepstore
119 keep/generated/bin/%: $(wildcard build/services/%/*.go)
120 mkdir -p keep/generated/src/git.curoverse.com
121 ln -sfn ../../../../.. keep/generated/src/git.curoverse.com/arvados.git
122 GOPATH=$(shell pwd)/keep/generated go get $(@:keep/generated/bin/%=git.curoverse.com/arvados.git/services/%)
124 KEEP_PROXY_DEPS += keepproxy/generated/bin/keepproxy
125 keepproxy/generated/bin/%: $(wildcard build/services/%/*.go)
126 mkdir -p keepproxy/generated/src/git.curoverse.com
127 ln -sfn ../../../../.. keepproxy/generated/src/git.curoverse.com/arvados.git
128 GOPATH=$(shell pwd)/keepproxy/generated go get $(@:keepproxy/generated/bin/%=git.curoverse.com/arvados.git/services/%)
132 rsync -rlp --exclude=docker/ --exclude='**/log/*' --exclude='**/tmp/*' \
133 --chmod=Da+rx,Fa+rX ../ build/
134 find build/ -name \*.gem -delete
135 cd build/services/fuse/ && python setup.py build
136 cd build/sdk/python/ && python setup.py build
137 cd build/sdk/cli && gem build arvados-cli.gemspec
138 cd build/sdk/ruby && gem build arvados.gemspec
139 touch build/.buildstamp
141 $(SLURM_GENERATED): $(BUILD)
143 mkdir -p slurm/generated
145 $(BASE_GENERATED): $(BUILD)
147 mkdir -p base/generated
148 tar -czf base/generated/arvados.tar.gz -C build .
150 $(API_GENERATED): $(API_GENERATED_IN)
153 $(SHELL_GENERATED): $(SHELL_GENERATED_IN)
156 $(WORKBENCH_GENERATED): $(WORKBENCH_GENERATED_IN)
157 $(CONFIG_RB) workbench
159 $(COMPUTE_GENERATED): $(COMPUTE_GENERATED_IN)
162 $(SSO_GENERATED): $(SSO_GENERATED_IN)
165 $(DOC_GENERATED): $(DOC_GENERATED_IN)
168 $(KEEP_GENERATED): $(KEEP_GENERATED_IN)
171 $(KEEP_PROXY_GENERATED): $(KEEP_PROXY_GENERATED_IN)
172 $(CONFIG_RB) keepproxy
174 DOCKER_BUILD = $(DOCKER) build --rm=true
176 # ============================================================
177 # The main Arvados servers: api, doc, workbench, compute
179 api-image: passenger-image $(BUILD) $(API_DEPS)
180 @echo "Building api-image"
181 mkdir -p api/generated
182 tar -czf api/generated/api.tar.gz -C build/services api
183 $(DOCKER_BUILD) -t arvados/api api
186 shell-image: base-image $(BUILD) $(SHELL_DEPS)
187 @echo "Building shell-image"
188 mkdir -p shell/generated
189 $(DOCKER_BUILD) -t arvados/shell shell
192 compute-image: slurm-image $(BUILD) $(COMPUTE_DEPS)
193 @echo "Building compute-image"
194 $(DOCKER_BUILD) -t arvados/compute compute
197 doc-image: base-image $(BUILD) $(DOC_DEPS)
198 @echo "Building doc-image"
199 mkdir -p doc/generated
200 tar -czf doc/generated/doc.tar.gz -C build doc
201 $(DOCKER_BUILD) -t arvados/doc doc
204 keep-image: debian-arvados-image $(BUILD) $(KEEP_DEPS)
205 @echo "Building keep-image"
206 $(DOCKER_BUILD) -t arvados/keep keep
209 keep-proxy-image: debian-arvados-image $(BUILD) $(KEEP_PROXY_DEPS)
210 @echo "Building keep-proxy-image"
211 $(DOCKER_BUILD) -t arvados/keepproxy keepproxy
212 date >keep-proxy-image
214 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
215 $(DOCKER_BUILD) -t arvados/jobs jobs
218 java-bwa-samtools-image: jobs-image $(BUILD) $(JAVA_BWA_SAMTOOLS_DEPS)
219 $(DOCKER_BUILD) -t arvados/jobs-java-bwa-samtools java-bwa-samtools
220 date >java-bwa-samtools-image
222 bcbio-nextgen-image: $(BUILD) $(BASE_GENERATED) $(BCBIO_NEXTGEN_DEPS)
223 rm -rf bcbio-nextgen/generated
224 cp -r base/generated bcbio-nextgen
225 $(DOCKER_BUILD) -t arvados/bcbio-nextgen bcbio-nextgen
226 date >bcbio-nextgen-image
228 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
229 @echo "Building workbench-image"
230 mkdir -p workbench/generated
231 tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
232 $(DOCKER_BUILD) -t arvados/workbench workbench
233 date >workbench-image
235 sso-image: passenger-image $(SSO_DEPS)
236 @echo "Building sso-image"
237 $(DOCKER_BUILD) -t arvados/sso sso
240 arv-web-image: passenger-image $(ARV_WEB_DEPS)
241 $(DOCKER_BUILD) -t arvados/arv-web arv-web
244 # ============================================================
245 # The arvados/base image is the base Debian image plus packages
246 # that are dependencies for every Arvados service.
248 passenger-image: base-image
249 @echo "Building passenger-image"
250 $(DOCKER_BUILD) -t arvados/passenger passenger
251 date >passenger-image
253 slurm-image: base-image $(SLURM_DEPS)
254 @echo "Building slurm-image"
255 $(DOCKER_BUILD) -t arvados/slurm slurm
258 base-image: debian-arvados-image $(BASE_DEPS)
259 @echo "Building base-image"
260 $(DOCKER_BUILD) -t arvados/base base
263 debian-arvados-image:
264 @echo "Building debian-arvados-image"
265 ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
266 date >debian-arvados-image
269 @echo "Downloading skydns-image"
270 $(DOCKER) pull crosbymichael/skydns
274 @echo "Downloading skydock-image"
275 $(DOCKER) pull crosbymichael/skydock