Add labels to docker images and add Jenkinsfile to build docker images (#1160)
* fixed generating `params.Version` * added labels to all Docker images including git_commit and the author of the build (using `$USER` env variable)
This commit is contained in:
parent
2cfcde0283
commit
16c7b94eb5
33
Makefile
33
Makefile
|
@ -25,13 +25,14 @@ endef
|
||||||
$(error $(NOT_IN_GOPATH_ERROR))
|
$(error $(NOT_IN_GOPATH_ERROR))
|
||||||
endif
|
endif
|
||||||
|
|
||||||
CGO_CFLAGS=-I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin
|
CGO_CFLAGS = -I/$(JAVA_HOME)/include -I/$(JAVA_HOME)/include/darwin
|
||||||
GOBIN=$(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin
|
GOBIN = $(dir $(realpath $(firstword $(MAKEFILE_LIST))))build/bin
|
||||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
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
|
XGOVERSION ?= 1.10.x
|
||||||
XGOIMAGE = statusteam/xgo:$(XGOVERSION)
|
XGOIMAGE = statusteam/xgo:$(XGOVERSION)
|
||||||
XGOIMAGEIOSSIM = statusteam/xgo-ios-simulator:$(XGOVERSION)
|
XGOIMAGEIOSSIM = statusteam/xgo-ios-simulator:$(XGOVERSION)
|
||||||
|
@ -44,7 +45,7 @@ BOOTNODE_IMAGE_NAME ?= statusteam/bootnode
|
||||||
PROXY_IMAGE_NAME ?= statusteam/discovery-proxy
|
PROXY_IMAGE_NAME ?= statusteam/discovery-proxy
|
||||||
STATUSD_PRUNE_IMAGE_NAME ?= statusteam/statusd-prune
|
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_WORKDIR = /go/src/github.com/status-im/status-go/
|
||||||
DOCKER_TEST_IMAGE = golang:1.10
|
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."
|
@echo "Run \"build/bin/statusd-prune -h\" to view available commands."
|
||||||
|
|
||||||
statusd-prune-docker-image: ##@statusd-prune Build statusd-prune docker image
|
statusd-prune-docker-image: ##@statusd-prune Build statusd-prune docker image
|
||||||
@echo "Building docker image..."
|
@echo "Building docker image for ststusd-prune..."
|
||||||
docker build --file _assets/build/Dockerfile-prune . -t $(STATUSD_PRUNE_IMAGE_NAME):latest
|
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
|
bootnode: ##@build Build discovery v5 bootnode using status-go deps
|
||||||
go build -i -o $(GOBIN)/bootnode -v -tags '$(BUILD_TAGS)' $(BUILD_FLAGS) ./cmd/bootnode/
|
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
|
statusgo-linux: xgo ##@cross-compile Build status-go for Linux
|
||||||
./_assets/patches/patcher -b . -p geth-xgo
|
./_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
|
./_assets/patches/patcher -b . -p geth-xgo -r
|
||||||
@echo "Android cross compilation done."
|
@echo "Android cross compilation done."
|
||||||
|
|
||||||
statusgo-android: xgo ##@cross-compile Build status-go for Android
|
statusgo-android: xgo ##@cross-compile Build status-go for Android
|
||||||
./_assets/patches/patcher -b . -p geth-xgo
|
./_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
|
./_assets/patches/patcher -b . -p geth-xgo -r
|
||||||
@echo "Android cross compilation done."
|
@echo "Android cross compilation done."
|
||||||
|
|
||||||
statusgo-ios: xgo ##@cross-compile Build status-go for iOS
|
statusgo-ios: xgo ##@cross-compile Build status-go for iOS
|
||||||
./_assets/patches/patcher -b . -p geth-xgo
|
./_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
|
./_assets/patches/patcher -b . -p geth-xgo -r
|
||||||
@echo "iOS framework cross compilation done."
|
@echo "iOS framework cross compilation done."
|
||||||
|
|
||||||
statusgo-ios-simulator: xgo ##@cross-compile Build status-go for iOS Simulator
|
statusgo-ios-simulator: xgo ##@cross-compile Build status-go for iOS Simulator
|
||||||
@docker pull $(XGOIMAGEIOSSIM)
|
@docker pull $(XGOIMAGEIOSSIM)
|
||||||
./_assets/patches/patcher -b . -p geth-xgo
|
./_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
|
./_assets/patches/patcher -b . -p geth-xgo -r
|
||||||
@echo "iOS framework cross compilation done."
|
@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 . \
|
docker build --file _assets/build/Dockerfile . \
|
||||||
--build-arg "build_tags=$(BUILD_TAGS)" \
|
--build-arg "build_tags=$(BUILD_TAGS)" \
|
||||||
--build-arg "build_flags=$(BUILD_FLAGS)" \
|
--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):$(DOCKER_IMAGE_CUSTOM_TAG) \
|
||||||
-t $(DOCKER_IMAGE_NAME):latest
|
-t $(DOCKER_IMAGE_NAME):latest
|
||||||
|
|
||||||
|
@ -144,6 +151,8 @@ bootnode-image:
|
||||||
docker build --file _assets/build/Dockerfile-bootnode . \
|
docker build --file _assets/build/Dockerfile-bootnode . \
|
||||||
--build-arg "build_tags=$(BUILD_TAGS)" \
|
--build-arg "build_tags=$(BUILD_TAGS)" \
|
||||||
--build-arg "build_flags=$(BUILD_FLAGS)" \
|
--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):$(DOCKER_IMAGE_CUSTOM_TAG) \
|
||||||
-t $(BOOTNODE_IMAGE_NAME):latest
|
-t $(BOOTNODE_IMAGE_NAME):latest
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
# Build status-go in a Go builder container
|
# Build status-go in a Go builder container
|
||||||
FROM golang:1.10-alpine as builder
|
FROM golang:1.10-alpine as builder
|
||||||
|
|
||||||
|
RUN apk add --no-cache make gcc musl-dev linux-headers
|
||||||
|
|
||||||
ARG build_tags
|
ARG build_tags
|
||||||
ARG build_flags
|
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
|
RUN mkdir -p /go/src/github.com/status-im/status-go
|
||||||
ADD . /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 && \
|
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
|
# Copy the binary to the second image
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
|
|
||||||
|
LABEL maintainer="support@status.im"
|
||||||
LABEL source="https://github.com/status-im/status-go"
|
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 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 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/
|
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/
|
COPY --from=builder /go/src/github.com/status-im/status-go/static/keys/* /static/keys/
|
||||||
|
|
||||||
# 30304 is used for Discovery v5
|
# 30304 is used for Discovery v5
|
||||||
|
|
|
@ -1,15 +1,23 @@
|
||||||
FROM golang:1.10-alpine as builder
|
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
|
RUN mkdir -p /go/src/github.com/status-im/status-go
|
||||||
ADD . /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
|
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
|
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/
|
COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/bootnode /usr/local/bin/
|
||||||
|
|
|
@ -10,6 +10,10 @@ RUN cd /go/src/github.com/status-im/status-go && make statusd-prune
|
||||||
# Copy the binary to the second image
|
# Copy the binary to the second image
|
||||||
FROM alpine:latest
|
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
|
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/
|
COPY --from=builder /go/src/github.com/status-im/status-go/build/bin/statusd-prune /usr/local/bin/
|
||||||
|
|
|
@ -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
|
|
|
@ -1,22 +1,4 @@
|
||||||
package params
|
package params
|
||||||
|
|
||||||
import (
|
// Version relies on a git tag and is passed by linker's '-ldflags' flag.
|
||||||
"fmt"
|
var Version string
|
||||||
)
|
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
Loading…
Reference in New Issue