Browse code

Do not required `.git` in the build context

- export DOCKER_GITCOMMIT in the Makefile
- prioritize DOCKER_GITCOMMIT against the `git` command in
`./hack/make.sh`
- Also add `integration-cli/bundles` to gitignore (it's generated when
using integration-cli shell)

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Vincent Demeester authored on 2016/11/16 19:49:32
Showing 3 changed files
... ...
@@ -1,4 +1,5 @@
1 1
 bundles
2
+integration-cli/bundles
2 3
 .gopath
3 4
 vendor/pkg
4 5
 .go-pkg-cache
... ...
@@ -10,6 +10,9 @@ export DOCKER_INCREMENTAL_BINARY
10 10
 DOCKER_OSARCH := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKER_ENGINE_OSARCH:-$$DOCKER_CLIENT_OSARCH}')
11 11
 DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKERFILE}')
12 12
 
13
+DOCKER_GITCOMMIT := $(shell git rev-parse --short HEAD || echo unsupported)
14
+export DOCKER_GITCOMMIT
15
+
13 16
 # env vars passed through directly to Docker's build scripts
14 17
 # to allow things like `make KEEPBUNDLE=1 binary` easily
15 18
 # `project/PACKAGERS.md` have some limited documentation of some of these
... ...
@@ -70,7 +70,9 @@ DEFAULT_BUNDLES=(
70 70
 
71 71
 VERSION=$(< ./VERSION)
72 72
 ! BUILDTIME=$(date --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/')
73
-if command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; then
73
+if [ "$DOCKER_GITCOMMIT" ]; then
74
+	GITCOMMIT="$DOCKER_GITCOMMIT"
75
+elif command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; then
74 76
 	GITCOMMIT=$(git rev-parse --short HEAD)
75 77
 	if [ -n "$(git status --porcelain --untracked-files=no)" ]; then
76 78
 		GITCOMMIT="$GITCOMMIT-unsupported"
... ...
@@ -83,8 +85,7 @@ if command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; the
83 83
 		git status --porcelain --untracked-files=no
84 84
 		echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
85 85
 	fi
86
-elif [ "$DOCKER_GITCOMMIT" ]; then
87
-	GITCOMMIT="$DOCKER_GITCOMMIT"
86
+	! BUILDTIME=$(date --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/') &> /dev/null
88 87
 else
89 88
 	echo >&2 'error: .git directory missing and DOCKER_GITCOMMIT not specified'
90 89
 	echo >&2 '  Please either build with the .git directory accessible, or specify the'