Merge branch 'master' into 2955-fail-orphan-jobs
[arvados.git] / docker / build_tools / Makefile
1 all: api-image doc-image workbench-image warehouse-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 -q`
15         -docker rmi `docker images -q`
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 JOBS_DEPS = jobs/Dockerfile
28
29 API_DEPS = api/Dockerfile $(API_GENERATED)
30
31 DOC_DEPS = doc/Dockerfile doc/apache2_vhost
32
33 WORKBENCH_DEPS = workbench/Dockerfile \
34                  workbench/passenger.conf \
35                  $(WORKBENCH_GENERATED)
36
37 WAREHOUSE_DEPS = warehouse/Dockerfile \
38                  warehouse/supervisor.conf \
39                  $(WAREHOUSE_GENERATED)
40
41 SSO_DEPS = sso/passenger.conf $(SSO_GENERATED)
42
43 BASE_GENERATED = base/generated/arvados.tar.gz
44
45 API_GENERATED = \
46         api/generated/apache2_vhost \
47         api/generated/config_databases.sh \
48         api/generated/database.yml \
49         api/generated/omniauth.rb \
50         api/generated/production.rb \
51         api/generated/secret_token.rb \
52         api/generated/superuser_token
53
54 API_GENERATED_IN = \
55         api/apache2_vhost.in \
56         api/config_databases.sh.in \
57         api/database.yml.in \
58         api/omniauth.rb.in \
59         api/production.rb.in \
60         api/secret_token.rb.in \
61         api/superuser_token.in
62
63 WORKBENCH_GENERATED = \
64         workbench/generated/apache2_vhost \
65         workbench/generated/production.rb \
66         workbench/generated/secret_token.rb
67
68 WORKBENCH_GENERATED_IN = \
69         workbench/apache2_vhost.in \
70         workbench/production.rb.in \
71         workbench/secret_token.rb.in
72
73 WAREHOUSE_GENERATED = warehouse/generated/warehouse.conf
74
75 WAREHOUSE_GENERATED_IN = warehouse/warehouse.conf.in
76
77 SSO_GENERATED = \
78         sso/generated/apache2_vhost \
79         sso/generated/seeds.rb \
80         sso/generated/secret_token.rb
81
82 SSO_GENERATED_IN = \
83         sso/apache2_vhost.in \
84         sso/seeds.rb.in \
85         sso/secret_token.rb.in
86
87 $(BUILD):
88         mkdir -p build
89         rsync -rlp --exclude=docker/ --exclude='**/log/*' --exclude='**/tmp/*' \
90                 --chmod=Da+rx,Fa+rX ../ build/
91         find build/ -name \*.gem -delete
92         cd build/services/fuse/ && python setup.py build
93         cd build/sdk/python/ && python setup.py build
94         cd build/sdk/cli && gem build arvados-cli.gemspec
95         cd build/sdk/ruby && gem build arvados.gemspec
96         touch build/.buildstamp
97
98 $(BASE_GENERATED): config.yml $(BUILD)
99         $(CONFIG_RB)
100         mkdir -p base/generated
101         tar -czf base/generated/arvados.tar.gz -C build .
102
103 $(API_GENERATED): config.yml $(API_GENERATED_IN)
104         $(CONFIG_RB)
105
106 $(WORKBENCH_GENERATED): config.yml $(WORKBENCH_GENERATED_IN)
107         $(CONFIG_RB)
108
109 $(WAREHOUSE_GENERATED): config.yml $(WAREHOUSE_GENERATED_IN)
110         $(CONFIG_RB)
111
112 $(SSO_GENERATED): config.yml $(SSO_GENERATED_IN)
113         $(CONFIG_RB)
114
115 # The docker build -q option suppresses verbose build output.
116 # Necessary to prevent failure on building warehouse; see
117 # https://github.com/dotcloud/docker/issues/3172
118 DOCKER_BUILD = docker build -q
119
120 # ============================================================
121 # The main Arvados servers: api, doc, workbench, warehouse
122
123 api-image: passenger-image $(BUILD) $(API_DEPS)
124         mkdir -p api/generated
125         tar -czf api/generated/api.tar.gz -C build/services api
126         $(DOCKER_BUILD) -t arvados/api api
127         date >api-image
128
129 doc-image: base-image $(BUILD) $(DOC_DEPS)
130         mkdir -p doc/generated
131         tar -czf doc/generated/doc.tar.gz -C build doc
132         $(DOCKER_BUILD) -t arvados/doc doc
133         date >doc-image
134
135 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
136         $(DOCKER_BUILD) -t arvados/jobs jobs
137         date >jobs-image
138
139 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
140         mkdir -p workbench/generated
141         tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
142         $(DOCKER_BUILD) -t arvados/workbench workbench
143         date >workbench-image
144
145 warehouse-image: base-image $(WAREHOUSE_DEPS)
146         $(DOCKER_BUILD) -t arvados/warehouse warehouse
147         date >warehouse-image
148
149 sso-image: passenger-image $(SSO_DEPS)
150         $(DOCKER_BUILD) -t arvados/sso sso
151         date >sso-image
152
153 # ============================================================
154 # The arvados/base image is the base Debian image plus packages
155 # that are dependencies for every Arvados service.
156
157 passenger-image: base-image
158         $(DOCKER_BUILD) -t arvados/passenger passenger
159         date >passenger-image
160
161 base-image: debian-image $(BASE_DEPS)
162         $(DOCKER_BUILD) -t arvados/base base
163         date >base-image
164
165 debian-image:
166         ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
167         date >debian-image