storj/Makefile

203 lines
7.5 KiB
Makefile
Raw Normal View History

GO_VERSION ?= 1.11
GOOS ?= linux
GOARCH ?= amd64
COMPOSE_PROJECT_NAME := ${TAG}-$(shell git rev-parse --abbrev-ref HEAD)
BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed "s!/!-!g")
ifeq (${BRANCH},master)
TAG := $(shell git rev-parse --short HEAD)-go${GO_VERSION}
else
TAG := $(shell git rev-parse --short HEAD)-${BRANCH}-go${GO_VERSION}
endif
CUSTOMTAG ?=
FILEEXT :=
ifeq (${GOOS},windows)
FILEEXT := .exe
endif
DOCKER_BUILD := docker build \
--build-arg GO_VERSION=${GO_VERSION}
2018-10-16 19:47:43 +01:00
.DEFAULT_GOAL := help
.PHONY: help
help:
@awk 'BEGIN { \
FS = ":.*##"; \
printf "\nUsage:\n make \033[36m<target>\033[0m\n"\
} \
/^[a-zA-Z_-]+:.*?##/ { \
printf " \033[36m%-17s\033[0m %s\n", $$1, $$2 \
} \
/^##@/ { \
printf "\n\033[1m%s\033[0m\n", substr($$0, 5) \
} ' $(MAKEFILE_LIST)
##@ Dependencies
.PHONY: build-dev-deps
build-dev-deps: ## Install dependencies for builds
go get github.com/mattn/goveralls
go get golang.org/x/tools/cover
go get github.com/modocache/gover
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin v1.10.2
.PHONY: lint
lint: check-copyrights ## Analyze and find programs in source code
@echo "Running ${@}"
@golangci-lint run
2018-04-12 14:50:22 +01:00
2018-10-16 19:47:43 +01:00
.PHONY: check-copyrights
check-copyrights: ## Check source files for copyright headers
@echo "Running ${@}"
@go run ./scripts/check-copyright.go
2018-10-16 19:47:43 +01:00
.PHONY: goimports-fix
goimports-fix: ## Applies goimports to every go file (excluding vendored files)
2018-12-07 13:44:25 +00:00
goimports -w -local storj.io $$(find . -type f -name '*.go' -not -path "*/vendor/*")
2018-10-16 19:47:43 +01:00
.PHONY: proto
proto: ## Rebuild protobuf files
2018-04-12 14:50:22 +01:00
@echo "Running ${@}"
2018-11-30 15:02:01 +00:00
go run scripts/protobuf.go install
go run scripts/protobuf.go generate
2018-04-17 18:29:15 +01:00
2018-10-16 19:47:43 +01:00
##@ Test
2018-04-25 15:55:26 +01:00
2018-10-16 19:47:43 +01:00
.PHONY: test
test: ## Run tests on source code (travis)
go test -race -v -cover -coverprofile=.coverprofile ./...
2018-05-09 00:01:46 +01:00
@echo done
Cache (#67) * add reference to dht to overlay client struct * wip * wip * Implement FindNode * get nodes * WIP * Merge in Dennis kademlia code, get it working with our code * ping and moar * WIP trying to get cache working with kademlia * WIP more wiring up * WIP * Update service cli commands * WIP * added GetNodes * added nodes to Kbucket * default transport changed to TCP * GetBuckets interface changed * filling in more routing * timestamp methods * removed store * Added initial network overlay explorer page * Updating and building with dockerfile * Working on adding bootstrap node code * WIP merging in dennis' code * WIP * connects cache to pkg/kademlia implementation * WIP redis cache * testing * Add bootstrap network function for CLI usage * cleanup * call bootstrap on init network * Add BootstrapNetwork function to interface * Merge in dennis kad code * WIP updates to redis/overlay client interface * WIP trying to get the DHT connected to the cache * go mod & test * deps * Bootstrap node now setting up correctly - Need to pass it through CLI commands better * WIP adding refresh and walk functions, added cli flags - added cli flags for custom bootstrap port and ip * PR comments addressed * adding FindStorageNodes to overlay cache * fix GetBucket * using SplitHostPort * Use JoinHostPort * updates to findstoragenodes response and request * WIP merge in progress, having issues with a panic * wip * adjustments * update port for dht bootstrap test * Docker * wip * dockerfile * fixes * makefile changes * Update port in NewKademlia call * Update local kademlia DHT config * kubernetes yaml * cleanup * making tests pass * k8s yaml * lint issues * Edit cli flags to allow for configurable bootstrap IP and Port args * cleanup * cache walking the network now * Rough prototype of Walk function laid out * Move walk function into bootstrap function * Update dht.go * changes to yaml * goimports
2018-06-05 22:06:37 +01:00
2018-10-16 19:47:43 +01:00
.PHONY: test-captplanet
test-captplanet: ## Test source with captain planet (travis)
@echo "Running ${@}"
@./scripts/test-captplanet.sh
2018-10-16 19:47:43 +01:00
.PHONY: test-docker
test-docker: ## Run tests in Docker
docker-compose up -d --remove-orphans test
docker-compose run test make test
.PHONY: all-in-one
2018-10-16 19:47:43 +01:00
all-in-one: ## Deploy docker images with one storagenode locally
if [ -z "${VERSION}" ]; then \
$(MAKE) satellite-image storagenode-image gateway-image -j 3 \
&& export VERSION="${TAG}"; \
fi \
&& docker-compose up storagenode satellite gateway
2018-10-16 19:47:43 +01:00
##@ Build
2018-10-16 19:47:43 +01:00
.PHONY: images
images: satellite-image storagenode-image uplink-image gateway-image ## Build gateway, satellite, storagenode, and uplink Docker images
2018-10-16 19:47:43 +01:00
echo Built version: ${TAG}
.PHONY: gateway-image
gateway-image: ## Build gateway Docker image
${DOCKER_BUILD} -t storjlabs/gateway:${TAG}${CUSTOMTAG} -f cmd/gateway/Dockerfile .
2018-10-16 19:47:43 +01:00
.PHONY: satellite-image
satellite-image: ## Build satellite Docker image
${DOCKER_BUILD} -t storjlabs/satellite:${TAG}${CUSTOMTAG} -f cmd/satellite/Dockerfile .
.PHONY: storagenode-image
storagenode-image: ## Build storagenode Docker image
${DOCKER_BUILD} -t storjlabs/storagenode:${TAG}${CUSTOMTAG} -f cmd/storagenode/Dockerfile .
.PHONY: uplink-image
uplink-image: ## Build uplink Docker image
${DOCKER_BUILD} -t storjlabs/uplink:${TAG}${CUSTOMTAG} -f cmd/uplink/Dockerfile .
.PHONY: binary
binary: CUSTOMTAG = -${GOOS}-${GOARCH}
binary:
@if [ -z "${COMPONENT}" ]; then echo "Try one of the following targets instead:" \
&& for b in binaries ${BINARIES}; do echo "- $$b"; done && exit 1; fi
mkdir -p release/${TAG}
rm -f cmd/${COMPONENT}/resource.syso
if [ "${GOARCH}" = "amd64" ]; then sixtyfour="-64"; fi; \
2018-11-26 14:11:09 +00:00
[ "${GOARCH}" = "amd64" ] && goversioninfo $$sixtyfour -o cmd/${COMPONENT}/resource.syso \
-original-name ${COMPONENT}_${GOOS}_${GOARCH}${FILEEXT} \
-description "${COMPONENT} program for Storj" \
-product-ver-build 2 -ver-build 2 \
-product-version "alpha2" \
resources/versioninfo.json || echo "goversioninfo is not installed, metadata will not be created"
tar -c . | docker run --rm -i -e TAR=1 -e GO111MODULE=on \
2018-11-26 14:11:09 +00:00
-e GOOS=${GOOS} -e GOARCH=${GOARCH} -e GOARM=6 -e CGO_ENABLED=1 \
-w /go/src/storj.io/storj -e GOPROXY storjlabs/golang \
-o app storj.io/storj/cmd/${COMPONENT} \
| tar -O -x ./app > release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT}
chmod 755 release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT}
2018-10-17 19:21:18 +01:00
[ "${FILEEXT}" = ".exe" ] && storj-sign release/${TAG}/$(COMPONENT)_${GOOS}_${GOARCH}${FILEEXT} || echo "Skipping signing"
rm -f release/${TAG}/${COMPONENT}_${GOOS}_${GOARCH}.zip
cd release/${TAG}; zip ${COMPONENT}_${GOOS}_${GOARCH}.zip ${COMPONENT}_${GOOS}_${GOARCH}${FILEEXT}
rm -f release/${TAG}/${COMPONENT}_${GOOS}_${GOARCH}${FILEEXT}
2018-11-07 18:19:09 +00:00
.PHONY: gateway_%
gateway_%:
GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=gateway $(MAKE) binary
.PHONY: satellite_%
satellite_%:
GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=satellite $(MAKE) binary
.PHONY: storagenode_%
storagenode_%:
GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=storagenode $(MAKE) binary
.PHONY: uplink_%
uplink_%:
GOOS=$(word 2, $(subst _, ,$@)) GOARCH=$(word 3, $(subst _, ,$@)) COMPONENT=uplink $(MAKE) binary
2018-11-07 18:19:09 +00:00
COMPONENTLIST := gateway satellite storagenode uplink
2018-11-26 14:11:09 +00:00
OSARCHLIST := darwin_amd64 linux_amd64 linux_arm windows_amd64
BINARIES := $(foreach C,$(COMPONENTLIST),$(foreach O,$(OSARCHLIST),$C_$O))
.PHONY: binaries
2018-11-07 18:19:09 +00:00
binaries: ${BINARIES} ## Build gateway, satellite, storagenode, and uplink binaries (jenkins)
2018-10-16 19:47:43 +01:00
##@ Deploy
.PHONY: deploy
deploy: ## Update Kubernetes deployments in staging (jenkins)
for deployment in $$(kubectl --context nonprod -n v3 get deployment -l app=storagenode --output=jsonpath='{.items..metadata.name}'); do \
kubectl --context nonprod --namespace v3 patch deployment $$deployment -p"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"storagenode\",\"image\":\"storjlabs/storagenode:${TAG}\"}]}}}}" ; \
done
kubectl --context nonprod --namespace v3 patch deployment satellite -p"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"satellite\",\"image\":\"storjlabs/satellite:${TAG}\"}]}}}}"
.PHONY: push-images
push-images: ## Push Docker images to Docker Hub (jenkins)
docker tag storjlabs/satellite:${TAG} storjlabs/satellite:latest
docker push storjlabs/satellite:${TAG}
docker push storjlabs/satellite:latest
docker tag storjlabs/storagenode:${TAG} storjlabs/storagenode:latest
docker push storjlabs/storagenode:${TAG}
docker push storjlabs/storagenode:latest
docker tag storjlabs/uplink:${TAG} storjlabs/uplink:latest
docker push storjlabs/uplink:${TAG}
docker push storjlabs/uplink:latest
.PHONY: binaries-upload
2018-10-16 19:47:43 +01:00
binaries-upload: ## Upload binaries to Google Storage (jenkins)
cd release; gsutil -m cp -r . gs://storj-v3-alpha-builds
2018-10-16 19:47:43 +01:00
##@ Clean
.PHONY: clean
clean: test-docker-clean binaries-clean clean-images ## Clean docker test environment, local release binaries, and local Docker images
.PHONY: binaries-clean
2018-10-16 19:47:43 +01:00
binaries-clean: ## Remove all local release binaries (jenkins)
rm -rf release
2018-10-16 19:47:43 +01:00
.PHONY: clean-images
ifeq (${BRANCH},master)
clean-images: ## Remove Docker images from local engine
-docker rmi storjlabs/satellite:${TAG} storjlabs/satellite:latest
-docker rmi storjlabs/storagenode:${TAG} storjlabs/storagenode:latest
-docker rmi storjlabs/uplink:${TAG} storjlabs/uplink:latest
else
clean-images:
-docker rmi storjlabs/satellite:${TAG}
-docker rmi storjlabs/storagenode:${TAG}
-docker rmi storjlabs/uplink:${TAG}
endif
.PHONY: test-docker-clean
test-docker-clean: ## Clean up Docker environment used in test-docker target
-docker-compose down --rmi all