From a8e3e55250387a61373fe010ab6a89da5521f477 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Mon, 25 Jun 2018 14:20:33 +0000 Subject: [PATCH] Use build image from build-tools repo --- .circleci/config.yml | 9 ++------- Makefile | 13 ++++++------- common-build/Dockerfile | 16 ---------------- common-build/build.sh | 17 ----------------- 4 files changed, 8 insertions(+), 47 deletions(-) delete mode 100644 common-build/Dockerfile delete mode 100755 common-build/build.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 2d4bd426..4c05019e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,10 +2,8 @@ version: 2 # https://circleci.com/blog/circleci-hacks-reuse-yaml-in-your-circleci-config-with-yaml/ defaults: &defaults -# Process to update the build container is: -# Check out desired version of this repo; 'make common-build/.uptodate'; docker push docker: - - image: weaveworks/common-build:circle20-cfa562b + - image: quay.io/weaveworks/build-golang:1.10.0-stretch working_directory: /go/src/github.com/weaveworks/common workflows: @@ -22,9 +20,7 @@ jobs: - checkout - run: name: Lint - command: | - touch common-build/.uptodate && - make BUILD_IN_CONTAINER=false lint + command: "make BUILD_IN_CONTAINER=false lint" test: <<: *defaults @@ -34,5 +30,4 @@ jobs: name: Test command: | dep ensure && - touch common-build/.uptodate && make BUILD_IN_CONTAINER=false test diff --git a/Makefile b/Makefile index 85660136..f65d4286 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,7 @@ IMAGE_PREFIX := weaveworks IMAGE_TAG := $(shell ./tools/image-tag) UPTODATE := .uptodate +BUILD_IMAGE=quay.io/weaveworks/build-golang:1.10.0-stretch # Building Docker images is now automated. The convention is every directory # with a Dockerfile in it builds an image calls quay.io/weaveworks/. @@ -23,8 +24,6 @@ DOCKER_IMAGE_DIRS=$(patsubst %/Dockerfile,%,$(DOCKERFILES)) all: $(UPTODATE_FILES) -common-build/$(UPTODATE): common-build/* - # All the boiler plate for building golang follows: SUDO := $(shell docker info >/dev/null 2>&1 || echo "sudo -E") BUILD_IN_CONTAINER := true @@ -41,22 +40,22 @@ NETGO_CHECK = @strings $@ | grep cgo_stub\\\.go >/dev/null || { \ ifeq ($(BUILD_IN_CONTAINER),true) -lint test shell: common-build/$(UPTODATE) +lint test shell: @mkdir -p $(shell pwd)/.pkg $(SUDO) docker run $(RM) -ti \ -v $(shell pwd)/.pkg:/go/pkg \ -v $(shell pwd):/go/src/github.com/weaveworks/common \ - $(IMAGE_PREFIX)/common-build $@ + $(BUILD_IMAGE) $@ else -lint: common-build/$(UPTODATE) +lint: ./tools/lint -notestpackage -ignorespelling queriers -ignorespelling Queriers . -test: common-build/$(UPTODATE) +test: ./tools/test -no-go-get -netgo -shell: common-build/$(UPTODATE) +shell: bash endif diff --git a/common-build/Dockerfile b/common-build/Dockerfile deleted file mode 100644 index d89e00a3..00000000 --- a/common-build/Dockerfile +++ /dev/null @@ -1,16 +0,0 @@ -FROM golang:1.10.3-stretch -RUN apt-get update && apt-get install -y file python-requests && \ - rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -RUN go clean -i net && \ - go install -tags netgo std && \ - go install -race -tags netgo std -RUN go get -tags netgo \ - github.com/fzipp/gocyclo \ - github.com/golang/lint/golint \ - github.com/kisielk/errcheck \ - github.com/mjibson/esc \ - github.com/client9/misspell/cmd/misspell \ - mvdan.cc/sh/cmd/shfmt -RUN curl https://github.com/raw/golang/dep/master/install.sh | sh -COPY build.sh / -ENTRYPOINT ["/build.sh"] diff --git a/common-build/build.sh b/common-build/build.sh deleted file mode 100755 index 1e45f8a7..00000000 --- a/common-build/build.sh +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/sh - -set -eu - -SRC_PATH=$GOPATH/src/github.com/weaveworks/common - -# If we run make directly, any files created on the bind mount -# will have awkward ownership. So we switch to a user with the -# same user and group IDs as source directory. We have to set a -# few things up so that sudo works without complaining later on. -uid=$(stat --format="%u" $SRC_PATH) -gid=$(stat --format="%g" $SRC_PATH) -echo "weave:x:$uid:$gid::$SRC_PATH:/bin/sh" >>/etc/passwd -echo "weave:*:::::::" >>/etc/shadow -echo "weave ALL=(ALL) NOPASSWD: ALL" >>/etc/sudoers - -su weave -c "PATH=$PATH make -C $SRC_PATH BUILD_IN_CONTAINER=false $*"