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

Add awslabs to git safe dir #802

Merged
merged 2 commits into from
May 2, 2024
Merged

Add awslabs to git safe dir #802

merged 2 commits into from
May 2, 2024

Conversation

ktasper
Copy link
Contributor

@ktasper ktasper commented May 2, 2024

Issue #, if available:
Fixes the following error when running make build-in-docker for ISSUE: #800

git rev-parse --short=7 HEAD > GITCOMMIT_SHA
fatal: detected dubious ownership in repository at '/go/src/github.com/awslabs/amazon-ecr-credential-helper'
To add an exception for this directory, call:

        git config --global --add safe.directory /go/src/github.com/awslabs/amazon-ecr-credential-helper
make: *** [Makefile:95: GITCOMMIT_SHA] Error 128

Description of changes:

  • Adds /go/src/github.com/awslabs/amazon-ecr-credential-helper to git as a safe directory.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Copy link
Contributor

@austinvazquez austinvazquez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into the issue. The challenge really comes from the build mounting .git directory into the container which is fine when building with non-root users but breaks as you have found when running as root users. I'd like to look more into simplifying this build logic as a seperate issue but first it would be good to get a workaround for this.

Can you apply the following patch to the Makefile along with your change? This way we generate the required shasum before going into the container as a workaround

diff --git a/Makefile b/Makefile
index 6fbed4f..fac7fb3 100644
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@ WINDOWS_ARM64_BINARY=$(BINPATH)/windows-arm64/$(BINARY_NAME).exe
 .PHONY: docker
 docker: build-in-docker
 
-%-in-docker:
+%-in-docker: GITCOMMIT_SHA
        docker run --rm \
                --user $(UID):$(GID) \
                --env TARGET_GOOS=$(TARGET_GOOS) \

scripts/container_init.sh Show resolved Hide resolved
Copy link
Contributor

@pendo324 pendo324 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@austinvazquez austinvazquez merged commit cce9343 into awslabs:main May 2, 2024
13 checks passed
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

Successfully merging this pull request may close these issues.

3 participants