-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (72 loc) · 2.61 KB
/
Copy pathMakefile
File metadata and controls
92 lines (72 loc) · 2.61 KB
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
GOFILES = $(shell find . -name '*.go' -not -path './vendor/*')
GOPACKAGES = $(shell go list ./... | grep -v /vendor/)
GIT_DESCR = $(shell git describe --tags --always)
APP=aecli
# build output folder
OUTPUTFOLDER = dist
# docker image
DOCKER_REGISTRY = 166568770115.dkr.ecr.eu-central-1.amazonaws.com/aeternity
DOCKER_IMAGE = aepp-contracts-library
DOCKER_TAG = $(shell git describe --always --tags)
# build paramters
OS = linux
ARCH = amd64
# K8S
K8S_NAMESPACE = default
K8S_DEPLOYMENT = aepp-contracts-library
.PHONY: list
list:
@$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$' | xargs
default: build
workdir:
mkdir -p dist
build: build-dist
build-dist: $(GOFILES)
@echo build binary to $(OUTPUTFOLDER)
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(APP) .
@echo copy resources
cp -r README.md LICENSE $(OUTPUTFOLDER)
@echo done
build-relase:
@echo build binary to $(OUTPUTFOLDER)
$(eval OS=darwin)
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(OS)/$(APP) .
$(eval OS=windows)
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(OS)/$(APP).exe .
$(eval OS=linux)
GOOS=$(OS) GOARCH=$(ARCH) CGO_ENABLED=0 go build -ldflags "-X main.Version=$(GIT_DESCR)" -o $(OUTPUTFOLDER)/$(OS)/$(APP) .
@echo copy resources
cp -r README.md LICENSE CHANGELOG.md $(OUTPUTFOLDER)
@echo done
test: test-all
test-all:
@go test -v $(GOPACKAGES) -coverprofile .testCoverage.txt
bench: bench-all
bench-all:
@go test -bench -v $(GOPACKAGES)
lint: lint-all
lint-all:
@golint -set_exit_status $(GOPACKAGES)
clean:
@echo remove $(OUTPUTFOLDER) folder
@rm -rf dist
@echo done
docker: docker-build
docker-build:
@echo copy resources
docker build -t $(DOCKER_IMAGE) .
@echo done
docker-push:
@echo push image
docker tag $(DOCKER_IMAGE):latest $(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(DOCKER_TAG)
aws ecr get-login --no-include-email --region eu-central-1 --profile aeternity-sdk | sh
docker push $(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(DOCKER_TAG)
@echo done
docker-run:
docker run -p 1905:1905 $(DOCKER_IMAGE):latest
debug-start:
@go run main.go start
deploy-k8s:
@echo deploy k8s
kubectl -n $(K8S_NAMESPACE) patch deployment $(K8S_DEPLOYMENT) --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"$(DOCKER_REGISTRY)/$(DOCKER_IMAGE):$(DOCKER_TAG)"}]'
@echo deploy k8s done