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 sso-image shell-image
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)
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)$(GENERATED_FILES)" = "" ] || rm $(IMAGE_FILES) $(GENERATED_FILES) 2>/dev/null
19 +@[ "$(GENERATED_DIRS)" = "" ] || rmdir */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 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 +@[ "`$(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 $(BASE_GENERATED)
59 SLURM_DEPS = slurm/Dockerfile $(SLURM_GENERATED)
61 JOBS_DEPS = jobs/Dockerfile
63 JAVA_BWA_SAMTOOLS_DEPS = java-bwa-samtools/Dockerfile
65 API_DEPS = api/* $(API_GENERATED)
67 SHELL_DEPS = shell/* $(SHELL_GENERATED)
69 COMPUTE_DEPS = compute/* $(COMPUTE_GENERATED)
71 DOC_DEPS = doc/Dockerfile doc/apache2_vhost
73 WORKBENCH_DEPS = workbench/Dockerfile \
74 $(WORKBENCH_GENERATED)
76 KEEP_DEPS = keep/Dockerfile $(KEEP_GENERATED)
78 SSO_DEPS = $(SSO_GENERATED)
80 BCBIO_NEXTGEN_DEPS = bcbio-nextgen/Dockerfile
82 BASE_GENERATED = base/generated/arvados.tar.gz
84 SLURM_GENERATED = slurm/generated/*
86 COMPUTE_GENERATED = compute/generated/setup.sh
88 COMPUTE_GENERATED_IN = compute/setup.sh.in
90 KEEP_GENERATED_IN := $(shell ls keep/*.in)
92 KEEP_GENERATED := $(shell ls -1 $(KEEP_GENERATED_IN) | perl -pe 's:^keep:keep/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
107 api/arvados-clients.yml.in \
108 api/apache2_vhost.in \
109 api/config_databases.sh.in \
110 api/database.yml.in \
112 api/application.yml.in \
114 api/setup-gitolite.sh.in \
116 api/superuser_token.in
119 shell/generated/setup.sh \
120 shell/generated/superuser_token
122 SHELL_GENERATED_IN = \
124 shell/superuser_token.in
127 slurm/generated/slurm.conf
129 SLURM_GENERATED_IN = \
132 WORKBENCH_GENERATED = \
133 workbench/generated/apache2_vhost \
134 workbench/generated/application.yml
136 WORKBENCH_GENERATED_IN = \
137 workbench/apache2_vhost.in \
138 workbench/application.yml.in
141 sso/generated/apache2_vhost \
142 sso/generated/seeds.rb \
143 sso/generated/secret_token.rb
146 sso/apache2_vhost.in \
148 sso/secret_token.rb.in
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
161 $(SLURM_GENERATED): config.yml $(BUILD)
163 mkdir -p slurm/generated
165 $(BASE_GENERATED): config.yml $(BUILD)
167 mkdir -p base/generated
168 tar -czf base/generated/arvados.tar.gz -C build .
170 $(API_GENERATED): config.yml $(API_GENERATED_IN)
173 $(SHELL_GENERATED): config.yml $(SHELL_GENERATED_IN)
176 $(WORKBENCH_GENERATED): config.yml $(WORKBENCH_GENERATED_IN)
179 $(COMPUTE_GENERATED): config.yml $(COMPUTE_GENERATED_IN)
182 $(WAREHOUSE_GENERATED): config.yml $(WAREHOUSE_GENERATED_IN)
185 $(SSO_GENERATED): config.yml $(SSO_GENERATED_IN)
188 $(KEEP_GENERATED): config.yml $(KEEP_GENERATED_IN)
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
196 # ============================================================
197 # The main Arvados servers: api, doc, workbench, warehouse
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
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
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
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
228 keep-image: debian-arvados-image $(BUILD) $(KEEP_DEPS)
229 @echo "Building keep-image"
230 $(DOCKER_BUILD) -t arvados/keep keep
233 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
234 $(DOCKER_BUILD) -t arvados/jobs jobs
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
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
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
254 warehouse-image: base-image $(WAREHOUSE_DEPS)
255 $(DOCKER_BUILD) -t arvados/warehouse warehouse
256 date >warehouse-image
258 sso-image: passenger-image $(SSO_DEPS)
259 @echo "Building sso-image"
260 $(DOCKER_BUILD) -t arvados/sso sso
263 # ============================================================
264 # The arvados/base image is the base Debian image plus packages
265 # that are dependencies for every Arvados service.
267 passenger-image: base-image
268 @echo "Building passenger-image"
269 $(DOCKER_BUILD) -t arvados/passenger passenger
270 date >passenger-image
272 slurm-image: base-image $(SLURM_DEPS)
273 @echo "Building slurm-image"
274 $(DOCKER_BUILD) -t arvados/slurm slurm
277 base-image: debian-arvados-image $(BASE_DEPS)
278 @echo "Building base-image"
279 $(DOCKER_BUILD) -t arvados/base base
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
288 @echo "Downloading skydns-image"
289 $(DOCKER) pull crosbymichael/skydns
293 @echo "Downloading skydock-image"
294 $(DOCKER) pull crosbymichael/skydock