-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
72 lines (55 loc) · 1.53 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
APP_IMAGE_NAME=selfservice/confluent-gateway
DB_IMAGE_NAME=selfservice/confluent-gateway/dbmigrations
BUILD_NUMBER=n/a
OUTPUT_DIR=${PWD}/.output
OUTPUT_DIR_APP=${OUTPUT_DIR}/app
OUTPUT_DIR_MANIFESTS=${OUTPUT_DIR}/manifests
OUTPUT_DIR_TESTS=${OUTPUT_DIR}/tests
GOOS=linux
GOARCH=amd64
RICHGO:=$(shell which richgo 2>/dev/null)
clean:
@rm -Rf $(OUTPUT_DIR)
@mkdir $(OUTPUT_DIR)
@mkdir $(OUTPUT_DIR_APP)
@mkdir $(OUTPUT_DIR_MANIFESTS)
@mkdir $(OUTPUT_DIR_TESTS)
restore:
@cd src && go mod download -x
build:
@cd src && GOOS=$(GOOS) GOARCH=$(GOARCH) CGO_BUILD=0 go build \
-v \
-ldflags='-extldflags=-static -w -s' \
-tags netgo,osusergo \
-o $(OUTPUT_DIR_APP)/confluent-gateway \
./cmd/main
# NOTE: if CGO_BUILD=0 becomes a problem down the line
# go build -ldflags='-extldflags=-static -w -s' -tags netgo,osusergo
test: tests
tests:
ifdef RICHGO
@cd src && richgo test \
-v \
-cover \
./...
else
@cd src && go test \
-v \
-cover \
./...
endif
container:
@docker build -t $(APP_IMAGE_NAME) .
@docker build -t ${DB_IMAGE_NAME} ./db
manifests:
@cp -r ./k8s/. $(OUTPUT_DIR_MANIFESTS)
@find "$(OUTPUT_DIR_MANIFESTS)" -type f -name '*.yml' | xargs sed -i 's:{{BUILD_NUMBER}}:${BUILD_NUMBER}:g'
deliver:
@sh ./tools/push-container.sh "${APP_IMAGE_NAME}" "${BUILD_NUMBER}"
@sh ./tools/push-container.sh "${DB_IMAGE_NAME}" "${BUILD_NUMBER}"
ci: clean restore build tests container manifests
cd: ci deliver
clean-restore-build: clean restore build
docker-build-push: container deliver
run:
@cd src && go run ./cmd/main