neo-go/Makefile

100 lines
3 KiB
Makefile
Raw Normal View History

2018-02-01 18:54:23 +00:00
BRANCH = "master"
REPONAME = "neo-go"
NETMODE ?= "privnet"
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
REPO ?= "$(shell go list -m)"
VERSION ?= "$(shell git describe --tags 2>/dev/null | sed 's/^v//')"
BUILD_FLAGS = "-X $(REPO)/config.Version=$(VERSION)"
# 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
build: deps
@echo "=> Building binary"
@set -x \
&& export GOGC=off \
&& export CGO_ENABLED=0 \
&& go build -v -mod=vendor -ldflags $(BUILD_FLAGS) -o ${BINARY} ./cli/main.go
2018-02-01 18:06:17 +00:00
install: build
@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
image:
@echo "=> Building image"
@docker build -t cityofzion/neo-go:latest --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) .
@docker build -t cityofzion/neo-go:$(VERSION) --build-arg REPO=$(REPO) --build-arg VERSION=$(VERSION) .
2018-02-01 18:54:23 +00:00
check-version:
git fetch && (! git rev-list ${VERSION})
clean-cluster:
@echo "=> Removing all containers and chain storage"
@rm -rf chains/privnet-docker-one chains/privnet-docker-two chains/privnet-docker-three chains/privnet-docker-four
@docker-compose stop
@docker-compose rm -f
2018-02-01 18:06:17 +00:00
deps:
@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}
git push origin ${VERSION}
2018-02-01 18:54: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}
run: build
${BINARY} node -config-path ./config -${NETMODE}
run-cluster: build-linux
@echo "=> Starting docker-compose cluster"
@echo "=> Building container image"
@docker-compose build
@docker-compose up -d
@echo "=> Tailing logs, exiting this prompt will not stop the cluster"
@docker-compose logs -f
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:
@go vet ./...
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