Debian Codegraph @

case_studies/fractal/Makefile

raw
1 # Copyright 2015 Google Inc. All rights reserved.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 ALL_IMAGES = $(shell cat service.list | grep '[.]packer.json$$')
16
17 default:
18 ../../jsonnet -J lib -A ssh_username=$$USER --multi . service.jsonnet > service.list
19 $(MAKE) all_artifacts
20 $(MAKE) terraform.done
21
22 all_artifacts: $(ALL_IMAGES:.packer.json=.packer.done)
23
24 %.packer.done: %.packer.json
25 @echo "======== BUILDING IMAGE: $(basename $(basename $<)) ========"
26 time packer build -force $< > $(basename $@).log 2>&1
27 cp $< $@
28
29 terraform.done: terraform.tf
30 @echo "======== MODIFYING DEPLOYMENT ========"
31 terraform plan -detailed-exitcode -out=terraform.plan ; case "$$?" in "2") exit 0;; *) exit 1;; esac
32 @read -r -p "Are you sure? [y/N] " response && case "$$response" in [yY][eE][sS]|[yY]) terraform apply terraform.plan && cp $< $@ ;; esac
33
34 destroy:
35 @echo "======== DESTROYING DEPLOYMENT ======== "
36 @rm -vf terraform.plan terraform.done
37 @terraform destroy -force
38
39 clean:
40 rm -fv service.list *.packer.log *.packer.json *~ *.packer.done *.tf