-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
56 lines (42 loc) · 1.33 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
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}"
.PHONY: build/docker
build/docker: ## Build the docker image.
DOCKER_BUILDKIT=1 \
docker build \
-f ./Dockerfile \
-t polygonid/verifier-backend:$(VERSION) \
--build-arg VERSION=$(VERSION) \
--build-arg BUILD_DATE=`date -u +"%Y-%m-%dT%H:%M:%SZ"` \
.
## install code generator for API files.
$(BIN)/oapi-codegen: tools.go go.mod go.sum
go get github.com/deepmap/oapi-codegen/cmd/oapi-codegen
$(GO) install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
# install golang lint.
$(BIN)/golangci-lint: go.mod go.sum
$(GO) install github.com/golangci/golangci-lint/cmd/golangci-lint
.PHONY: tests
tests:
$(GO) test -v ./...
## Generate API files
.PHONY: api
api: $(BIN)/oapi-codegen
$(BIN)/oapi-codegen -config ./api/config-oapi-codegen.yaml ./api/api.yaml > ./internal/api/api.gen.go
.PHONY: lint
lint: $(BIN)/golangci-lint
$(BIN)/golangci-lint run
.PHONY: run
run: build/docker
docker run --env-file ./.env -p 3010:3010 -d --name verifier-backend polygonid/verifier-backend:$(VERSION)
.PHONY: stop
stop:
docker stop verifier-backend || true
.PHONY: restart
restart: stop
docker rm verifier-backend || true
make run