Merge branch 'master' into 2525-java-sdk
[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/sdk/python/ && ./build.sh
93         cd build/sdk/cli && gem build arvados-cli.gemspec
94         cd build/sdk/ruby && gem build arvados.gemspec
95         touch build/.buildstamp
96
97 $(BASE_GENERATED): config.yml $(BUILD)
98         $(CONFIG_RB)
99         mkdir -p base/generated
100         tar -czf base/generated/arvados.tar.gz -C build .
101
102 $(API_GENERATED): config.yml $(API_GENERATED_IN)
103         $(CONFIG_RB)
104
105 $(WORKBENCH_GENERATED): config.yml $(WORKBENCH_GENERATED_IN)
106         $(CONFIG_RB)
107
108 $(WAREHOUSE_GENERATED): config.yml $(WAREHOUSE_GENERATED_IN)
109         $(CONFIG_RB)
110
111 $(SSO_GENERATED): config.yml $(SSO_GENERATED_IN)
112         $(CONFIG_RB)
113
114 # The docker build -q option suppresses verbose build output.
115 # Necessary to prevent failure on building warehouse; see
116 # https://github.com/dotcloud/docker/issues/3172
117 DOCKER_BUILD = docker build -q
118
119 # ============================================================
120 # The main Arvados servers: api, doc, workbench, warehouse
121
122 api-image: passenger-image $(BUILD) $(API_DEPS)
123         mkdir -p api/generated
124         tar -czf api/generated/api.tar.gz -C build/services api
125         $(DOCKER_BUILD) -t arvados/api api
126         date >api-image
127
128 doc-image: base-image $(BUILD) $(DOC_DEPS)
129         mkdir -p doc/generated
130         tar -czf doc/generated/doc.tar.gz -C build doc
131         $(DOCKER_BUILD) -t arvados/doc doc
132         date >doc-image
133
134 jobs-image: base-image $(BUILD) $(JOBS_DEPS)
135         $(DOCKER_BUILD) -t arvados/jobs jobs
136         date >jobs-image
137
138 workbench-image: passenger-image $(BUILD) $(WORKBENCH_DEPS)
139         mkdir -p workbench/generated
140         tar -czf workbench/generated/workbench.tar.gz -C build/apps workbench
141         $(DOCKER_BUILD) -t arvados/workbench workbench
142         date >workbench-image
143
144 warehouse-image: base-image $(WAREHOUSE_DEPS)
145         $(DOCKER_BUILD) -t arvados/warehouse warehouse
146         date >warehouse-image
147
148 sso-image: passenger-image $(SSO_DEPS)
149         $(DOCKER_BUILD) -t arvados/sso sso
150         date >sso-image
151
152 # ============================================================
153 # The arvados/base image is the base Debian image plus packages
154 # that are dependencies for every Arvados service.
155
156 passenger-image: base-image
157         $(DOCKER_BUILD) -t arvados/passenger passenger
158         date >passenger-image
159
160 base-image: debian-image $(BASE_DEPS)
161         $(DOCKER_BUILD) -t arvados/base base
162         date >base-image
163
164 debian-image:
165         ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
166         date >debian-image