-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
70 lines (57 loc) · 2.49 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
.DEFAULT_GOAL:=help
#============================================================================
# Load environment variables for local development
include .env
export
#============================================================================
.PHONY: dev
dev: ## Run dev container
@docker compose ls -q | grep -q "instill-core" && true || \
(echo "Error: Run \"make latest PROFILE=controller ITMODE_ENABLED=true\" in instill-core repository (https://github.com/instill-ai/instill-core) in your local machine first." && exit 1)
@docker inspect --type container ${SERVICE_NAME} >/dev/null 2>&1 && echo "A container named ${SERVICE_NAME} is already running." || \
echo "Run dev container ${SERVICE_NAME}. To stop it, run \"make stop\"."
@docker run -d --rm \
-e DOCKER_HOST=${SOCAT_HOST}:${SOCAT_PORT} \
-e CFG_ETCD_PORT=${ETCD_CLIENT_PORT} \
-v model-repository:/model-repository \
-v $(PWD):/${SERVICE_NAME} \
-p ${SERVICE_PORT}:${SERVICE_PORT} \
--network instill-network \
--name ${SERVICE_NAME} \
instill/${SERVICE_NAME}:dev >/dev/null 2>&1
.PHONY: logs
logs: ## Tail container logs with -n 10
@docker logs ${SERVICE_NAME} --follow --tail=10
.PHONY: stop
stop: ## Stop container
@docker stop -t 1 ${SERVICE_NAME}
.PHONY: rm
rm: ## Remove container
@docker rm -f ${SERVICE_NAME}
.PHONY: top
top: ## Display all running service processes
@docker top ${SERVICE_NAME}
.PHONY: build
build: ## Build dev docker image
@docker build \
--build-arg SERVICE_NAME=${SERVICE_NAME} \
--build-arg GOLANG_VERSION=${GOLANG_VERSION} \
--build-arg K6_VERSION=${K6_VERSION} \
-f Dockerfile.dev -t instill/${SERVICE_NAME}:dev .
.PHONY: go-gen
go-gen: ## Generate codes
go generate ./...
.PHONY: unit-test
unit-test: ## Run unit test
@go test -v -race -coverpkg=./... -coverprofile=/model/coverage.out ./...
@go tool cover -func=/model/coverage.out
@go tool cover -html=/model/coverage.out
@rm /model/coverage.out
.PHONY: integration-test
integration-test: ## Run integration test
@TEST_FOLDER_ABS_PATH=${PWD} k6 run \
-e API_GATEWAY_PROTOCOL=${API_GATEWAY_PROTOCOL} -e API_GATEWAY_URL=${API_GATEWAY_URL} integration-test/grpc.js --no-usage-report --quiet
.PHONY: help
help: ## Show this help
@echo "\nMakefile for local development"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m (default: help)\n\nTargets:\n"} /^[a-zA-Z_-]+:.*?##/ { printf " \033[36m%-18s\033[0m %s\n", $$1, $$2 }' $(MAKEFILE_LIST)