forked from onepanelio/onepanel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (49 loc) · 1.85 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
COMMIT_HASH=$(shell git rev-parse --short HEAD)
.PHONY: init
init:
ifndef version
$(error version is undefined)
endif
jq:
cat api/apidocs.swagger.json \
| jq 'walk( if type == "object" then with_entries( .key |= sub( "api\\."; "") ) else . end )' \
| jq 'walk( if type == "string" then gsub( "api\\."; "") else . end )' \
| jq '.info.version = "$(version)"' \
> api/api.swagger.json
rm api/apidocs.swagger.json
protoc:
protoc -I/usr/local/include \
-Iapi/third_party/ \
-Iapi/proto \
--go_out ./api/gen --go_opt paths=source_relative \
--go-grpc_out ./api/gen --go-grpc_opt paths=source_relative \
--go-grpc_opt paths=source_relative \
--grpc-gateway_out ./api/gen \
--grpc-gateway_opt logtostderr=true \
--grpc-gateway_opt allow_delete_body=true \
--grpc-gateway_opt paths=source_relative \
--grpc-gateway_opt generate_unbound_methods=true \
--openapiv2_out ./api \
--openapiv2_opt allow_merge=true \
--openapiv2_opt fqn_for_openapi_name=true \
--openapiv2_opt allow_delete_body=true \
--openapiv2_opt logtostderr=true \
--openapiv2_opt simple_operation_ids=true \
api/proto/*.proto
api-internal: init protoc jq
api: init
docker run --rm --mount type=bind,source="${PWD}",target=/root onepanel/helper:v1.0.0 make api-internal version=$(version)
docker-build:
docker build -t onepanel-core .
docker tag onepanel-core:latest onepanel/core:$(COMMIT_HASH)
docker-push:
docker push onepanel/core:$(COMMIT_HASH)
docker-custom:
docker build -t onepanel-core .
docker tag onepanel-core:latest onepanel/core:$(TAG)
docker push onepanel/core:$(TAG)
docker: docker-build docker-push
run-tests:
docker run --rm --name test-onepanel-postgres -p 5432:5432 -e POSTGRES_USER=admin -e POSTGRES_PASSWORD=tester -e POSTGRES_DB=onepanel -d postgres:12.3
go test github.com/onepanelio/core/pkg -count=1 ||:
docker stop test-onepanel-postgres