Build all containers from working source. (refs #2221)
[arvados.git] / docker / 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 *-image */generated/*
7         -@rmdir */generated
8
9 # `make realclean' will also remove the docker images and force
10 # subsequent makes to build the entire chain from the ground up
11 realclean: clean
12         -[ -n "`docker ps -q`" ] && docker stop `docker ps -q`
13         -docker rm `docker ps -a -q`
14         -docker rmi `docker images -q`
15
16 # ============================================================
17 # Dependencies for */generated files which are prerequisites
18 # for building docker images.
19
20 BASE_DEPS = base/Dockerfile $(BASE_GENERATED)
21
22 API_DEPS = api/Dockerfile $(API_GENERATED)
23
24 DOC_DEPS = doc/Dockerfile doc/apache2_vhost
25
26 WORKBENCH_DEPS = workbench/Dockerfile \
27                  workbench/passenger.conf \
28                  $(WORKBENCH_GENERATED)
29
30 WAREHOUSE_DEPS = warehouse/Dockerfile \
31                  warehouse/supervisor.conf \
32                  $(WAREHOUSE_GENERATED)
33
34 SSO_DEPS = sso/passenger.conf $(SSO_GENERATED)
35
36 BASE_GENERATED = base/generated/arvados.tar.gz
37
38 API_GENERATED = \
39         api/generated/apache2_vhost \
40         api/generated/config_databases.sh \
41         api/generated/database.yml \
42         api/generated/omniauth.rb \
43         api/generated/production.rb \
44         api/generated/secret_token.rb \
45         api/generated/superuser_token
46
47 API_GENERATED_IN = \
48         api/apache2_vhost.in \
49         api/config_databases.sh.in \
50         api/database.yml.in \
51         api/omniauth.rb.in \
52         api/production.rb.in \
53         api/secret_token.rb.in \
54         api/superuser_token.in
55
56 WORKBENCH_GENERATED = \
57         workbench/generated/apache2_vhost \
58         workbench/generated/production.rb \
59         workbench/generated/secret_token.rb
60
61 WORKBENCH_GENERATED_IN = \
62         workbench/apache2_vhost.in \
63         workbench/production.rb.in \
64         workbench/secret_token.rb.in
65
66 WAREHOUSE_GENERATED = warehouse/generated/warehouse.conf
67
68 WAREHOUSE_GENERATED_IN = warehouse/warehouse.conf.in
69
70 SSO_GENERATED = \
71         sso/generated/apache2_vhost \
72         sso/generated/seeds.rb \
73         sso/generated/secret_token.rb
74
75 SSO_GENERATED_IN = \
76         sso/apache2_vhost.in \
77         sso/seeds.rb.in \
78         sso/secret_token.rb.in
79
80 $(BASE_GENERATED): config.yml
81         ./config.rb
82         mkdir -p base/generated
83         tar -c -z -f base/generated/arvados.tar.gz -C .. . \
84           --exclude=services/api/log/* --exclude=docker/*
85
86
87 $(API_GENERATED): config.yml $(API_GENERATED_IN)
88         ./config.rb
89
90 $(WORKBENCH_GENERATED): config.yml $(WORKBENCH_GENERATED_IN)
91         ./config.rb
92
93 $(WAREHOUSE_GENERATED): config.yml $(WAREHOUSE_GENERATED_IN)
94         ./config.rb
95
96 $(SSO_GENERATED): config.yml $(SSO_GENERATED_IN)
97         ./config.rb
98
99 # The docker build -q option suppresses verbose build output.
100 # Necessary to prevent failure on building warehouse; see
101 # https://github.com/dotcloud/docker/issues/3172
102 DOCKER_BUILD = docker build -q
103
104 # ============================================================
105 # The main Arvados servers: api, doc, workbench, warehouse
106
107 api-image: passenger-image $(API_DEPS)
108         mkdir -p api/generated
109         tar -c -z -f api/generated/api.tar.gz -C ../services api --exclude=api/log/*
110         $(DOCKER_BUILD) -t arvados/api api
111         echo -n "Built at $(date)" > api-image
112
113 doc-image: base-image $(DOC_DEPS)
114         mkdir -p doc/generated
115         tar -c -z -f doc/generated/doc.tar.gz -C .. doc
116         $(DOCKER_BUILD) -t arvados/doc doc
117         echo -n "Built at $(date)" > doc-image
118
119 workbench-image: passenger-image $(WORKBENCH_DEPS)
120         mkdir -p workbench/generated
121         tar -c -z -f workbench/generated/workbench.tar.gz -C ../apps workbench
122         $(DOCKER_BUILD) -t arvados/workbench workbench
123         echo -n "Built at $(date)" > workbench-image
124
125 warehouse-image: base-image $(WAREHOUSE_DEPS)
126         $(DOCKER_BUILD) -t arvados/warehouse warehouse
127         echo -n "Built at $(date)" > warehouse-image
128
129 sso-image: passenger-image $(SSO_DEPS)
130         $(DOCKER_BUILD) -t arvados/sso sso
131         echo -n "Built at $(date)" > sso-image
132
133 # ============================================================
134 # The arvados/base image is the base Debian image plus packages
135 # that are dependencies for every Arvados service.
136
137 passenger-image: base-image
138         $(DOCKER_BUILD) -t arvados/passenger passenger
139         echo -n "Built at $(date)" > passenger-image
140
141 base-image: debian-image $(BASE_DEPS)
142         $(DOCKER_BUILD) -t arvados/base base
143         echo -n "Built at $(date)" > base-image
144
145 debian-image:
146         ./mkimage-debootstrap.sh arvados/debian wheezy ftp://ftp.us.debian.org/debian/
147         echo -n "Built at $(date)" > debian-image
148