Skip to content

Add .git to .dockerignore#27834

Closed
lowenna wants to merge 1 commit intomoby:masterfrom
microsoft:jjh/dockerignoredotgit
Closed

Add .git to .dockerignore#27834
lowenna wants to merge 1 commit intomoby:masterfrom
microsoft:jjh/dockerignoredotgit

Conversation

@lowenna
Copy link
Copy Markdown
Member

@lowenna lowenna commented Oct 27, 2016

Signed-off-by: John Howard jhoward@microsoft.com

I don't think there's any reason not to have this in there - currently the entire .git folder is being sent in the builder context when doing builds which can be a pretty significant overhead if you have lots of branches (it almost triples the size of the build context on my dev machine). Let's see what CI says though, maybe there's some dependency I'm not aware of....

Signed-off-by: John Howard <jhoward@microsoft.com>
@lowenna
Copy link
Copy Markdown
Member Author

lowenna commented Oct 27, 2016

OK, so looks like some of the make scripts use it. But looks like they could be worked around with an environment variable:

12:44:43 error: .git directory missing and DOCKER_GITCOMMIT not specified
12:44:43   Please either build with the .git directory accessible, or specify the
12:44:43   exact (--short) commit hash you are building using DOCKER_GITCOMMIT for
12:44:43   future accountability in diagnosing build issues.  Thanks!

@vdemeester
Copy link
Copy Markdown
Member

/cc @tiborvass

@tiborvass
Copy link
Copy Markdown
Contributor

I understand the concern, but I'm not sure we'd want this.

@tianon what do you think about retrieving DOCKER_GITCOMMIT and setting it as an envvar?

@tianon
Copy link
Copy Markdown
Member

tianon commented Nov 12, 2016

@tianon what do you think about retrieving DOCKER_GITCOMMIT and setting it as an envvar?

Retrieving it where? In the Makefile?

(it'd be really neat if we could add --ignore to docker build so that the Makefile could explicitly --ignore .git but not affect non-Makefile builds 😞)

@tianon
Copy link
Copy Markdown
Member

tianon commented Nov 12, 2016

To clarify a bit, doing docker build ... followed by docker run ... is a currently a supported means of using the Docker development container (and used to be the official way, before we started using the Makefile more heavily -- not sure if we still have any documentation referencing the "older" manual method).

@vdemeester
Copy link
Copy Markdown
Member

vdemeester commented Nov 15, 2016

142M .git

I definitely want that 👼 😝. 142M just to get the git has commit is.. a little bit too much 😛

I think it's doable simply :

diff --git a/hack/make.sh b/hack/make.sh
index 95c935b..6777f36 100755
--- a/hack/make.sh
+++ b/hack/make.sh
@@ -69,7 +69,9 @@ DEFAULT_BUNDLES=(
 )

 VERSION=$(< ./VERSION)
-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"
@@ -87,8 +89,6 @@ if command -v git &> /dev/null && [ -d .git ] && git rev-parse &> /dev/null; the
                # If using bash 3.1 which doesn't support --rfc-3389, eg Windows CI
                BUILDTIME=$(date -u)
        fi
-elif [ "$DOCKER_GITCOMMIT" ]; then
-       GITCOMMIT="$DOCKER_GITCOMMIT"
 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'

And setting DOCKER_GITCOMMIT in the Makefile if possible 👼

@vdemeester
Copy link
Copy Markdown
Member

Also I think we could add integration-cli/bundles to the .dockerignore 👼 (it's created when using the integration-cli shell).

@vdemeester
Copy link
Copy Markdown
Member

Closing this as I'm carrying in #28473

@vdemeester vdemeester closed this Nov 16, 2016
thaJeztah added a commit that referenced this pull request Feb 5, 2017
Carry #27834 — Do not require `.git` in the build context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants