diff --git a/Makefile b/Makefile index 4552fcfcf..a8b8b76e3 100644 --- a/Makefile +++ b/Makefile @@ -25,13 +25,14 @@ endef $(error $(NOT_IN_GOPATH_ERROR)) endif -CGO_CFLAGS=-I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin -GOBIN=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin -GIT_COMMIT := $(shell git rev-parse --short HEAD) +CGO_CFLAGS = -I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin +GOBIN = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin +GIT_COMMIT = $(shell git describe --exact-match --tag 2>/dev/null || git rev-parse --short HEAD) +AUTHOR = $(shell echo $$USER) -BUILD_FLAGS ?= $(shell echo "-ldflags '-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X github.com/status-im/status-go/params.VersionMeta=$(GIT_COMMIT)'") +BUILD_FLAGS ?= $(shell echo "-ldflags '-X main.buildStamp=`date -u '+%Y-%m-%d.%H:%M:%S'` -X github.com/status-im/status-go/params.Version=$(GIT_COMMIT)'") -GO ?= latest +XGO_GO ?= latest XGOVERSION ?= 1.10.x XGOIMAGE = statusteam/xgo:$(XGOVERSION) XGOIMAGEIOSSIM = statusteam/xgo-ios-simulator:$(XGOVERSION) @@ -44,7 +45,7 @@ BOOTNODE_IMAGE_NAME ?= statusteam/bootnode PROXY_IMAGE_NAME ?= statusteam/discovery-proxy STATUSD_PRUNE_IMAGE_NAME ?= statusteam/statusd-prune -DOCKER_IMAGE_CUSTOM_TAG ?= $(shell BUILD_TAGS="$(BUILD_TAGS)" ./_assets/ci/get-docker-image-tag.sh) +DOCKER_IMAGE_CUSTOM_TAG ?= $(GIT_COMMIT) DOCKER_TEST_WORKDIR = /go/src/github.com/status-im/status-go/ DOCKER_TEST_IMAGE = golang:1.10 @@ -81,8 +82,12 @@ statusd-prune: ##@statusd-prune Build statusd-prune @echo "Run \"build/bin/statusd-prune -h\" to view available commands." statusd-prune-docker-image: ##@statusd-prune Build statusd-prune docker image - @echo "Building docker image..." - docker build --file _assets/build/Dockerfile-prune . -t $(STATUSD_PRUNE_IMAGE_NAME):latest + @echo "Building docker image for ststusd-prune..." + docker build --file _assets/build/Dockerfile-prune . \ + --label "commit=$(GIT_COMMIT)" \ + --label "author=$(AUTHOR)" \ + -t $(BOOTNODE_IMAGE_NAME):$(DOCKER_IMAGE_CUSTOM_TAG) \ + -t $(STATUSD_PRUNE_IMAGE_NAME):latest bootnode: ##@build Build discovery v5 bootnode using status-go deps go build -i -o $(GOBIN)/bootnode -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/bootnode/ @@ -102,26 +107,26 @@ statusgo-cross: statusgo-android statusgo-ios statusgo-linux: xgo ##@cross-compile Build status-go for Linux ./_assets/patches/patcher -b . -p geth-xgo - $(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=linux/amd64 -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/statusd + $(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(XGO_GO) -out statusgo --dest=$(GOBIN) --targets=linux/amd64 -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/statusd ./_assets/patches/patcher -b . -p geth-xgo -r @echo "Android cross compilation done." statusgo-android: xgo ##@cross-compile Build status-go for Android ./_assets/patches/patcher -b . -p geth-xgo - $(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib + $(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(XGO_GO) -out statusgo --dest=$(GOBIN) --targets=android-16/aar -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib ./_assets/patches/patcher -b . -p geth-xgo -r @echo "Android cross compilation done." statusgo-ios: xgo ##@cross-compile Build status-go for iOS ./_assets/patches/patcher -b . -p geth-xgo - $(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib + $(GOPATH)/bin/xgo --image $(XGOIMAGE) --go=$(XGO_GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib ./_assets/patches/patcher -b . -p geth-xgo -r @echo "iOS framework cross compilation done." statusgo-ios-simulator: xgo ##@cross-compile Build status-go for iOS Simulator @docker pull $(XGOIMAGEIOSSIM) ./_assets/patches/patcher -b . -p geth-xgo - $(GOPATH)/bin/xgo --image $(XGOIMAGEIOSSIM) --go=$(GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib + $(GOPATH)/bin/xgo --image $(XGOIMAGEIOSSIM) --go=$(XGO_GO) -out statusgo --dest=$(GOBIN) --targets=ios-9.3/framework -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./lib ./_assets/patches/patcher -b . -p geth-xgo -r @echo "iOS framework cross compilation done." @@ -136,6 +141,8 @@ docker-image: ##@docker Build docker image (use DOCKER_IMAGE_NAME to set the ima docker build --file _assets/build/Dockerfile . \ --build-arg "build_tags=$(BUILD_TAGS)" \ --build-arg "build_flags=$(BUILD_FLAGS)" \ + --label "commit=$(GIT_COMMIT)" \ + --label "author=$(AUTHOR)" \ -t $(DOCKER_IMAGE_NAME):$(DOCKER_IMAGE_CUSTOM_TAG) \ -t $(DOCKER_IMAGE_NAME):latest @@ -144,6 +151,8 @@ bootnode-image: docker build --file _assets/build/Dockerfile-bootnode . \ --build-arg "build_tags=$(BUILD_TAGS)" \ --build-arg "build_flags=$(BUILD_FLAGS)" \ + --label "commit=$(GIT_COMMIT)" \ + --label "author=$(AUTHOR)" \ -t $(BOOTNODE_IMAGE_NAME):$(DOCKER_IMAGE_CUSTOM_TAG) \ -t $(BOOTNODE_IMAGE_NAME):latest diff --git a/_assets/build/Dockerfile b/_assets/build/Dockerfile index bb49eef92..38ddfa042 100644 --- a/_assets/build/Dockerfile +++ b/_assets/build/Dockerfile @@ -1,11 +1,11 @@ # Build status-go in a Go builder container FROM golang:1.10-alpine as builder +RUN apk add --no-cache make gcc musl-dev linux-headers + ARG build_tags ARG build_flags -RUN apk add --no-cache make gcc musl-dev linux-headers - RUN mkdir -p /go/src/github.com/status-im/status-go ADD . /go/src/github.com/status-im/status-go RUN cd /go/src/github.com/status-im/status-go && \ @@ -16,15 +16,14 @@ RUN cd /go/src/github.com/status-im/status-go && \ # Copy the binary to the second image FROM alpine:latest +LABEL maintainer="support@status.im" LABEL source="https://github.com/status-im/status-go" LABEL description="status-go is an underlying part of Status - a browser, messenger, and gateway to a decentralized world." -LABEL maintainer="support@status.im" RUN apk add --no-cache ca-certificates bash +RUN mkdir -p /static/keys COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/statusd /usr/local/bin/ - -RUN mkdir -p /static/keys COPY --from=builder /go/src/github.com/status-im/status-go/static/keys/* /static/keys/ # 30304 is used for Discovery v5 diff --git a/_assets/build/Dockerfile-bootnode b/_assets/build/Dockerfile-bootnode index 1d5bbca00..6dcd15c3d 100644 --- a/_assets/build/Dockerfile-bootnode +++ b/_assets/build/Dockerfile-bootnode @@ -1,16 +1,24 @@ FROM golang:1.10-alpine as builder -ARG build_tags +RUN apk add --no-cache make gcc musl-dev linux-headers git -RUN apk add --no-cache make gcc musl-dev linux-headers +ARG build_tags +ARG build_flags RUN mkdir -p /go/src/github.com/status-im/status-go ADD . /go/src/github.com/status-im/status-go -RUN cd /go/src/github.com/status-im/status-go && make bootnode BUILD_TAGS="$build_tags" +RUN cd /go/src/github.com/status-im/status-go && \ + make bootnode \ + BUILD_TAGS="$build_tags" \ + BUILD_FLAGS="$build_flags" FROM alpine:latest +LABEL maintainer="support@status.im" +LABEL source="https://github.com/status-im/status-go" +LABEL description="bootnode is an Ethereum bootnode with patched Discovery V5." + RUN apk add --no-cache ca-certificates bash COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/bootnode /usr/local/bin/ -ENTRYPOINT /usr/local/bin/bootnode \ No newline at end of file +ENTRYPOINT /usr/local/bin/bootnode diff --git a/_assets/build/Dockerfile-prune b/_assets/build/Dockerfile-prune index d4e0fd009..24c8555a5 100644 --- a/_assets/build/Dockerfile-prune +++ b/_assets/build/Dockerfile-prune @@ -10,6 +10,10 @@ RUN cd /go/src/github.com/status-im/status-go && make statusd-prune # Copy the binary to the second image FROM alpine:latest +LABEL maintainer="support@status.im" +LABEL source="https://github.com/status-im/status-go" +LABEL description="statusd-prune is used to prune old messages stored by MailServer." + RUN apk add --no-cache ca-certificates bash COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/statusd-prune /usr/local/bin/ diff --git a/_assets/ci/get-docker-image-tag.sh b/_assets/ci/get-docker-image-tag.sh deleted file mode 100755 index 6183e11ec..000000000 --- a/_assets/ci/get-docker-image-tag.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash -# -# Creates a string in a format: $GIT_SHA[:8][-$BUILD_TAGS] -# where $BUILD_TAGS is optional and if present all spaces -# are replaced by a hyphen (-). -# -# For example: BUILD_TAGS="tag1 tag2" ./_assets/ci/get-docker-image-tag.sh -# will produce "12345678-tag1-tag2". - -set -e -o pipefail - -tag="$(git rev-parse HEAD | cut -c 1-8)" - -if [ ! -z "$BUILD_TAGS" ]; then - tag="$tag-$(echo $BUILD_TAGS | sed -e "s/[[:space:]]/-/g")" -fi - -echo $tag diff --git a/params/version.go b/params/version.go index 5867402c6..f6c613c9a 100644 --- a/params/version.go +++ b/params/version.go @@ -1,22 +1,4 @@ package params -import ( - "fmt" -) - -const ( - // VersionMajor is a major version component of the current release - VersionMajor = 0 - - // VersionMinor is a minor version component of the current release - VersionMinor = 9 - - // VersionPatch is a patch version component of the current release - VersionPatch = 9 -) - -// VersionMeta is metadata to append to the version string -var VersionMeta string // rely on linker: -ldflags -X github.com/status-im/status-go/params.VersionMeta" - -// Version exposes string representation of program version. -var Version = fmt.Sprintf("%d.%d.%d-%s", VersionMajor, VersionMinor, VersionPatch, VersionMeta) +// Version relies on a git tag and is passed by linker's '-ldflags' flag. +var Version string