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 -E 'debian-arvados-image|skydns-image|skydock-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 -@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 JAVA_BWA_SAMTOOLS_DEPS = java-bwa-samtools/Dockerfile
66 API_DEPS = api/* config.yml $(API_GENERATED)
68 SHELL_DEPS = shell/* config.yml $(SHELL_GENERATED)
70 COMPUTE_DEPS = compute/* config.yml $(COMPUTE_GENERATED)
72 DOC_DEPS = doc/Dockerfile doc/apache2_vhost
74 WORKBENCH_DEPS = workbench/Dockerfile \
76 $(WORKBENCH_GENERATED)
78 KEEP_DEPS = keep/Dockerfile config.yml $(KEEP_GENERATED)
80 SSO_DEPS = config.yml $(SSO_GENERATED)
82 BCBIO_NEXTGEN_DEPS = bcbio-nextgen/Dockerfile
84 BASE_GENERATED = base/generated/arvados.tar.gz
86 COMPUTE_GENERATED_IN = compute/*.in
87 COMPUTE_GENERATED = compute/generated/*
89 KEEP_GENERATED_IN = keep/*.in
90 KEEP_GENERATED = keep/generated/*
92 API_GENERATED_IN = api/*.in
93 API_GENERATED = api/generated/*
95 SHELL_GENERATED_IN = shell/*.in
96 SHELL_GENERATED = shell/generated/*
98 SLURM_GENERATED_IN = slurm/*.in
99 SLURM_GENERATED = slurm/generated/*
101 WORKBENCH_GENERATED_IN = workbench/*.in
102 WORKBENCH_GENERATED = workbench/generated/*
104 SSO_GENERATED_IN = sso/*.in
105 SSO_GENERATED = sso/generated/*
109 rsync -rlp --exclude=docker/ --exclude='**/log/*' --exclude='**/tmp/*' \
110 --chmod=Da+rx,Fa+rX ../ build/
111 find build/ -name \*.gem -delete
112 cd build/services/fuse/ && python setup.py build
113 cd build/sdk/python/ && python setup.py build
114 cd build/sdk/cli && gem build arvados-cli.gemspec
115 cd build/sdk/ruby && gem build arvados.gemspec
116 touch build/.buildstamp
118 $(SLURM_GENERATED): $(BUILD)
120 mkdir -p slurm/generated
122 $(BASE_GENERATED): $(BUILD)
124 mkdir -p base/generated
125 tar -czf base/generated/arvados.tar.gz -C build .
127 $(API_GENERATED): $(API_GENERATED_IN)
130 $(SHELL_GENERATED): $(SHELL_GENERATED_IN)
133 $(WORKBENCH_GENERATED): $(WORKBENCH_GENERATED_IN)
134 $(CONFIG_RB) workbench
136 $(COMPUTE_GENERATED): $(COMPUTE_GENERATED_IN)
139 $(SSO_GENERATED): $(SSO_GENERATED_IN)
142 $(KEEP_GENERATED): $(KEEP_GENERATED_IN)
145 # The docker build -q option suppresses verbose build output.
146 # Necessary to prevent failure on building warehouse; see
147 # https://github.com/dotcloud/docker/issues/3172
148 DOCKER_BUILD = $(DOCKER) build -q --rm=true
150 # ============================================================
151 # The main Arvados servers: api, doc, workbench, compute
153 api-image: passenger-image $(BUILD) $(API_DEPS)
154 @echo "Building api-image"
155 mkdir -p api/generated
156 tar -czf api/generated/api.tar.gz -C build/services api
157 chmod 755 api/generated/setup.sh
158 chmod 755 api/generated/setup-gitolite.sh
159 $(DOCKER_BUILD) -t arvados/api api
162 shell-image: base-image $(BUILD) $(SHELL_DEPS)
163 @echo "Building shell-image"
164 mkdir -p shell/generated
165 chmod 755 shell/generated/setup.sh
166 $(DOCKER_BUILD) -t arvados/shell shell
169 compute-image: slurm-image $(BUILD) $(COMPUTE_DEPS)
170 @echo "Building compute-image"
171 chmod 755 compute/generated/setup.sh
172 $(DOCKER_BUILD) -t arvados/compute compute
175 doc-image: base-image $(BUILD) $(DOC_DEPS)
176 @echo "Building doc-image"
177 mkdir -p doc/generated
178 tar -czf doc/generated/doc.tar.gz -C build doc
179 $(DOCKER_BUILD) -t arvados/doc doc
182 keep-image: debian-arvados-image $(BUILD) $(KEEP_DEPS)
183 @echo "Building keep-image"
184 $(DOCKER_BUILD) -t arvados/keep keep
187 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
188 $(DOCKER_BUILD) -t arvados/jobs jobs
191 java-bwa-samtools-image: jobs-image $(BUILD) $(JAVA_BWA_SAMTOOLS_DEPS)
192 $(DOCKER_BUILD) -t arvados/jobs-java-bwa-samtools java-bwa-samtools
193 date >java-bwa-samtools-image
195 bcbio-nextgen-image: $(BUILD) $(BASE_GENERATED) $(BCBIO_NEXTGEN_DEPS)
196 rm -rf bcbio-nextgen/generated
197 cp -r base/generated bcbio-nextgen
198 $(DOCKER_BUILD) -t arvados/bcbio-nextgen bcbio-nextgen
199 date >bcbio-nextgen-image
201 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
202 @echo "Building workbench-image"
203 mkdir -p workbench/generated
204 tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
205 $(DOCKER_BUILD) -t arvados/workbench workbench
206 date >workbench-image
208 sso-image: passenger-image $(SSO_DEPS)
209 @echo "Building sso-image"
210 $(DOCKER_BUILD) -t arvados/sso sso
213 # ============================================================
214 # The arvados/base image is the base Debian image plus packages
215 # that are dependencies for every Arvados service.
217 passenger-image: base-image
218 @echo "Building passenger-image"
219 $(DOCKER_BUILD) -t arvados/passenger passenger
220 date >passenger-image
222 slurm-image: base-image $(SLURM_DEPS)
223 @echo "Building slurm-image"
224 $(DOCKER_BUILD) -t arvados/slurm slurm
227 base-image: debian-arvados-image $(BASE_DEPS)
228 @echo "Building base-image"
229 $(DOCKER_BUILD) -t arvados/base base
232 debian-arvados-image:
233 @echo "Building debian-arvados-image"
234 ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
235 date >debian-arvados-image
238 @echo "Downloading skydns-image"
239 $(DOCKER) pull crosbymichael/skydns
243 @echo "Downloading skydock-image"
244 $(DOCKER) pull crosbymichael/skydock