From 5841065420a1ed8509dd8f0b47fe11507a15993b Mon Sep 17 00:00:00 2001 From: Matt Robinson Date: Tue, 21 Aug 2018 22:54:56 -0400 Subject: [PATCH] Attempt to fix jenkins builds (#260) * Attempt to clean up docker image tags * Clean only master * Add back go version and actually use it --- Jenkinsfile | 6 ++++-- Makefile | 28 ++++++++++++++++++++-------- cmd/farmer/Dockerfile | 6 +++--- cmd/hc/Dockerfile | 3 ++- 4 files changed, 29 insertions(+), 14 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a80393e86..7420f818a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -10,8 +10,10 @@ node('node') { } stage('Push Images') { - echo 'Push to Repo' - sh 'make push-images' + if (env.BRANCH_NAME == "master") { + echo 'Push to Repo' + sh 'make push-images' + } } stage('Deploy') { diff --git a/Makefile b/Makefile index ab8a6c719..587685c57 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,15 @@ .PHONY: test lint proto check-copyrights build-dev-deps -TAG := $$(git rev-parse --short HEAD) -GO_VERSION := 1.10 + +GO_VERSION ?= 1.10 COMPOSE_PROJECT_NAME := ${TAG}-$(shell git rev-parse --abbrev-ref HEAD) GO_DIRS := $(shell go list ./... | grep -v storj.io/storj/examples) +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 lint: check-copyrights @@ -93,20 +99,26 @@ test-docker-clean: -docker-compose down --rmi all images: - docker build --build-arg VERSION=${GO_VERSION} -t storjlabs/satellite:${TAG}-${GO_VERSION} -f cmd/hc/Dockerfile . - docker tag storjlabs/satellite:${TAG}-${GO_VERSION} storjlabs/satellite:latest - docker build -t storjlabs/storage-node:${TAG} -f cmd/farmer/Dockerfile . - docker tag storjlabs/storage-node:${TAG} storjlabs/storage-node:latest + docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/satellite:${TAG} -f cmd/hc/Dockerfile . + docker build --build-arg GO_VERSION=${GO_VERSION} -t storjlabs/storage-node:${TAG} -f cmd/farmer/Dockerfile . push-images: - docker push storjlabs/satellite:${TAG}-${GO_VERSION} + docker tag storjlabs/satellite:${TAG} storjlabs/satellite:latest + docker push storjlabs/satellite:${TAG} docker push storjlabs/satellite:latest + docker tag storjlabs/storage-node:${TAG} storjlabs/storage-node:latest docker push storjlabs/storage-node:${TAG} docker push storjlabs/storage-node:latest +ifeq (${BRANCH},master) clean-images: - -docker rmi storjlabs/satellite:${TAG}-${GO_VERSION} storjlabs/satellite:latest + -docker rmi storjlabs/satellite:${TAG} storjlabs/satellite:latest -docker rmi storjlabs/storage-node:${TAG} storjlabs/storage-node:latest +else +clean-images: + -docker rmi storjlabs/satellite:${TAG} + -docker rmi storjlabs/storage-node:${TAG} +endif install-deps: go get -u -v golang.org/x/vgo diff --git a/cmd/farmer/Dockerfile b/cmd/farmer/Dockerfile index b00cd4419..9b88f639e 100644 --- a/cmd/farmer/Dockerfile +++ b/cmd/farmer/Dockerfile @@ -1,7 +1,7 @@ # build -FROM golang:1.10-alpine AS build-env -RUN apk add -U curl git musl-dev gcc \ - && apk add git +ARG GO_VERSION=1.10 +FROM golang:${GO_VERSION}-alpine AS build-env +RUN apk add -U curl git musl-dev gcc RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh COPY . /go/src/storj.io/storj RUN cd /go/src/storj.io/storj && dep ensure -vendor-only diff --git a/cmd/hc/Dockerfile b/cmd/hc/Dockerfile index 26609e33b..fccfa91ff 100644 --- a/cmd/hc/Dockerfile +++ b/cmd/hc/Dockerfile @@ -1,4 +1,5 @@ -FROM golang:1.10-alpine AS build-env +ARG GO_VERSION=1.10 +FROM golang:${GO_VERSION}-alpine AS build-env RUN apk update && \ apk upgrade && \ apk add curl && \