1 # This is the 'shell hack'. Call make with DUMP=1 to see the effect.
4 SHELL = $(warning [$@])$(OLD_SHELL) -x
7 all: skydns-image skydock-image api-image compute-image doc-image workbench-image keep-image keep-proxy-image sso-image shell-image
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)
12 # `make clean' removes the files generated in the build directory
13 # but does not remove any docker images generated in previous builds
17 +@[ "$(IMAGE_FILES)" = "" ] || rm -f $(IMAGE_FILES) 2>/dev/null
18 +@[ "$(GENERATED_DIRS)" = "" ] || rm -rf */generated 2>/dev/null
20 DEBIAN_IMAGE := $(shell $(DOCKER) images -q arvados/debian |head -n1)
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 REALCLEAN_IMAGES := $(shell $(DOCKER) images -q arvados/* |grep -v $(DEBIAN_IMAGE) 2>/dev/null)
24 DEEPCLEAN_IMAGES := $(shell $(DOCKER) images -q arvados/*)
25 SKYDNS_CONTAINERS := $(shell $(DOCKER) ps -a |grep -e crosbymichael/skydns -e crosbymichael/skydock |cut -f 1 -d' ')
26 SKYDNS_IMAGES := $(shell $(DOCKER) images -q crosbymichael/skyd*)
28 # `make realclean' will also remove the Arvados docker images (but not the
29 # arvados/debian image) and force subsequent makes to build the entire chain
32 @echo "make realclean"
33 +@[ "`$(DOCKER) ps -q`" = '' ] || $(DOCKER) stop `$(DOCKER) ps -q`
34 +@[ "$(REALCLEAN_CONTAINERS)" = '' ] || $(DOCKER) rm $(REALCLEAN_CONTAINERS)
35 +@[ "$(REALCLEAN_IMAGES)" = '' ] || $(DOCKER) rmi $(REALCLEAN_IMAGES)
37 # `make deepclean' will remove all Arvados docker images and the skydns/skydock
38 # images and force subsequent makes to build the entire chain from the ground up
40 @echo "make deepclean"
41 -@rm -f debian-arvados-image 2>/dev/null
42 -@rm -f skydns-image skydock-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)
49 # ============================================================
50 # Dependencies for */generated files which are prerequisites
51 # for building docker images.
53 CONFIG_RB = build_tools/config.rb
55 BUILD = build/.buildstamp
57 BASE_DEPS = base/Dockerfile config.yml $(BASE_GENERATED)
59 SLURM_DEPS = slurm/Dockerfile config.yml $(SLURM_GENERATED)
61 JOBS_DEPS = jobs/Dockerfile
63 ARV_WEB_DEPS = arv-web/Dockerfile arv-web/apache2_foreground.sh arv-web/apache2_vhost
65 JAVA_BWA_SAMTOOLS_DEPS = java-bwa-samtools/Dockerfile
67 API_DEPS = api/* config.yml $(API_GENERATED)
69 SHELL_DEPS = shell/* config.yml $(SHELL_GENERATED)
71 COMPUTE_DEPS = compute/* config.yml $(COMPUTE_GENERATED)
73 DOC_DEPS = doc/Dockerfile doc/apache2_vhost
75 WORKBENCH_DEPS = workbench/Dockerfile \
77 $(WORKBENCH_GENERATED)
79 KEEP_DEPS = keep/Dockerfile config.yml $(KEEP_GENERATED)
81 KEEP_PROXY_DEPS = keepproxy/Dockerfile config.yml $(KEEP_PROXY_GENERATED)
83 SSO_DEPS = config.yml $(SSO_GENERATED)
85 BCBIO_NEXTGEN_DEPS = bcbio-nextgen/Dockerfile
87 BASE_GENERATED = base/generated/arvados.tar.gz
89 COMPUTE_GENERATED_IN = compute/*.in
90 COMPUTE_GENERATED = compute/generated/*
92 KEEP_GENERATED_IN = keep/*.in
93 KEEP_GENERATED = keep/generated/*
95 KEEP_PROXY_GENERATED_IN = keepproxy/*.in
96 KEEP_PROXY_GENERATED = keepproxy/generated/*
98 API_GENERATED_IN = api/*.in
99 API_GENERATED = api/generated/*
101 SHELL_GENERATED_IN = shell/*.in
102 SHELL_GENERATED = shell/generated/*
104 SLURM_GENERATED_IN = slurm/*.in
105 SLURM_GENERATED = slurm/generated/*
107 WORKBENCH_GENERATED_IN = workbench/*.in
108 WORKBENCH_GENERATED = workbench/generated/*
110 SSO_GENERATED_IN = sso/*.in
111 SSO_GENERATED = sso/generated/*
113 KEEP_DEPS += keep/generated/bin/keepproxy
114 KEEP_DEPS += keep/generated/bin/keepstore
115 keep/generated/bin/%: $(wildcard build/services/%/*.go)
116 mkdir -p keep/generated/src/git.curoverse.com
117 ln -sfn ../../../../.. keep/generated/src/git.curoverse.com/arvados.git
118 GOPATH=$(shell pwd)/keep/generated go get $(@:keep/generated/bin/%=git.curoverse.com/arvados.git/services/%)
120 KEEP_PROXY_DEPS += keepproxy/generated/bin/keepproxy
121 keepproxy/generated/bin/%: $(wildcard build/services/%/*.go)
122 mkdir -p keepproxy/generated/src/git.curoverse.com
123 ln -sfn ../../../../.. keepproxy/generated/src/git.curoverse.com/arvados.git
124 GOPATH=$(shell pwd)/keepproxy/generated go get $(@:keepproxy/generated/bin/%=git.curoverse.com/arvados.git/services/%)
128 rsync -rlp --exclude=docker/ --exclude='**/log/*' --exclude='**/tmp/*' \
129 --chmod=Da+rx,Fa+rX ../ build/
130 find build/ -name \*.gem -delete
131 cd build/services/fuse/ && python setup.py build
132 cd build/sdk/python/ && python setup.py build
133 cd build/sdk/cli && gem build arvados-cli.gemspec
134 cd build/sdk/ruby && gem build arvados.gemspec
135 touch build/.buildstamp
137 $(SLURM_GENERATED): $(BUILD)
139 mkdir -p slurm/generated
141 $(BASE_GENERATED): $(BUILD)
143 mkdir -p base/generated
144 tar -czf base/generated/arvados.tar.gz -C build .
146 $(API_GENERATED): $(API_GENERATED_IN)
149 $(SHELL_GENERATED): $(SHELL_GENERATED_IN)
152 $(WORKBENCH_GENERATED): $(WORKBENCH_GENERATED_IN)
153 $(CONFIG_RB) workbench
155 $(COMPUTE_GENERATED): $(COMPUTE_GENERATED_IN)
158 $(SSO_GENERATED): $(SSO_GENERATED_IN)
161 $(KEEP_GENERATED): $(KEEP_GENERATED_IN)
164 $(KEEP_PROXY_GENERATED): $(KEEP_PROXY_GENERATED_IN)
165 $(CONFIG_RB) keepproxy
167 DOCKER_BUILD = $(DOCKER) build --rm=true
169 # ============================================================
170 # The main Arvados servers: api, doc, workbench, compute
172 api-image: passenger-image $(BUILD) $(API_DEPS)
173 @echo "Building api-image"
174 mkdir -p api/generated
175 tar -czf api/generated/api.tar.gz -C build/services api
176 $(DOCKER_BUILD) -t arvados/api api
179 shell-image: base-image $(BUILD) $(SHELL_DEPS)
180 @echo "Building shell-image"
181 mkdir -p shell/generated
182 $(DOCKER_BUILD) -t arvados/shell shell
185 compute-image: slurm-image $(BUILD) $(COMPUTE_DEPS)
186 @echo "Building compute-image"
187 $(DOCKER_BUILD) -t arvados/compute compute
190 doc-image: base-image $(BUILD) $(DOC_DEPS)
191 @echo "Building doc-image"
192 mkdir -p doc/generated
193 tar -czf doc/generated/doc.tar.gz -C build doc
194 $(DOCKER_BUILD) -t arvados/doc doc
197 keep-image: debian-arvados-image $(BUILD) $(KEEP_DEPS)
198 @echo "Building keep-image"
199 $(DOCKER_BUILD) -t arvados/keep keep
202 keep-proxy-image: debian-arvados-image $(BUILD) $(KEEP_PROXY_DEPS)
203 @echo "Building keep-proxy-image"
204 $(DOCKER_BUILD) -t arvados/keepproxy keepproxy
205 date >keep-proxy-image
207 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
208 $(DOCKER_BUILD) -t arvados/jobs jobs
211 java-bwa-samtools-image: jobs-image $(BUILD) $(JAVA_BWA_SAMTOOLS_DEPS)
212 $(DOCKER_BUILD) -t arvados/jobs-java-bwa-samtools java-bwa-samtools
213 date >java-bwa-samtools-image
215 bcbio-nextgen-image: $(BUILD) $(BASE_GENERATED) $(BCBIO_NEXTGEN_DEPS)
216 rm -rf bcbio-nextgen/generated
217 cp -r base/generated bcbio-nextgen
218 $(DOCKER_BUILD) -t arvados/bcbio-nextgen bcbio-nextgen
219 date >bcbio-nextgen-image
221 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
222 @echo "Building workbench-image"
223 mkdir -p workbench/generated
224 tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
225 $(DOCKER_BUILD) -t arvados/workbench workbench
226 date >workbench-image
228 sso-image: passenger-image $(SSO_DEPS)
229 @echo "Building sso-image"
230 $(DOCKER_BUILD) -t arvados/sso sso
233 arv-web-image: passenger-image $(ARV_WEB_DEPS)
234 $(DOCKER_BUILD) -t arvados/arv-web arv-web
237 # ============================================================
238 # The arvados/base image is the base Debian image plus packages
239 # that are dependencies for every Arvados service.
241 passenger-image: base-image
242 @echo "Building passenger-image"
243 $(DOCKER_BUILD) -t arvados/passenger passenger
244 date >passenger-image
246 slurm-image: base-image $(SLURM_DEPS)
247 @echo "Building slurm-image"
248 $(DOCKER_BUILD) -t arvados/slurm slurm
251 base-image: debian-arvados-image $(BASE_DEPS)
252 @echo "Building base-image"
253 $(DOCKER_BUILD) -t arvados/base base
256 debian-arvados-image:
257 @echo "Building debian-arvados-image"
258 ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
259 date >debian-arvados-image
262 @echo "Downloading skydns-image"
263 $(DOCKER) pull crosbymichael/skydns
267 @echo "Downloading skydock-image"
268 $(DOCKER) pull crosbymichael/skydock