-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (37 loc) · 1.31 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
GOOS ?= linux #$(shell go env GOOS)
GOARCH ?= amd64 #$(shell go env GOARCH)
IMG ?= makubit/simple-application:latest
ESCAPED_IMG := $(shell echo ${IMG} | sed 's/\//\\\//g')
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
NAME ?= simple-application-with-deployment
##@ Development
fmt: ## Run go fmt against code.
go fmt ./...
vet: ## Run go vet against code.
go vet ./...
test: fmt vet ## Run tests.
go test ./... -coverprofile coverage.out
##@ Build
build: fmt vet ## Build service binary.
GOOS=${GOOS} GOARCH=${GOARCH} go build -o build/sample ./cmd/...
docker-build: test ##Build docker image.
docker build -t ${IMG} ./build
docker-push: ## Push docker image.
docker push ${IMG}
clean: ## Clean all binaries and test files.
rm -rf ${PROJECT_DIR}/build/helm
rm -f ${PROJECT_DIR}/build/sample
rm -f ${PROJECT_DIR}/coverage.out
mongo-docker-run:
docker pull mongo
docker run -d --name mongodb-local -p 27017:27017 mongo
##@ Deploy
helm-build:
cp -R helm $(PROJECT_DIR)/build/helm
sed -i '' -e 's/$${img}/${ESCAPED_IMG}/g' $(PROJECT_DIR)/build/helm/values.yaml
helm lint $(PROJECT_DIR)/build/helm
helm-deploy: helm-build ## Deploy helm resources.
helm install ${NAME} $(PROJECT_DIR)/build/helm
rm -rf $(PROJECT_DIR)/build/helm
helm-delete: ## Delete helm deployment.
helm delete ${NAME}