Merge branch 'master' into 3219-further-docker-improvements
[arvados.git] / docker / build_tools / Makefile
1 all: api-image compute-image doc-image workbench-image keep-image sso-image shell-image
2
3 # `make clean' removes the files generated in the build directory
4 # but does not remove any docker images generated in previous builds
5 clean:
6         -rm -rf build
7         -rm `ls *-image |grep -v debian-arvados-image` */generated/*
8         -@rmdir */generated
9
10 DEBIAN_IMAGE := $(shell $(DOCKER) images -q arvados/debian |head -n1)
11
12 # `make realclean' will also remove the Arvados docker images (but not the
13 # arvados/debian image) and force subsequent makes to build the entire chain
14 # from the ground up
15 realclean: clean
16         -[ -n "`$(DOCKER) ps -q`" ] && $(DOCKER) stop `$(DOCKER) ps -q`
17         -$(DOCKER) rm `$(DOCKER) ps -a |grep -e arvados -e api_server -e keep_server -e doc_server -e workbench_server |cut -f 1 -d' '`
18         -$(DOCKER) rmi `$(DOCKER) images -q arvados/* |grep -v $(DEBIAN_IMAGE)`
19
20 # `make deepclean' will remove all Arvados docker images and force
21 # subsequent makes to build the entire chain from the ground up
22 deepclean: clean
23         -rm debian-arvados-image
24         -[ -n "`$(DOCKER) ps -q`" ] && $(DOCKER) stop `$(DOCKER) ps -q`
25         -$(DOCKER) rm `$(DOCKER) ps -a |grep -e arvados -e api_server -e keep_server -e doc_server -e workbench_server |cut -f 1 -d' '`
26         -$(DOCKER) rmi `$(DOCKER) images -q arvados/*`
27
28 # ============================================================
29 # Dependencies for */generated files which are prerequisites
30 # for building docker images.
31
32 CONFIG_RB = build_tools/config.rb
33
34 BUILD = build/.buildstamp
35
36 BASE_DEPS = base/Dockerfile $(BASE_GENERATED)
37
38 SLURM_DEPS = slurm/Dockerfile $(SLURM_GENERATED)
39
40 JOBS_DEPS = jobs/Dockerfile
41
42 JAVA_BWA_SAMTOOLS_DEPS = java-bwa-samtools/Dockerfile
43
44 API_DEPS = api/* $(API_GENERATED)
45
46 SHELL_DEPS = shell/* $(SHELL_GENERATED)
47
48 COMPUTE_DEPS = compute/* $(COMPUTE_GENERATED)
49
50 DOC_DEPS = doc/Dockerfile doc/apache2_vhost
51
52 WORKBENCH_DEPS = workbench/Dockerfile \
53                  $(WORKBENCH_GENERATED)
54
55 KEEP_DEPS = keep/Dockerfile
56
57 SSO_DEPS = $(SSO_GENERATED)
58
59 BCBIO_NEXTGEN_DEPS = bcbio-nextgen/Dockerfile
60
61 BASE_GENERATED = base/generated/arvados.tar.gz
62
63 SLURM_GENERATED = slurm/generated/*
64
65 COMPUTE_GENERATED = compute/generated/setup.sh
66
67 COMPUTE_GENERATED_IN = compute/setup.sh.in
68
69 API_GENERATED = \
70         api/generated/arvados-clients.yml \
71         api/generated/apache2_vhost \
72         api/generated/config_databases.sh \
73         api/generated/database.yml \
74         api/generated/omniauth.rb \
75         api/generated/application.yml \
76         api/generated/setup.sh \
77         api/generated/setup-gitolite.sh \
78         api/generated/slurm.conf \
79         api/generated/superuser_token
80
81 API_GENERATED_IN = \
82         api/arvados-clients.yml.in \
83         api/apache2_vhost.in \
84         api/config_databases.sh.in \
85         api/database.yml.in \
86         api/omniauth.rb.in \
87         api/application.yml.in \
88         api/setup.sh.in \
89         api/setup-gitolite.sh.in \
90         api/slurm.conf.in \
91         api/superuser_token.in
92
93 SHELL_GENERATED = \
94         shell/generated/setup.sh \
95         shell/generated/superuser_token
96
97 SHELL_GENERATED_IN = \
98         shell/setup.sh.in \
99         shell/superuser_token.in
100
101 SLURM_GENERATED = \
102         slurm/generated/slurm.conf
103
104 SLURM_GENERATED_IN = \
105         slurm/slurm.conf.in
106
107 WORKBENCH_GENERATED = \
108         workbench/generated/apache2_vhost \
109         workbench/generated/application.yml
110
111 WORKBENCH_GENERATED_IN = \
112         workbench/apache2_vhost.in \
113         workbench/application.yml.in
114
115 SSO_GENERATED = \
116         sso/generated/apache2_vhost \
117         sso/generated/seeds.rb \
118         sso/generated/secret_token.rb
119
120 SSO_GENERATED_IN = \
121         sso/apache2_vhost.in \
122         sso/seeds.rb.in \
123         sso/secret_token.rb.in
124
125 $(BUILD):
126         mkdir -p build
127         rsync -rlp --exclude=docker/ --exclude='**/log/*' --exclude='**/tmp/*' \
128                 --chmod=Da+rx,Fa+rX ../ build/
129         find build/ -name \*.gem -delete
130         cd build/services/fuse/ && python setup.py build
131         cd build/sdk/python/ && python setup.py build
132         cd build/sdk/cli && gem build arvados-cli.gemspec
133         cd build/sdk/ruby && gem build arvados.gemspec
134         touch build/.buildstamp
135
136 $(SLURM_GENERATED): config.yml $(BUILD)
137         $(CONFIG_RB)
138         mkdir -p slurm/generated
139
140 $(BASE_GENERATED): config.yml $(BUILD)
141         $(CONFIG_RB)
142         mkdir -p base/generated
143         tar -czf base/generated/arvados.tar.gz -C build .
144
145 $(API_GENERATED): config.yml $(API_GENERATED_IN)
146         $(CONFIG_RB)
147
148 $(SHELL_GENERATED): config.yml $(SHELL_GENERATED_IN)
149         $(CONFIG_RB)
150
151 $(WORKBENCH_GENERATED): config.yml $(WORKBENCH_GENERATED_IN)
152         $(CONFIG_RB)
153
154 $(COMPUTE_GENERATED): config.yml $(COMPUTE_GENERATED_IN)
155
156 $(WAREHOUSE_GENERATED): config.yml $(WAREHOUSE_GENERATED_IN)
157         $(CONFIG_RB)
158
159 $(SSO_GENERATED): config.yml $(SSO_GENERATED_IN)
160         $(CONFIG_RB)
161
162 # The docker build -q option suppresses verbose build output.
163 # Necessary to prevent failure on building warehouse; see
164 # https://github.com/dotcloud/docker/issues/3172
165 DOCKER_BUILD = $(DOCKER) build -q --rm=true
166
167 # ============================================================
168 # The main Arvados servers: api, doc, workbench, warehouse
169
170 api-image: passenger-image $(BUILD) $(API_DEPS)
171         @echo "Building api-image"
172         mkdir -p api/generated
173         tar -czf api/generated/api.tar.gz -C build/services api
174         chmod 755 api/generated/setup.sh
175         chmod 755 api/generated/setup-gitolite.sh
176         $(DOCKER_BUILD) -t arvados/api api
177         date >api-image
178
179 shell-image: base-image $(BUILD) $(SHELL_DEPS)
180         mkdir -p shell/generated
181         chmod 755 shell/generated/setup.sh
182         $(DOCKER_BUILD) -t arvados/shell shell
183         date >shell-image
184
185 compute-image: slurm-image $(BUILD) $(COMPUTE_DEPS)
186         chmod 755 compute/generated/setup.sh
187         $(DOCKER_BUILD) -t arvados/compute compute
188         date >compute-image
189
190 doc-image: base-image $(BUILD) $(DOC_DEPS)
191         mkdir -p doc/generated
192         tar -czf doc/generated/doc.tar.gz -C build doc
193         $(DOCKER_BUILD) -t arvados/doc doc
194         date >doc-image
195
196 keep-image: debian-arvados-image $(BUILD) $(KEEP_DEPS)
197         $(DOCKER_BUILD) -t arvados/keep keep
198         date >keep-image
199
200 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
201         $(DOCKER_BUILD) -t arvados/jobs jobs
202         date >jobs-image
203
204 java-bwa-samtools-image: jobs-image $(BUILD) $(JAVA_BWA_SAMTOOLS_DEPS)
205         $(DOCKER_BUILD) -t arvados/jobs-java-bwa-samtools java-bwa-samtools
206         date >java-bwa-samtools-image
207
208 bcbio-nextgen-image: $(BUILD) $(BASE_GENERATED) $(BCBIO_NEXTGEN_DEPS)
209         rm -rf bcbio-nextgen/generated
210         cp -r base/generated bcbio-nextgen
211         $(DOCKER_BUILD) -t arvados/bcbio-nextgen bcbio-nextgen
212         date >bcbio-nextgen-image
213
214 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
215         mkdir -p workbench/generated
216         tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
217         $(DOCKER_BUILD) -t arvados/workbench workbench
218         date >workbench-image
219
220 warehouse-image: base-image $(WAREHOUSE_DEPS)
221         $(DOCKER_BUILD) -t arvados/warehouse warehouse
222         date >warehouse-image
223
224 sso-image: passenger-image $(SSO_DEPS)
225         $(DOCKER_BUILD) -t arvados/sso sso
226         date >sso-image
227
228 # ============================================================
229 # The arvados/base image is the base Debian image plus packages
230 # that are dependencies for every Arvados service.
231
232 passenger-image: base-image
233         $(DOCKER_BUILD) -t arvados/passenger passenger
234         date >passenger-image
235
236 slurm-image: base-image $(SLURM_DEPS)
237         $(DOCKER_BUILD) -t arvados/slurm slurm
238         date >slurm-image
239
240 base-image: debian-arvados-image $(BASE_DEPS)
241         @echo "Building base-image"
242         $(DOCKER_BUILD) -t arvados/base base
243         date >base-image
244
245 debian-arvados-image:
246         ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
247         date >debian-arvados-image