-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
64 lines (51 loc) · 1.69 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
GIT_NAME ?= $(shell git describe --exact-match 2>/dev/null)
GIT_HASH ?= git-$(shell git rev-parse --short=12 HEAD)
LDFLAGS ?= "-X github.com/authgear/authgear-nft-indexer/pkg/version.Version=${GIT_HASH}"
.PHONY: start
start:
go run ./cmd/server start
.PHONY: setup
setup: vendor
cp authgear-nft-indexer.yaml.example authgear-nft-indexer.yaml
.PHONY: vendor
vendor:
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.55.2
go mod download
go install github.com/google/wire/cmd/wire
.PHONY: generate
generate:
go generate ./pkg/... ./cmd/...
.PHONY: test
test:
go test ./pkg/... -timeout 1m30s
.PHONY: lint
lint:
golangci-lint run ./cmd/... ./pkg/...
.PHONY: fmt
fmt:
go fmt ./...
.PHONY: build
build:
go build -o $(BIN_NAME) -tags "$(GO_BUILD_TAGS)" -ldflags ${LDFLAGS} ./cmd/$(TARGET)
.PHONY: check-tidy
check-tidy:
$(MAKE) fmt
$(MAKE) generate
go mod tidy
git status --porcelain | grep '.*'; test $$? -eq 1
.PHONY: build-image
build-image:
# Add --pull so that we are using the latest base image.
docker build --pull --file ./cmd/$(TARGET)/Dockerfile --tag $(IMAGE_NAME) --build-arg GIT_HASH=$(GIT_HASH) .
.PHONY: tag-image
tag-image: DOCKER_IMAGE = quay.io/theauthgear/$(IMAGE_NAME)
tag-image:
docker tag $(IMAGE_NAME) $(DOCKER_IMAGE):latest
docker tag $(IMAGE_NAME) $(DOCKER_IMAGE):$(GIT_HASH)
if [ ! -z $(GIT_NAME) ]; then docker tag $(IMAGE_NAME) $(DOCKER_IMAGE):$(GIT_NAME); fi
.PHONY: push-image
push-image: DOCKER_IMAGE = quay.io/theauthgear/$(IMAGE_NAME)
push-image:
docker push $(DOCKER_IMAGE):latest
docker push $(DOCKER_IMAGE):$(GIT_HASH)
if [ ! -z $(GIT_NAME) ]; then docker push $(DOCKER_IMAGE):$(GIT_NAME); fi