Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make docker fails when the repo is cloned as a submodule #184

Closed
scjudd opened this issue Sep 19, 2019 · 4 comments
Closed

make docker fails when the repo is cloned as a submodule #184

scjudd opened this issue Sep 19, 2019 · 4 comments

Comments

@scjudd
Copy link
Contributor

scjudd commented Sep 19, 2019

If the repo is cloned as a submodule, make docker fails. This is due to the fact that GITCOMMIT_SHA doesn't exist before make runs within the build container, and the true .git/ directory is outside of the Docker build context when we're in a submodule.

I was able to fix this by making GITCOMMIT_SHA a dependency of the docker make target in the Makefile, such that GITCOMMIT_SHA already exists in the Docker build context before make runs. I have opened #185 with the fix.

Example

~$ EXAMPLE_DIR=$(mktemp -d)

~$ cd $EXAMPLE_DIR

tmp.MEpbWK5rCB$ git init
Initialized empty Git repository in /tmp/tmp.MEpbWK5rCB/.git/

tmp.MEpbWK5rCB$ git submodule add [email protected]:awslabs/amazon-ecr-credential-helper.git
Cloning into '/tmp/tmp.MEpbWK5rCB/amazon-ecr-credential-helper'...
remote: Enumerating objects: 373, done.
remote: Counting objects: 100% (373/373), done.
remote: Compressing objects: 100% (300/300), done.
remote: Total 2186 (delta 90), reused 205 (delta 55), pack-reused 1813
Receiving objects: 100% (2186/2186), 2.60 MiB | 11.09 MiB/s, done.
Resolving deltas: 100% (889/889), done.

tmp.MEpbWK5rCB$ cd amazon-ecr-credential-helper/

amazon-ecr-credential-helper$ make docker
find: ‘.git/’: Not a directory
mkdir -p bin
docker run --rm \
-e TARGET_GOOS= \
-e TARGET_GOARCH= \
-v '/tmp/tmp.MEpbWK5rCB/amazon-ecr-credential-helper/bin':/go/src/github.com/awslabs/amazon-ecr-credential-helper/bin \
sha256:dfe7b32b42631a793e59eb8c18b99da8df91fa3717ecc4fa4d0323a1ccf84110
find: '.git/': Not a directory
git rev-parse --short=7 HEAD > GITCOMMIT_SHA
fatal: Not a git repository: ../.git/modules/amazon-ecr-credential-helper
make: *** [GITCOMMIT_SHA] Error 128
Makefile:75: recipe for target 'GITCOMMIT_SHA' failed
Makefile:32: recipe for target 'docker' failed
make: *** [docker] Error 2
@samuelkarp
Copy link
Contributor

Hi @scjudd! I'm really curious to know more about why you're attempting to build the credential helper inside a submodule. If you're not already aware, there are prebuilt binaries and source releases that don't require git.

@scjudd
Copy link
Contributor Author

scjudd commented Sep 19, 2019

I actually would happily use the prebuilt binaries if I could checkout version 0.3.1, run make docker and produce the same SHA256 hash as the pre-built binaries. It seemed this was an easier ask than deterministic builds.

@samuelkarp
Copy link
Contributor

Thanks! I've opened #186 to track reproducible builds, since this is something I've wanted anyway.

For your use-case of building yourself, another alternative is to build from a source tarball that already contains a rendered GITCOMMIT_SHA file; this tarball does not depend on having a working git checkout.

@samuelkarp
Copy link
Contributor

I've merged #185 to address this. #186 will continue to track reproducible builds.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants