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