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
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
91 api/generated/arvados-clients.yml \
92 api/generated/apache2_vhost \
93 api/generated/config_databases.sh \
94 api/generated/database.yml \
95 api/generated/omniauth.rb \
96 api/generated/application.yml \
97 api/generated/setup.sh \
98 api/generated/setup-gitolite.sh \
99 api/generated/slurm.conf \
100 api/generated/superuser_token
103 api/arvados-clients.yml.in \
104 api/apache2_vhost.in \
105 api/config_databases.sh.in \
106 api/database.yml.in \
108 api/application.yml.in \
110 api/setup-gitolite.sh.in \
112 api/superuser_token.in
115 shell/generated/setup.sh \
116 shell/generated/superuser_token
118 SHELL_GENERATED_IN = \
120 shell/superuser_token.in
123 slurm/generated/slurm.conf
125 SLURM_GENERATED_IN = \
128 WORKBENCH_GENERATED = \
129 workbench/generated/apache2_vhost \
130 workbench/generated/application.yml
132 WORKBENCH_GENERATED_IN = \
133 workbench/apache2_vhost.in \
134 workbench/application.yml.in
137 sso/generated/apache2_vhost \
138 sso/generated/seeds.rb \
139 sso/generated/secret_token.rb
142 sso/apache2_vhost.in \
144 sso/secret_token.rb.in
148 rsync -rlp --exclude=docker/ --exclude='**/log/*' --exclude='**/tmp/*' \
149 --chmod=Da+rx,Fa+rX ../ build/
150 find build/ -name \*.gem -delete
151 cd build/services/fuse/ && python setup.py build
152 cd build/sdk/python/ && python setup.py build
153 cd build/sdk/cli && gem build arvados-cli.gemspec
154 cd build/sdk/ruby && gem build arvados.gemspec
155 touch build/.buildstamp
157 $(SLURM_GENERATED): config.yml $(BUILD)
159 mkdir -p slurm/generated
161 $(BASE_GENERATED): config.yml $(BUILD)
163 mkdir -p base/generated
164 tar -czf base/generated/arvados.tar.gz -C build .
166 $(API_GENERATED): config.yml $(API_GENERATED_IN)
169 $(SHELL_GENERATED): config.yml $(SHELL_GENERATED_IN)
172 $(WORKBENCH_GENERATED): config.yml $(WORKBENCH_GENERATED_IN)
175 $(COMPUTE_GENERATED): config.yml $(COMPUTE_GENERATED_IN)
177 $(WAREHOUSE_GENERATED): config.yml $(WAREHOUSE_GENERATED_IN)
180 $(SSO_GENERATED): config.yml $(SSO_GENERATED_IN)
183 # The docker build -q option suppresses verbose build output.
184 # Necessary to prevent failure on building warehouse; see
185 # https://github.com/dotcloud/docker/issues/3172
186 DOCKER_BUILD = $(DOCKER) build -q --rm=true
188 # ============================================================
189 # The main Arvados servers: api, doc, workbench, warehouse
191 api-image: passenger-image $(BUILD) $(API_DEPS)
192 @echo "Building api-image"
193 mkdir -p api/generated
194 tar -czf api/generated/api.tar.gz -C build/services api
195 chmod 755 api/generated/setup.sh
196 chmod 755 api/generated/setup-gitolite.sh
197 $(DOCKER_BUILD) -t arvados/api api
200 shell-image: base-image $(BUILD) $(SHELL_DEPS)
201 @echo "Building shell-image"
202 mkdir -p shell/generated
203 chmod 755 shell/generated/setup.sh
204 $(DOCKER_BUILD) -t arvados/shell shell
207 compute-image: slurm-image $(BUILD) $(COMPUTE_DEPS)
208 @echo "Building compute-image"
209 chmod 755 compute/generated/setup.sh
210 $(DOCKER_BUILD) -t arvados/compute compute
213 doc-image: base-image $(BUILD) $(DOC_DEPS)
214 @echo "Building doc-image"
215 mkdir -p doc/generated
216 tar -czf doc/generated/doc.tar.gz -C build doc
217 $(DOCKER_BUILD) -t arvados/doc doc
220 keep-image: debian-arvados-image $(BUILD) $(KEEP_DEPS)
221 @echo "Building keep-image"
222 $(DOCKER_BUILD) -t arvados/keep keep
225 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
226 $(DOCKER_BUILD) -t arvados/jobs jobs
229 java-bwa-samtools-image: jobs-image $(BUILD) $(JAVA_BWA_SAMTOOLS_DEPS)
230 $(DOCKER_BUILD) -t arvados/jobs-java-bwa-samtools java-bwa-samtools
231 date >java-bwa-samtools-image
233 bcbio-nextgen-image: $(BUILD) $(BASE_GENERATED) $(BCBIO_NEXTGEN_DEPS)
234 rm -rf bcbio-nextgen/generated
235 cp -r base/generated bcbio-nextgen
236 $(DOCKER_BUILD) -t arvados/bcbio-nextgen bcbio-nextgen
237 date >bcbio-nextgen-image
239 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
240 @echo "Building workbench-image"
241 mkdir -p workbench/generated
242 tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
243 $(DOCKER_BUILD) -t arvados/workbench workbench
244 date >workbench-image
246 warehouse-image: base-image $(WAREHOUSE_DEPS)
247 $(DOCKER_BUILD) -t arvados/warehouse warehouse
248 date >warehouse-image
250 sso-image: passenger-image $(SSO_DEPS)
251 @echo "Building sso-image"
252 $(DOCKER_BUILD) -t arvados/sso sso
255 # ============================================================
256 # The arvados/base image is the base Debian image plus packages
257 # that are dependencies for every Arvados service.
259 passenger-image: base-image
260 @echo "Building passenger-image"
261 $(DOCKER_BUILD) -t arvados/passenger passenger
262 date >passenger-image
264 slurm-image: base-image $(SLURM_DEPS)
265 @echo "Building slurm-image"
266 $(DOCKER_BUILD) -t arvados/slurm slurm
269 base-image: debian-arvados-image $(BASE_DEPS)
270 @echo "Building base-image"
271 $(DOCKER_BUILD) -t arvados/base base
274 debian-arvados-image:
275 @echo "Building debian-arvados-image"
276 ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
277 date >debian-arvados-image
280 @echo "Downloading skydns-image"
281 $(DOCKER) pull crosbymichael/skydns
285 @echo "Downloading skydock-image"
286 $(DOCKER) pull crosbymichael/skydock