Skip to content

Commit

Permalink
Update the scripting
Browse files Browse the repository at this point in the history
Automated putting the source tree into release mode.
  • Loading branch information
mkeeler committed Jun 15, 2018
1 parent 6282be9 commit 48910f7
Show file tree
Hide file tree
Showing 14 changed files with 859 additions and 64 deletions.
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pkg/
.git
bin/
67 changes: 50 additions & 17 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,20 @@ GIT_DESCRIBE?=$(shell git describe --tags --always)
GIT_IMPORT=github.com/hashicorp/consul/version
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).GitDescribe=$(GIT_DESCRIBE)

ifeq ($(FORCE_REBUILD),1)
NOCACHE=--no-cache
else
NOCACHE=
endif

DOCKER_BUILD_QUIET?=1
ifeq (${DOCKER_BUILD_QUIET},1)
QUIET=-q
else
QUIET=
endif

CONSUL_DEV_IMAGE?=consul-dev
GO_BUILD_TAG?=consul-build-go
UI_BUILD_TAG?=consul-build-ui
UI_LEGACY_BUILD_TAG?=consul-build-ui-legacy
Expand All @@ -37,6 +51,18 @@ DIST_TAG?=1
DIST_BUILD?=1
DIST_SIGN?=1

ifdef DIST_VERSION
DIST_VERSION_ARG=-v $(DIST_VERSION)
else
DIST_VERSION_ARG=
endif

ifdef DIST_RELEASE_DATE
DIST_DATE_ARG=-d $(DIST_RELEASE_DATE)
else
DIST_DATE_ARG=
endif

export GO_BUILD_TAG
export UI_BUILD_TAG
export UI_LEGACY_BUILD_TAG
Expand All @@ -57,7 +83,11 @@ bin: tools
dev: changelogfmt vendorfmt dev-build

dev-build:
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh consul-local -o '$(GOOS)' -a '$(GOARCH)'
@$(SHELL) $(CURDIR)/build-support/scripts/build-local.sh

dev-docker:
@$(SHELL)
@docker build -t '$(CONSUL_DEV_IMAGE)' --build-arg 'GIT_COMMIT=$(GIT_COMMIT)' --build-arg 'GIT_DIRTY=$(GIT_DIRTY)' --build-arg 'GIT_DESCRIBE=$(GIT_DESCRIBE)' -f $(CURDIR)/build-support/docker/Consul-Dev.dockerfile $(CURDIR)

vendorfmt:
@echo "--> Formatting vendor/vendor.json"
Expand All @@ -70,14 +100,14 @@ changelogfmt:

# linux builds a linux package independent of the source platform
linux:
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh consul-local -o linux -a amd64
@$(SHELL) $(CURDIR)/build-support/scripts/build-local.sh -o linux -a amd64

# dist builds binaries for all platforms and packages them for distribution
dist:
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh release -t '$(DIST_TAG)' -b '$(DIST_BUILD)' -S '$(DIST_SIGN)'
@$(SHELL) $(CURDIR)/build-support/scripts/release.sh -t '$(DIST_TAG)' -b '$(DIST_BUILD)' -S '$(DIST_SIGN)' '$(DIST_VERSION_ARG)' '$(DIST_DATE_ARG)'

publish:
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh publish
@$(SHELL) $(CURDIR)/build-support/scripts/publish.sh -g -w

cov:
gocov test $(GOFILES) | gocov-html > /tmp/coverage.html
Expand Down Expand Up @@ -143,37 +173,40 @@ tools:

version:
@echo -n "Version: "
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh
@echo -n "Version + release: "
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version -R
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh -r
@echo -n "Version + git: "
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version -G
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh -g
@echo -n "Version + release + git: "
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version -R -G
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh -r -g

docker-images:
@$(MAKE) -C build-support/docker images

docker-images: go-build-image ui-build-image ui-legacy-build-image

go-build-image:
@$(MAKE) -C build-support/docker go-build-image
@echo "Building Golang build container"
@docker build $(NOCACHE) $(QUIET) --build-arg 'GOTOOLS=$(GOTOOLS)' -t $(GO_BUILD_TAG) - < build-support/docker/Build-Go.dockerfile

ui-build-image:
@$(MAKE) -C build-support/docker ui-build-image
@echo "Building UI build container"
@docker build $(NOCACHE) $(QUIET) -t $(UI_BUILD_TAG) - < build-support/docker/Build-UI.dockerfile

ui-legacy-build-image:
@$(MAKE) -C build-support/docker ui-legacy-build-image
@echo "Building Legacy UI build container"
@docker build $(NOCACHE) $(QUIET) -t $(UI_LEGACY_BUILD_TAG) - < build-support/docker/Build-UI-Legacy.dockerfile

static-assets-docker: go-build-image
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh assetfs
@$(SHELL) $(CURDIR)/build-support/scripts/build-docker.sh static-assets

consul-docker: go-build-image
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh consul
@$(SHELL) $(CURDIR)/build-support/scripts/build-docker.sh consul

ui-docker: ui-build-image
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh ui
@$(SHELL) $(CURDIR)/build-support/scripts/build-docker.sh ui

ui-legacy-docker: ui-legacy-build-image
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh ui-legacy
@$(SHELL) $(CURDIR)/build-support/scripts/build-docker.sh ui-legacy


.PHONY: all ci bin dev dist cov test cover format vet ui static-assets tools vendorfmt
Expand Down
13 changes: 13 additions & 0 deletions build-support/docker/Consul-Dev.dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM golang:latest as builder
ARG GIT_COMMIT
ARG GIT_DIRTY
ARG GIT_DESCRIBE
WORKDIR /go/src/github.com/hashicorp/consul
ENV CONSUL_DEV=1
ENV COLORIZE=0
Add . /go/src/github.com/hashicorp/consul/
RUN make

FROM consul:latest

COPY --from=builder /go/src/github.com/hashicorp/consul/bin/consul /bin
28 changes: 0 additions & 28 deletions build-support/docker/Makefile

This file was deleted.

15 changes: 13 additions & 2 deletions build-support/functions/00-vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@ UI_LEGACY_BUILD_CONTAINER_DEFAULT="consul-build-ui-legacy"
GO_BUILD_CONTAINER_DEFAULT="consul-build-go"

# Whether to colorize shell output
COLORIZE=1
if test -z "${COLORIZE}"
then
COLORIZE=1
fi


# determine GOPATH and the first GOPATH to use for intalling binaries
Expand Down Expand Up @@ -36,4 +39,12 @@ fi
if test -z "${PUBLISH_GIT_REPO}"
then
PUBLISH_GIT_REPO=hashicorp/consul.git
fi
fi

if test "$(uname)" == "Darwin"
then
SED_EXT="-E"
else
SED_EXT=""
fi

Loading

0 comments on commit 48910f7

Please sign in to comment.