forked from IBM/rotisserie
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
92 lines (76 loc) · 3.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
SHELL := /bin/bash
REV_FILE=.make-rev-check
## Workflow
## export APP_HOSTNAME=''
##
## edit -
## letsencrypt.yaml
## rotisserie-secrets.yaml
##
##
## Start from scratch(using kube-lego):
## make full-roll
##
## Start from scratch(without kube-lego):
## make roll
##
## Redeploying after making changes:
## make all-images
## make redeploy
##
## Cleanup after testing:
## make purge
## IMAGES ##
# Sets the revision and stores it in .make-rev-check.
set-rev:
git rev-parse --short HEAD > $(REV_FILE)
# Creates images for the app, ocr, and static containers. Runs set-rev to ensure that the rev_file exists.
images: set-rev
./deploy/images/make-image.sh deploy/images/app.Dockerfile "rotisserie-app:$$(cat $(REV_FILE))"
./deploy/images/make-image.sh deploy/images/ocr.Dockerfile "rotisserie-ocr:$$(cat $(REV_FILE))"
./deploy/images/make-image.sh deploy/images/static-server.Dockerfile "rotisserie-static:$$(cat $(REV_FILE))"
# Tags images for the app, ocr, and static containers. Runs set-rev to ensure that the rev_file exists.
tag-images: set-rev
docker tag "rotisserie-app:$$(cat $(REV_FILE))" "registry.ng.bluemix.net/rotisserie/rotisserie-app:$$(cat $(REV_FILE))"
docker tag "rotisserie-ocr:$$(cat $(REV_FILE))" "registry.ng.bluemix.net/rotisserie/rotisserie-ocr:$$(cat $(REV_FILE))"
docker tag "rotisserie-static:$$(cat $(REV_FILE))" "registry.ng.bluemix.net/rotisserie/rotisserie-static:$$(cat $(REV_FILE))"
# Uploads images to IBM Cointainer Repository. Runs set-rev to ensure that the rev_file exists.
upload-images: set-rev
docker push "registry.ng.bluemix.net/rotisserie/rotisserie-app:$$(cat $(REV_FILE))"
docker push "registry.ng.bluemix.net/rotisserie/rotisserie-ocr:$$(cat $(REV_FILE))"
docker push "registry.ng.bluemix.net/rotisserie/rotisserie-static:$$(cat $(REV_FILE))"
# Runs all image related tasks.
all-images: set-rev images tag-images upload-images
## Kubernetes ##
# Creates secrets required for the cluster based on the rotisserie-secrets.yaml file.
secrets:
kubectl create -f rotisserie-secrets.yaml || true
# Deploys based on the rotisserie.yaml file. Runs set-rev to ensure that the rev_file exists. Uses revision
# to set the image_tag in rotisserie.yaml.
.PHONY: deploy
deploy: set-rev
IMAGE_TAG=$$(cat $(REV_FILE)) envsubst < deploy/rotisserie.yaml | kubectl apply -f -
# Deploys kube-lego based on the letsencrypt.yaml and kube-lego.yaml files.
kube-lego:
kubectl create -f letsencrypt.yaml
kubectl create -f deploy/kube-lego.yaml
# Deletes the app, ocr, and static deployments using kubectl delete.
delete-deployments:
kubectl delete deploy rotisserie-app
kubectl delete deploy rotisserie-ocr
kubectl delete deploy rotisserie-static
# Runs delete-deployments then runs deploy.
redeploy: delete-deployments deploy
# Creates a new deployment from scratch, without kube-lego.
roll: all-images secrets deploy
# Creates a new deployment from scratch, with kube-lego.
full-roll: roll kube-lego
# Deletes deployments based on deployment files.
purge:
kubectl delete -f deploy/rotisserie.yaml || true
kubectl delete -f deploy/kube-lego.yaml || true
kubectl delete -f rotisserie-secrets.yaml || true
kubectl delete -f letsencrypt.yaml || true
kubectl delete ing kube-lego-nginx || true
kubectl delete secrets kube-lego-account || true
kubectl delete secrets rotisserie-tls || true