-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
108 lines (82 loc) · 3.21 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
#!/usr/bin/make -f
export GO111MODULE=on
VERSION := $(shell echo $(shell git describe --tags) | sed 's/^v//')
COMMIT := $(shell git rev-parse --short HEAD)
build_tags = netgo
build_tags += $(BUILD_TAGS)
build_tags := $(strip $(build_tags))
whitespace :=
whitespace := $(whitespace) $(whitespace)
comma := ,
build_tags_comma_sep := $(subst $(whitespace),$(comma),$(build_tags))
ldflags = -w -s -X github.com/cosmos/cosmos-sdk/version.Name=mantleNode \
-X github.com/cosmos/cosmos-sdk/version.AppName=mantleNode \
-X github.com/cosmos/cosmos-sdk/version.Version=$(VERSION) \
-X github.com/cosmos/cosmos-sdk/version.Commit=$(COMMIT) \
-X github.com/cosmos/cosmos-sdk/version.BuildTags=$(build_tags_comma_sep) \
ldflags += $(LDFLAGS)
ldflags := $(strip $(ldflags))
BUILD_FLAGS += -tags "$(build_tags)" -ldflags "${ldflags}" -trimpath
# Go environment variables
GOBIN = $(shell go env GOPATH)/bin
# Docker variables
DOCKER := $(shell which docker)
DOCKER_IMAGE_NAME = assetmantle/node
DOCKER_TAG_NAME = edge
DOCKER_CONTAINER_NAME = assetmantle-container
DOCKER_CMD ?= "/bin/sh"
.PHONY: all install build verify docker-run docker-interactive
all: verify build
install:
ifeq (${OS},Windows_NT)
go build -mod=readonly ${BUILD_FLAGS} -o ${GOBIN}/mantleNode.exe ./node
else
go build -mod=readonly ${BUILD_FLAGS} -o ${GOBIN}/mantleNode ./node
endif
build:
ifeq (${OS},Windows_NT)
go build ${BUILD_FLAGS} -o build/mantleNode.exe ./node
else
go build ${BUILD_FLAGS} -o build/mantleNode ./node
endif
verify:
@echo "verifying modules"
@go mod verify
# Commands for running docker
#
# Run node on docker
# Example Usage:
# make docker-build ## Builds node binary in 2 stages, 1st builder 2nd Runner
# Final image only has the compiled node binary
# make docker-interactive ## Will start an shell session into the docker container
# Access to node binary here
# NOTE: To be used for testing only, since the container will be removed after stopping
# make docker-run DOCKER_CMD=sleep 10000000 DOCKER_OPTS=-d ## Will run the container in the background
# NOTE: Recommeded to use docker commands directly for long running processes
# make docker-clean # Will clean up the running container, as well as delete the image
# after one is done testing
enable-docker-buildx:
@${DOCKER} buildx install
@${DOCKER} buildx use default
docker-build:
${DOCKER} build -t ${DOCKER_IMAGE_NAME}:${DOCKER_TAG_NAME} .
docker-build-no-cache:
${DOCKER} build -t ${DOCKER_IMAGE_NAME}:${DOCKER_TAG_NAME} . --no-cache
docker-build-push: docker-build
${DOCKER} push ${DOCKER_IMAGE_NAME}:${DOCKER_TAG_NAME}
docker-run: docker-build
${DOCKER} run ${DOCKER_OPTS} --name=${DOCKER_CONTAINER_NAME} ${DOCKER_IMAGE_NAME}:${DOCKER_TAG_NAME} ${DOCKER_CMD}
docker-interactive: docker-build
${MAKE} docker-run DOCKER_CMD=/bin/sh DOCKER_OPTS="--rm -it"
docker-clean-container:
-${DOCKER} stop ${DOCKER_CONTAINER_NAME}
-${DOCKER} rm ${DOCKER_CONTAINER_NAME}
docker-clean-image:
-${DOCKER} rmi ${DOCKER_IMAGE_NAME}:${DOCKER_TAG_NAME}
docker-compose:
${DOCKER} compose up -d
docker-compose-it:
${DOCKER} compose up
docker-compose-clean:
-${DOCKER} compose down -t0 -v
docker-clean: docker-compose-clean docker-clean-container docker-clean-image