From 7e467dc7f79d5b49b2af8c6b162f8a1f7f02e3f1 Mon Sep 17 00:00:00 2001 From: Vincent Demeester Date: Wed, 16 Nov 2016 11:49:32 +0100 Subject: [PATCH] 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 Upstream-commit: fae6ca2bb42d9c4146df413bcce701431298161c Component: engine --- components/engine/.dockerignore | 1 + components/engine/Makefile | 3 +++ components/engine/hack/make.sh | 7 ++++--- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/components/engine/.dockerignore b/components/engine/.dockerignore index 2ce8321a7e..b605b08c61 100644 --- a/components/engine/.dockerignore +++ b/components/engine/.dockerignore @@ -1,4 +1,5 @@ bundles +integration-cli/bundles .gopath vendor/pkg .go-pkg-cache diff --git a/components/engine/Makefile b/components/engine/Makefile index 747340ffd4..7fe4872b04 100644 --- a/components/engine/Makefile +++ b/components/engine/Makefile @@ -10,6 +10,9 @@ export DOCKER_INCREMENTAL_BINARY DOCKER_OSARCH := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKER_ENGINE_OSARCH:-$$DOCKER_CLIENT_OSARCH}') DOCKERFILE := $(shell bash -c 'source hack/make/.detect-daemon-osarch && echo $${DOCKERFILE}') +DOCKER_GITCOMMIT := $(shell git rev-parse --short HEAD || echo unsupported) +export DOCKER_GITCOMMIT + # env vars passed through directly to Docker's build scripts # to allow things like `make KEEPBUNDLE=1 binary` easily # `project/PACKAGERS.md` have some limited documentation of some of these diff --git a/components/engine/hack/make.sh b/components/engine/hack/make.sh index 8b8c9aed73..8b2a4a975d 100755 --- a/components/engine/hack/make.sh +++ b/components/engine/hack/make.sh @@ -70,7 +70,9 @@ DEFAULT_BUNDLES=( VERSION=$(< ./VERSION) ! BUILDTIME=$(date --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/') -if command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; then +if [ "$DOCKER_GITCOMMIT" ]; then + GITCOMMIT="$DOCKER_GITCOMMIT" +elif command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; then GITCOMMIT=$(git rev-parse --short HEAD) if [ -n "$(git status --porcelain --untracked-files=no)" ]; then GITCOMMIT="$GITCOMMIT-unsupported" @@ -83,8 +85,7 @@ if command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; the git status --porcelain --untracked-files=no echo "#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" fi -elif [ "$DOCKER_GITCOMMIT" ]; then - GITCOMMIT="$DOCKER_GITCOMMIT" + ! BUILDTIME=$(date --rfc-3339 ns 2> /dev/null | sed -e 's/ /T/') &> /dev/null else echo >&2 'error: .git directory missing and DOCKER_GITCOMMIT not specified' echo >&2 ' Please either build with the .git directory accessible, or specify the'