Skip to content

Commit 48910f7

Browse files
committed
Update the scripting
Automated putting the source tree into release mode.
1 parent 6282be9 commit 48910f7

14 files changed

+859
-64
lines changed

.dockerignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
pkg/
2+
.git
3+
bin/

GNUmakefile

+50-17
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ GIT_DESCRIBE?=$(shell git describe --tags --always)
2828
GIT_IMPORT=github.com/hashicorp/consul/version
2929
GOLDFLAGS=-X $(GIT_IMPORT).GitCommit=$(GIT_COMMIT)$(GIT_DIRTY) -X $(GIT_IMPORT).GitDescribe=$(GIT_DESCRIBE)
3030

31+
ifeq ($(FORCE_REBUILD),1)
32+
NOCACHE=--no-cache
33+
else
34+
NOCACHE=
35+
endif
36+
37+
DOCKER_BUILD_QUIET?=1
38+
ifeq (${DOCKER_BUILD_QUIET},1)
39+
QUIET=-q
40+
else
41+
QUIET=
42+
endif
43+
44+
CONSUL_DEV_IMAGE?=consul-dev
3145
GO_BUILD_TAG?=consul-build-go
3246
UI_BUILD_TAG?=consul-build-ui
3347
UI_LEGACY_BUILD_TAG?=consul-build-ui-legacy
@@ -37,6 +51,18 @@ DIST_TAG?=1
3751
DIST_BUILD?=1
3852
DIST_SIGN?=1
3953

54+
ifdef DIST_VERSION
55+
DIST_VERSION_ARG=-v $(DIST_VERSION)
56+
else
57+
DIST_VERSION_ARG=
58+
endif
59+
60+
ifdef DIST_RELEASE_DATE
61+
DIST_DATE_ARG=-d $(DIST_RELEASE_DATE)
62+
else
63+
DIST_DATE_ARG=
64+
endif
65+
4066
export GO_BUILD_TAG
4167
export UI_BUILD_TAG
4268
export UI_LEGACY_BUILD_TAG
@@ -57,7 +83,11 @@ bin: tools
5783
dev: changelogfmt vendorfmt dev-build
5884

5985
dev-build:
60-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh consul-local -o '$(GOOS)' -a '$(GOARCH)'
86+
@$(SHELL) $(CURDIR)/build-support/scripts/build-local.sh
87+
88+
dev-docker:
89+
@$(SHELL)
90+
@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)
6191

6292
vendorfmt:
6393
@echo "--> Formatting vendor/vendor.json"
@@ -70,14 +100,14 @@ changelogfmt:
70100

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

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

79109
publish:
80-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh publish
110+
@$(SHELL) $(CURDIR)/build-support/scripts/publish.sh -g -w
81111

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

144174
version:
145175
@echo -n "Version: "
146-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version
176+
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh
147177
@echo -n "Version + release: "
148-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version -R
178+
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh -r
149179
@echo -n "Version + git: "
150-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version -G
180+
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh -g
151181
@echo -n "Version + release + git: "
152-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh version -R -G
182+
@$(SHELL) $(CURDIR)/build-support/scripts/version.sh -r -g
153183

154-
docker-images:
155-
@$(MAKE) -C build-support/docker images
184+
185+
docker-images: go-build-image ui-build-image ui-legacy-build-image
156186

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

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

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

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

169202
consul-docker: go-build-image
170-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh consul
203+
@$(SHELL) $(CURDIR)/build-support/scripts/build-docker.sh consul
171204

172205
ui-docker: ui-build-image
173-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh ui
206+
@$(SHELL) $(CURDIR)/build-support/scripts/build-docker.sh ui
174207

175208
ui-legacy-docker: ui-legacy-build-image
176-
@$(SHELL) $(CURDIR)/build-support/scripts/build.sh ui-legacy
209+
@$(SHELL) $(CURDIR)/build-support/scripts/build-docker.sh ui-legacy
177210

178211

179212
.PHONY: all ci bin dev dist cov test cover format vet ui static-assets tools vendorfmt
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM golang:latest as builder
2+
ARG GIT_COMMIT
3+
ARG GIT_DIRTY
4+
ARG GIT_DESCRIBE
5+
WORKDIR /go/src/github.com/hashicorp/consul
6+
ENV CONSUL_DEV=1
7+
ENV COLORIZE=0
8+
Add . /go/src/github.com/hashicorp/consul/
9+
RUN make
10+
11+
FROM consul:latest
12+
13+
COPY --from=builder /go/src/github.com/hashicorp/consul/bin/consul /bin

build-support/docker/Makefile

-28
This file was deleted.

build-support/functions/00-vars.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ UI_LEGACY_BUILD_CONTAINER_DEFAULT="consul-build-ui-legacy"
77
GO_BUILD_CONTAINER_DEFAULT="consul-build-go"
88

99
# Whether to colorize shell output
10-
COLORIZE=1
10+
if test -z "${COLORIZE}"
11+
then
12+
COLORIZE=1
13+
fi
1114

1215

1316
# determine GOPATH and the first GOPATH to use for intalling binaries
@@ -36,4 +39,12 @@ fi
3639
if test -z "${PUBLISH_GIT_REPO}"
3740
then
3841
PUBLISH_GIT_REPO=hashicorp/consul.git
39-
fi
42+
fi
43+
44+
if test "$(uname)" == "Darwin"
45+
then
46+
SED_EXT="-E"
47+
else
48+
SED_EXT=""
49+
fi
50+

0 commit comments

Comments
 (0)