forked from codingwithmanny/0xPolygonID--issuer-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
119 lines (90 loc) · 3.47 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
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
BIN := $(shell pwd)/bin
VERSION ?= $(shell git rev-parse --short HEAD)
GO?=$(shell which go)
export GOBIN := $(BIN)
export PATH := $(BIN):$(PATH)
BUILD_CMD := $(GO) install -ldflags "-X main.build=${VERSION}"
LOCAL_DEV_PATH = $(shell pwd)/infrastructure/local
DOCKER_COMPOSE_FILE := $(LOCAL_DEV_PATH)/docker-compose.yml
DOCKER_COMPOSE_CMD := docker-compose -p sh-id-platform -f $(DOCKER_COMPOSE_FILE)
.PHONY: build
build:
$(BUILD_CMD) ./cmd/...
.PHONY: build/docker
build/docker: ## Build the docker image.
DOCKER_BUILDKIT=1 \
docker build \
-f ./Dockerfile \
-t sh-id-platform/api:$(VERSION) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
.
.PHONY: clean
clean: ## Go clean
$(GO) clean ./...
.PHONY: tests
tests:
$(GO) test -v ./... --count=1
.PHONY: test-race
test-race:
$(GO) test -v --race ./...
$(BIN)/oapi-codegen: tools.go go.mod go.sum ## install code generator for API files.
go get github.com/deepmap/oapi-codegen/cmd/oapi-codegen
$(GO) install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
.PHONY: api
api: $(BIN)/oapi-codegen
$(BIN)/oapi-codegen -config ./api/config-oapi-codegen.yaml ./api/api.yaml > ./internal/api/api.gen.go
.PHONY: api-admin
api-admin: $(BIN)/oapi-codegen
$(BIN)/oapi-codegen -config ./api_admin/config-oapi-codegen.yaml ./api_admin/api.yaml > ./internal/api_admin/api.gen.go
.PHONY: up
up:
$(DOCKER_COMPOSE_CMD) up -d redis postgres vault
.PHONY: run
run:
$(eval TOKEN = $(shell docker logs sh-id-platform-test-vault 2>&1 | grep " .hvs" | awk '{print $$2}' | tail -1 ))
COMPOSE_DOCKER_CLI_BUILD=1 KEY_STORE_TOKEN=$(TOKEN) DOCKER_FILE="Dockerfile" $(DOCKER_COMPOSE_CMD) up -d platform
.PHONY: run-arm
run-arm:
$(eval TOKEN = $(shell docker logs sh-id-platform-test-vault 2>&1 | grep " .hvs" | awk '{print $$2}' | tail -1 ))
COMPOSE_DOCKER_CLI_BUILD=1 KEY_STORE_TOKEN=$(TOKEN) DOCKER_FILE="Dockerfile-arm" $(DOCKER_COMPOSE_CMD) up -d platform
.PHONY: run-ui-backend
run-ui-backend:
$(eval TOKEN = $(shell docker logs sh-id-platform-test-vault 2>&1 | grep " .hvs" | awk '{print $$2}' | tail -1 ))
COMPOSE_DOCKER_CLI_BUILD=1 KEY_STORE_TOKEN=$(TOKEN) DOCKER_FILE="Dockerfile" $(DOCKER_COMPOSE_CMD) up -d admin
.PHONY: run-arm-ui-backend
run-arm-ui-backend:
$(eval TOKEN = $(shell docker logs sh-id-platform-test-vault 2>&1 | grep " .hvs" | awk '{print $$2}' | tail -1 ))
COMPOSE_DOCKER_CLI_BUILD=1 KEY_STORE_TOKEN=$(TOKEN) DOCKER_FILE="Dockerfile-arm" $(DOCKER_COMPOSE_CMD) up -d admin
.PHONY: down
down:
$(DOCKER_COMPOSE_CMD) down --remove-orphans
.PHONY: stop
stop:
$(DOCKER_COMPOSE_CMD) stop
.PHONY: up-test
up-test:
$(DOCKER_COMPOSE_CMD) up -d test_postgres vault
$(BIN)/configurator:
$(BUILD_CMD) ./cmd/configurator
.PHONY: clean-vault
clean-vault:
rm -R infrastructure/local/.vault/data/init.out
rm -R infrastructure/local/.vault/file/core/
rm -R infrastructure/local/.vault/file/logical/
rm -R infrastructure/local/.vault/file/sys/
$(BIN)/platformid-migrate:
$(BUILD_CMD) ./cmd/migrate
$(BIN)/install-goose: go.mod go.sum
$(GO) install github.com/pressly/goose/v3
$(BIN)/golangci-lint: go.mod go.sum
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint
.PHONY: db/migrate
db/migrate: $(BIN)/install-goose $(BIN)/platformid-migrate ## Install goose and apply migrations.
sh -c '$(BIN)/migrate'
.PHONY: config
config: $(BIN)/configurator
sh -c '$(BIN)/configurator -template=config.toml.sample -output=config.toml'
.PHONY: lint
lint: $(BIN)/golangci-lint
$(BIN)/golangci-lint run