-
Notifications
You must be signed in to change notification settings - Fork 0
/
bb.edn
109 lines (88 loc) · 3 KB
/
bb.edn
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{:paths ["bb"]
:deps
{org.clojars.lispyclouds/contajners {:mvn/version "1.0.5"}}
:tasks
{clj:repl
{:doc "Start repl"
:task (shell "clojure -M:repl")}
bb:repl
{:doc "bb nrepl server"
:task (shell "bb nrepl-server")}
test
{:doc "Run tests"
:task (shell "./bin/kaocha")}
test:watch
{:doc "Run tests watch mode"
:task (shell "./bin/kaocha --watch")}
uber:build
{:doc "Build uber"
:task (shell "clojure -T:build uber")}
uber:run
{:doc "Run uber"
:task (shell "java -jar target/app-standalone.jar")}
start
{:doc "Run locally"
:task (shell "clojure -M -m template.core")}
docker:build
{:doc "Build image"
:task (shell "docker build --tag shopping-cart .")}
docker:run
{:doc "Run container"
:task (shell "docker run --rm -p 5000:80 shopping-cart")}
infra:plan
{:doc "Plan infra"
:task (shell {:dir "infra"} "terraform plan")}
infra:apply
{:doc "Apply infra"
:task (shell {:dir "infra"} "terraform apply")}
infra:destroy
{:doc "Destroy infra"
:task (shell {:dir "infra"} "terraform destroy")}
infra:name
{:doc "Get name"
:requires ([cheshire.core :as json])
:task (-> (shell {:dir "infra" :out :string} "terraform output -raw name")
:out)}
acr:login
{:doc "Login to ACR"
:requires ([cheshire.core :as json])
:depends [infra:name]
:task (let [login-cmd (format "az acr credential show --name %s" infra:name)
result (-> (shell {:out :string} login-cmd)
:out
(json/parse-string true))
username (:username result)
password (get-in result [:passwords 0 :value])
host (-> (shell {:dir "infra" :out :string} "terraform output -raw registry_hostname")
:out)]
(shell (format "docker login %s --username %s --password %s" host username password)))}
acr:build
{:doc "Tag image for ACR"
:depends [docker:build]
:requires ([cheshire.core :as json])
:task (let [host (-> (shell {:dir "infra" :out :string} "terraform output -raw registry_hostname")
:out)]
(shell (format "docker tag shopping-cart:latest %s/shopping-cart:latest" host)))}
acr:push
{:doc "Push image to ACR"
:depends [acr:build]
:requires ([cheshire.core :as json])
:task (let [host (-> (shell {:dir "infra" :out :string} "terraform output -raw registry_hostname")
:out)]
(shell (format "docker push %s/shopping-cart:latest" host)))}
k8:connect
{:doc "Add Azure k8 to kubectl"
:depends [infra:name]
:task (shell (format "az aks get-credentials --resource-group %s --name %s" infra:name infra:name))}
k8:apply
{:doc "Run k8"
:task (shell "kubectl apply -f manifests/")}
k8:delete
{:doc "Stop k8"
:task (shell "kubectl delete -f manifests/")}
k8:show
{:doc "Show k8 details"
:task (do
(shell "kubectl get pods")
(shell "kubectl get deployments")
(shell "kubectl get services"))}}}