-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskfile.yml
127 lines (123 loc) · 4.02 KB
/
Taskfile.yml
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
version: '3'
output: prefixed
includes:
dev: ./dev
dist: ./dist
helm:
dir: ./helm
taskfile: ./helm
env:
# Enable buildkit for proper multistage Dockerfile builds
# (skipping stages, which are not needed for the target)
DOCKER_BUILDKIT: 1
BUILDER_IMAGE: shopping-cart/builder
tasks:
default:
- task: docker:run
prepare:
- task: vendor
- task: generate:protobuf
vendor:
cmds:
- go mod vendor
sources:
- go.mod
- go.sum
generates:
- vendor/modules.txt
generate:protobuf:
cmds:
- go generate -x shopping-cart/api/proto/...
sources:
- api/proto/**/*.proto
generates:
- api/proto/**/*.pb.go
vet:
deps: [prepare]
cmds: ["go vet ./..."]
fmt:
cmds: ["go fmt ./..."]
build:
- task: api_gateway:build
- task: stock_service:build
- task: payment_service:build
- task: order_service:build
build_docker:
- task: api_gateway:build_docker
- task: stock_service:build_docker
- task: payment_service:build_docker
- task: order_service:build_docker
########## API Gateway ###############################################################################################
api_gateway:run:
deps: [prepare]
cmds: ["go run shopping-cart/cmd/api-gateway {{.CLI_ARGS}}"]
api_gateway:build:
deps: [prepare]
env:
CGO_ENABLED: 0
cmds: ["go build -o out/ shopping-cart/cmd/api-gateway"]
api_gateway:build_docker: docker build --target api-gateway -t shopping-cart/api-gateway .
########## Stock Service #############################################################################################
stock_service:run:
deps: [prepare]
cmds: ["go run shopping-cart/cmd/stock-service {{.CLI_ARGS}}"]
stock_service:build:
deps: [prepare]
env:
CGO_ENABLED: 0
cmds: ["go build -o out/ shopping-cart/cmd/stock-service"]
stock_service:build_docker: docker build --target stock-service -t shopping-cart/stock-service .
########## Payment Service ###########################################################################################
payment_service:run:
deps: [prepare]
cmds: ["go run shopping-cart/cmd/payment-service {{.CLI_ARGS}}"]
payment_service:build:
deps: [prepare]
env:
CGO_ENABLED: 0
cmds: ["go build -o out/ shopping-cart/cmd/payment-service"]
payment_service:build_docker: docker build --target payment-service -t shopping-cart/payment-service .
########## Order Service #############################################################################################
order_service:run:
deps: [prepare]
cmds: ["go run shopping-cart/cmd/order-service {{.CLI_ARGS}}"]
order_service:build:
deps: [prepare]
env:
CGO_ENABLED: 0
cmds: ["go build -o out/ shopping-cart/cmd/order-service"]
order_service:build_docker: docker build --target order-service -t shopping-cart/order-service .
########## Cleanup ###################################################################################################
clean:protobuf: find api/proto -type f -name "*.pb.go" -delete
clean:
- task: clean:protobuf
- rm -rf out
- rm -rf vendor
########## Docker Builder ###########################################################################################
docker:build_builder: docker build --target builder -t {{.BUILDER_IMAGE}} .
docker:run:
deps: [docker:build_builder]
interactive: true
vars:
UID:
sh: id -u
GID:
sh: id -g
PWD:
sh: pwd
cmds:
- >
docker run -it
--network host
--user {{.UID}}:{{.GID}}
--workdir /project
--env GOCACHE=/tmp/gocache
--volume {{.PWD}}:/project
{{.BUILDER_IMAGE}}
{{.CLI_ARGS}}
########## Test ######################################################################################################
test:
deps: [prepare]
cmds:
- go test $(go list ./... | grep -v /vendor/) -v -short -coverprofile cover.out ./...
- go tool cover -html=cover.out -o cover.html