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