2018-02-01 18:54:23 +00:00
|
|
|
BRANCH = "master"
|
2018-04-16 08:41:23 +00:00
|
|
|
REPONAME = "neo-go"
|
2018-03-15 20:45:37 +00:00
|
|
|
NETMODE ?= "privnet"
|
2019-08-28 19:05:55 +00:00
|
|
|
BINARY = "./bin/neo-go"
|
2019-11-07 11:57:02 +00:00
|
|
|
DESTDIR = ""
|
|
|
|
SYSCONFIGDIR = "/etc"
|
|
|
|
BINDIR = "/usr/bin"
|
|
|
|
SYSTEMDUNIT_DIR = "/lib/systemd/system"
|
|
|
|
UNITWORKDIR = "/var/lib/neo-go"
|
2018-02-01 18:54:23 +00:00
|
|
|
|
2019-11-15 17:41:40 +00:00
|
|
|
DC_FILE=.docker/docker-compose.yml
|
|
|
|
|
2019-08-26 14:26:42 +00:00
|
|
|
REPO ?= "$(shell go list -m)"
|
2019-08-26 14:05:17 +00:00
|
|
|
VERSION ?= "$(shell git describe --tags 2>/dev/null | sed 's/^v//')"
|
2020-04-01 15:33:32 +00:00
|
|
|
BUILD_FLAGS = "-X '$(REPO)/pkg/config.Version=$(VERSION)'"
|
2019-08-26 14:05:17 +00:00
|
|
|
|
2020-01-28 10:03:18 +00:00
|
|
|
IMAGE_REPO=nspccdev/neo-go
|
|
|
|
|
2019-09-09 08:19:57 +00:00
|
|
|
# All of the targets are phony here because we don't really use make dependency
|
|
|
|
# tracking for files
|
|
|
|
.PHONY: build deps image check-version clean-cluster push-tag push-to-registry \
|
|
|
|
run run-cluster test vet lint fmt cover
|
|
|
|
|
2019-08-26 14:26:42 +00:00
|
|
|
build: deps
|
|
|
|
@echo "=> Building binary"
|
|
|
|
@set -x \
|
|
|
|
&& export GOGC=off \
|
|
|
|
&& export CGO_ENABLED=0 \
|
2020-08-06 13:32:36 +00:00
|
|
|
&& go build -trimpath -v -mod=vendor -ldflags $(BUILD_FLAGS) -o ${BINARY} ./cli/main.go
|
2018-02-01 18:06:17 +00:00
|
|
|
|
2019-11-13 12:05:13 +00:00
|
|
|
neo-go.service: neo-go.service.template
|
|
|
|
@sed -r -e 's_BINDIR_$(BINDIR)_' -e 's_UNITWORKDIR_$(UNITWORKDIR)_' -e 's_SYSCONFIGDIR_$(SYSCONFIGDIR)_' $< >$@
|
|
|
|
|
|
|
|
install: build neo-go.service
|
2019-11-06 13:09:07 +00:00
|
|
|
@echo "=> Installing systemd service"
|
2019-11-07 11:57:02 +00:00
|
|
|
@mkdir -p $(DESTDIR)$(SYSCONFIGDIR)/neo-go \
|
|
|
|
&& mkdir -p $(SYSTEMDUNIT_DIR) \
|
|
|
|
&& cp ./neo-go.service $(SYSTEMDUNIT_DIR) \
|
|
|
|
&& cp ./config/protocol.mainnet.yml $(DESTDIR)$(SYSCONFIGDIR)/neo-go \
|
|
|
|
&& cp ./config/protocol.privnet.yml $(DESTDIR)$(SYSCONFIGDIR)/neo-go \
|
|
|
|
&& cp ./config/protocol.testnet.yml $(DESTDIR)$(SYSCONFIGDIR)/neo-go \
|
|
|
|
&& install -m 0755 -t $(BINDIR) $(BINARY) \
|
|
|
|
|
|
|
|
postinst: install
|
|
|
|
@echo "=> Preparing directories and configs"
|
|
|
|
@id neo-go || useradd -s /usr/sbin/nologin -d $(UNITWORKDIR) neo-go \
|
|
|
|
&& mkdir -p $(UNITWORKDIR) \
|
|
|
|
&& chown -R neo-go:neo-go $(UNITWORKDIR) $(BINDIR)/neo-go \
|
|
|
|
&& systemctl enable neo-go.service
|
2019-11-06 13:09:07 +00:00
|
|
|
|
2019-11-15 18:12:37 +00:00
|
|
|
image: deps
|
2019-08-26 14:26:42 +00:00
|
|
|
@echo "=> Building image"
|
2020-01-28 10:03:18 +00:00
|
|
|
@docker build -t $(IMAGE_REPO):latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) .
|
|
|
|
@docker build -t $(IMAGE_REPO):$(VERSION) --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) .
|
|
|
|
|
|
|
|
image-push:
|
|
|
|
@echo "=> Publish image"
|
|
|
|
@docker push $(IMAGE_REPO):latest
|
|
|
|
@docker push $(IMAGE_REPO):$(VERSION)
|
2018-04-28 18:20:27 +00:00
|
|
|
|
2018-02-01 18:54:23 +00:00
|
|
|
check-version:
|
|
|
|
git fetch && (! git rev-list ${VERSION})
|
|
|
|
|
2020-05-22 11:59:51 +00:00
|
|
|
version:
|
|
|
|
@echo ${VERSION}
|
|
|
|
|
2018-02-01 18:06:17 +00:00
|
|
|
deps:
|
2019-08-26 14:26:42 +00:00
|
|
|
@go mod tidy -v
|
|
|
|
@go mod vendor
|
2018-02-01 18:06:17 +00:00
|
|
|
|
2018-02-01 18:54:23 +00:00
|
|
|
push-tag:
|
|
|
|
git checkout ${BRANCH}
|
|
|
|
git pull origin ${BRANCH}
|
|
|
|
git tag ${VERSION}
|
2018-03-15 20:45:37 +00:00
|
|
|
git push origin ${VERSION}
|
2018-02-01 18:54:23 +00:00
|
|
|
|
2018-04-16 08:41:23 +00:00
|
|
|
push-to-registry:
|
|
|
|
@docker login -e ${DOCKER_EMAIL} -u ${DOCKER_USER} -p ${DOCKER_PASS}
|
|
|
|
@docker tag CityOfZion/${REPONAME}:latest CityOfZion/${REPONAME}:${CIRCLE_TAG}
|
|
|
|
@docker push CityOfZion/${REPONAME}:${CIRCLE_TAG}
|
|
|
|
@docker push CityOfZion/${REPONAME}
|
|
|
|
|
2018-03-03 07:16:05 +00:00
|
|
|
run: build
|
2019-08-28 19:05:55 +00:00
|
|
|
${BINARY} node -config-path ./config -${NETMODE}
|
2018-03-03 07:16:05 +00:00
|
|
|
|
2018-02-01 17:40:04 +00:00
|
|
|
test:
|
2018-02-24 07:23:02 +00:00
|
|
|
@go test ./... -cover
|
2018-02-01 18:54:23 +00:00
|
|
|
|
|
|
|
vet:
|
2018-03-03 07:16:05 +00:00
|
|
|
@go vet ./...
|
2019-09-09 08:11:49 +00:00
|
|
|
|
|
|
|
lint:
|
|
|
|
@go list ./... | xargs -L1 golint -set_exit_status
|
|
|
|
|
|
|
|
fmt:
|
|
|
|
@gofmt -l -w -s $$(find . -type f -name '*.go'| grep -v "/vendor/")
|
|
|
|
|
|
|
|
cover:
|
|
|
|
@go test -v -race ./... -coverprofile=coverage.txt -covermode=atomic
|
|
|
|
@go tool cover -html=coverage.txt -o coverage.html
|
2019-11-15 17:41:40 +00:00
|
|
|
|
|
|
|
# --- Environment ---
|
|
|
|
env_vendor:
|
|
|
|
@echo "=> Update vendor"
|
|
|
|
@go mod tidy
|
|
|
|
@go mod download
|
|
|
|
@go mod vendor
|
|
|
|
|
|
|
|
env_image: env_vendor
|
|
|
|
@echo "=> Building env image"
|
|
|
|
@docker build \
|
|
|
|
-t env_neo_go_image \
|
|
|
|
--build-arg REPO=$(REPO) \
|
|
|
|
--build-arg VERSION=$(VERSION) .
|
|
|
|
|
|
|
|
env_up:
|
|
|
|
@echo "=> Bootup environment"
|
2019-11-25 13:33:00 +00:00
|
|
|
@docker-compose -f $(DC_FILE) up -d node_one node_two node_three node_four
|
2019-11-15 17:41:40 +00:00
|
|
|
|
2020-01-13 12:22:21 +00:00
|
|
|
env_single:
|
|
|
|
@echo "=> Bootup environment"
|
|
|
|
@docker-compose -f $(DC_FILE) up -d node_single
|
|
|
|
|
2019-11-15 17:41:40 +00:00
|
|
|
env_down:
|
2019-11-29 09:48:00 +00:00
|
|
|
@echo "=> Stop environment"
|
2019-11-15 17:41:40 +00:00
|
|
|
@docker-compose -f $(DC_FILE) down
|
|
|
|
|
|
|
|
env_restart:
|
2019-11-29 09:48:00 +00:00
|
|
|
@echo "=> Stop and start environment"
|
2019-11-15 17:41:40 +00:00
|
|
|
@docker-compose -f $(DC_FILE) restart
|
|
|
|
|
2019-11-29 09:48:00 +00:00
|
|
|
env_clean: env_down
|
|
|
|
@echo "=> Cleanup environment"
|
|
|
|
@docker volume rm docker_volume_chain
|