2018-08-31 16:21:44 +01:00
|
|
|
.PHONY: test lint proto check-copyrights build-dev-deps
|
2018-04-25 15:55:26 +01:00
|
|
|
|
2018-08-22 03:54:56 +01:00
|
|
|
|
2018-08-31 16:21:44 +01:00
|
|
|
GO_VERSION ?= 1.11
|
|
|
|
GOOS ?= linux
|
|
|
|
GOARCH ?= amd64
|
2018-07-25 22:47:02 +01:00
|
|
|
COMPOSE_PROJECT_NAME := ${TAG}-$(shell git rev-parse --abbrev-ref HEAD)
|
2018-08-22 03:54:56 +01:00
|
|
|
BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
|
|
|
|
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
|
2018-08-31 16:21:44 +01:00
|
|
|
CUSTOMTAG ?=
|
2018-07-25 22:47:02 +01:00
|
|
|
|
2018-08-31 16:21:44 +01:00
|
|
|
FILEEXT :=
|
|
|
|
ifeq (${GOOS},windows)
|
|
|
|
FILEEXT := .exe
|
|
|
|
endif
|
|
|
|
|
|
|
|
DOCKER_BUILD := docker build \
|
2018-09-07 20:46:08 +01:00
|
|
|
--build-arg GO_VERSION=${GO_VERSION}
|
2018-06-21 20:36:39 +01:00
|
|
|
|
2018-04-23 17:05:52 +01:00
|
|
|
lint: check-copyrights
|
|
|
|
@echo "Running ${@}"
|
2018-09-11 14:13:25 +01:00
|
|
|
@golangci-lint run
|
2018-04-12 14:50:22 +01:00
|
|
|
|
2018-04-23 17:05:52 +01:00
|
|
|
check-copyrights:
|
|
|
|
@echo "Running ${@}"
|
|
|
|
@./scripts/check-for-header.sh
|
|
|
|
|
2018-06-13 19:22:32 +01:00
|
|
|
# Applies goimports to every go file (excluding vendored files)
|
|
|
|
goimports-fix:
|
|
|
|
goimports -w $$(find . -type f -name '*.go' -not -path "*/vendor/*")
|
|
|
|
|
2018-04-12 14:50:22 +01:00
|
|
|
proto:
|
|
|
|
@echo "Running ${@}"
|
2018-04-17 18:29:15 +01:00
|
|
|
./scripts/build-protos.sh
|
|
|
|
|
|
|
|
build-dev-deps:
|
2018-06-26 12:48:02 +01:00
|
|
|
go get github.com/mattn/goveralls
|
2018-08-01 15:15:38 +01:00
|
|
|
go get golang.org/x/tools/cover
|
2018-06-26 12:48:02 +01:00
|
|
|
go get github.com/modocache/gover
|
2018-09-11 14:13:25 +01:00
|
|
|
curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | bash -s -- -b ${GOPATH}/bin v1.10.2
|
2018-04-25 15:55:26 +01:00
|
|
|
|
2018-09-11 14:13:25 +01:00
|
|
|
test:
|
|
|
|
go test -race -v -cover -coverprofile=.coverprofile ./...
|
2018-05-09 00:01:46 +01:00
|
|
|
@echo done
|
2018-06-05 22:06:37 +01:00
|
|
|
|
2018-08-14 17:58:16 +01:00
|
|
|
test-captplanet:
|
|
|
|
@echo "Running ${@}"
|
|
|
|
@./scripts/test-captplanet.sh
|
|
|
|
|
2018-07-25 22:47:02 +01:00
|
|
|
test-docker:
|
|
|
|
docker-compose up -d --remove-orphans test
|
|
|
|
docker-compose run test make test
|
|
|
|
|
|
|
|
test-docker-clean:
|
|
|
|
-docker-compose down --rmi all
|
|
|
|
|
2018-08-31 16:21:44 +01:00
|
|
|
images: satellite-image storagenode-image uplink-image
|
2018-08-23 16:48:03 +01:00
|
|
|
echo Built version: ${TAG}
|
|
|
|
|
|
|
|
.PHONY: satellite-image
|
|
|
|
satellite-image:
|
2018-08-31 16:21:44 +01:00
|
|
|
${DOCKER_BUILD} -t storjlabs/satellite:${TAG}${CUSTOMTAG} -f cmd/satellite/Dockerfile .
|
|
|
|
.PHONY: storagenode-image
|
|
|
|
storagenode-image:
|
|
|
|
${DOCKER_BUILD} -t storjlabs/storagenode:${TAG}${CUSTOMTAG} -f cmd/storagenode/Dockerfile .
|
2018-08-23 16:48:03 +01:00
|
|
|
.PHONY: uplink-image
|
|
|
|
uplink-image:
|
2018-08-31 16:21:44 +01:00
|
|
|
${DOCKER_BUILD} -t storjlabs/uplink:${TAG}${CUSTOMTAG} -f cmd/uplink/Dockerfile .
|
2018-08-23 16:48:03 +01:00
|
|
|
|
|
|
|
.PHONY: all-in-one
|
|
|
|
all-in-one:
|
|
|
|
if [ -z "${VERSION}" ]; then \
|
|
|
|
$(MAKE) images -j 3 \
|
|
|
|
&& export VERSION="${TAG}"; \
|
|
|
|
fi \
|
2018-08-31 16:21:44 +01:00
|
|
|
&& docker-compose up -d storagenode \
|
2018-08-23 16:48:03 +01:00
|
|
|
&& scripts/fix-mock-overlay \
|
2018-08-31 16:21:44 +01:00
|
|
|
&& docker-compose up storagenode satellite uplink
|
2018-06-21 20:36:39 +01:00
|
|
|
|
|
|
|
push-images:
|
2018-08-22 03:54:56 +01:00
|
|
|
docker tag storjlabs/satellite:${TAG} storjlabs/satellite:latest
|
|
|
|
docker push storjlabs/satellite:${TAG}
|
2018-08-08 18:48:59 +01:00
|
|
|
docker push storjlabs/satellite:latest
|
2018-08-31 16:21:44 +01:00
|
|
|
docker tag storjlabs/storagenode:${TAG} storjlabs/storagenode:latest
|
|
|
|
docker push storjlabs/storagenode:${TAG}
|
|
|
|
docker push storjlabs/storagenode:latest
|
2018-08-23 16:48:03 +01:00
|
|
|
docker tag storjlabs/uplink:${TAG} storjlabs/uplink:latest
|
|
|
|
docker push storjlabs/uplink:${TAG}
|
|
|
|
docker push storjlabs/uplink:latest
|
2018-06-22 21:17:37 +01:00
|
|
|
|
2018-08-22 03:54:56 +01:00
|
|
|
ifeq (${BRANCH},master)
|
2018-07-13 16:02:33 +01:00
|
|
|
clean-images:
|
2018-08-22 03:54:56 +01:00
|
|
|
-docker rmi storjlabs/satellite:${TAG} storjlabs/satellite:latest
|
2018-08-31 16:21:44 +01:00
|
|
|
-docker rmi storjlabs/storagenode:${TAG} storjlabs/storagenode:latest
|
2018-08-23 16:48:03 +01:00
|
|
|
-docker rmi storjlabs/uplink:${TAG} storjlabs/uplink:latest
|
2018-08-22 03:54:56 +01:00
|
|
|
else
|
|
|
|
clean-images:
|
|
|
|
-docker rmi storjlabs/satellite:${TAG}
|
2018-08-31 16:21:44 +01:00
|
|
|
-docker rmi storjlabs/storagenode:${TAG}
|
2018-08-23 16:48:03 +01:00
|
|
|
-docker rmi storjlabs/uplink:${TAG}
|
2018-08-22 03:54:56 +01:00
|
|
|
endif
|
2018-07-13 16:02:33 +01:00
|
|
|
|
2018-06-22 21:17:37 +01:00
|
|
|
install-deps:
|
|
|
|
go get -u -v golang.org/x/vgo
|
2018-07-13 16:02:33 +01:00
|
|
|
cd vgo install ./...
|
2018-08-23 22:04:51 +01:00
|
|
|
|
|
|
|
.PHONY: deploy
|
|
|
|
deploy:
|
2018-10-08 17:52:27 +01:00
|
|
|
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}\"}]}}}}" ; \
|
2018-08-23 22:04:51 +01:00
|
|
|
done
|
2018-10-08 17:52:27 +01:00
|
|
|
kubectl --context nonprod --namespace v3 patch deployment satellite -p"{\"spec\":{\"template\":{\"spec\":{\"containers\":[{\"name\":\"satellite\",\"image\":\"storjlabs/satellite:${TAG}\"}]}}}}"
|
2018-08-27 22:06:55 +01:00
|
|
|
|
2018-08-31 16:21:44 +01:00
|
|
|
.PHONY: binary
|
|
|
|
binary: CUSTOMTAG = -${GOOS}-${GOARCH}
|
|
|
|
binary:
|
2018-09-05 21:40:47 +01:00
|
|
|
@if [ -z "${COMPONENT}" ]; then echo "Try one of the following targets instead:" \
|
|
|
|
&& for b in binaries ${BINARIES}; do echo "- $$b"; done && exit 1; fi
|
2018-08-31 16:21:44 +01:00
|
|
|
mkdir -p release/${TAG}
|
2018-09-05 21:40:47 +01:00
|
|
|
tar -c . | docker run --rm -i -e TAR=1 -e GO111MODULE=on \
|
|
|
|
-e GOOS=${GOOS} -e GOARCH=${GOARCH} -e CGO_ENABLED=1 \
|
|
|
|
-w /go/src/storj.io/storj 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-08-31 16:21:44 +01:00
|
|
|
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-09-05 21:40:47 +01:00
|
|
|
.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
|
|
|
|
|
|
|
|
COMPONENTLIST := uplink satellite storagenode
|
|
|
|
OSARCHLIST := linux_amd64 windows_amd64 darwin_amd64
|
|
|
|
BINARIES := $(foreach C,$(COMPONENTLIST),$(foreach O,$(OSARCHLIST),$C_$O))
|
2018-08-31 16:21:44 +01:00
|
|
|
.PHONY: binaries
|
2018-09-05 21:40:47 +01:00
|
|
|
binaries: ${BINARIES}
|
2018-08-31 16:21:44 +01:00
|
|
|
|
|
|
|
.PHONY: binaries-upload
|
|
|
|
binaries-upload:
|
|
|
|
cd release; gsutil -m cp -r . gs://storj-v3-alpha-builds
|
|
|
|
|
|
|
|
.PHONY: binaries-clean
|
|
|
|
binaries-clean:
|
|
|
|
rm -rf release
|
|
|
|
|
|
|
|
clean: test-docker-clean binaries-clean clean-images
|