-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
78 lines (64 loc) · 2.59 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
KIND := kindest/node:v1.27.3
KIND_CLUSTER := golang-service-cluster
SERVICE_NAME := golang-service
VERSION := 0.0.1
DEPENDENCIES := brew kind kubectl kustomize pgcli vault kustomize
# ==================================================================================== #
# HELPERS
# ==================================================================================== #
## help: print this help message
.PHONY: help
help:
@echo 'Usage:'
@sed -n 's/^##//p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
# ==================================================================================== #
# DEPENDENCIES
# ==================================================================================== #
## check-dependencies: check for required dependencies
.PHONY: check-dependencies
check-dependencies:
@$(foreach dep,$(DEPENDENCIES), \
which $(dep) > /dev/null || { echo "$(dep) is not installed. Please install $(dep)."; exit 1; }; \
)
## install-dependencies: install required dependencies using brew
.PHONY: install-dependencies
install-dependencies:
@$(foreach dep,$(DEPENDENCIES), \
which $(dep) > /dev/null || brew install $(dep); \
)
# ==================================================================================== #
# RUNNING DEV
# ==================================================================================== #
## run-local: run the application locally
.PHONY: run-local
run-local:
@echo "🚀 Running application locally"
@go run app/services/sales-api/main.go
## dev-up: start the development environment using Kind
.PHONY: dev-up
dev-up:
kind create cluster \
--image $(KIND) \
--name $(KIND_CLUSTER)
kubectl wait --timeout=120s --namespace=local-path-storage --for=condition=Available deployment/local-path-provisioner
## dev-load: loads the image into the kind cluster
.PHONY: dev-load
dev-load:
@echo "🚀 Loading 'golang-service' image into Kind cluster"
@kind load docker-image $(SERVICE_NAME):$(VERSION) --name $(KIND_CLUSTER)
## dev-apply: apply kustomization and applies the artifacts to the cluster in local dev
.PHONY: dev-apply
dev-apply:
@echo "🚀 Applying kustomization to Kind cluster"
@kustomize build zarf/k8s/dev/sales | kubectl apply -f -
# ==================================================================================== #
# BUILDING
# ==================================================================================== #
## build-service: build the service Docker image
.PHONY: build-service
build-service:
@echo "🚀 Building service Docker image"
@docker build \
-f zarf/docker/Dockerfile.service \
-t $(SERVICE_NAME):$(VERSION) \
.