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

image build failed with error "fatal: not a git repository (or any of the parent directories): .git" #46

Open
liming92309 opened this issue Apr 23, 2023 · 1 comment

Comments

@liming92309
Copy link

Hi

I tried to run make dockr to build image, and it is failed as below, if the golang:1 base image is not correct?

in my environment, i see the base image is docker.io/library/golang:1

[1/2] STEP 1/7: FROM golang:1 AS build
[1/2] STEP 2/7: WORKDIR /sidecarinjector
--> Using cache f6c0341009898f985698892b589608c7dde3f9cee285f4bbca301596dd506943
--> f6c03410098
[1/2] STEP 3/7: COPY go.mod go.sum ./
--> Using cache 2ec6cab42b756aa6dbd04507328613f00a6d2ee8ec2ccdaa66f08c6d4061a6ae
--> 2ec6cab42b7
[1/2] STEP 4/7: RUN go mod download
--> Using cache 0c864f93055bad9a5386ceff63b14b035d94bda9df4da6ccfe511d7483d7df50
--> 0c864f93055
[1/2] STEP 5/7: COPY . ./
--> 65cfd9e6215
[1/2] STEP 6/7: COPY pkg ./pkg
--> 4b48cf1e32e
[1/2] STEP 7/7: RUN GIT_HASH=$(git rev-parse --short HEAD) && GIT_TAG=$(git tag | tail -1) && CGO_ENABLED=0 && GOOS=linux && GOARCH=amd64 && echo "GIT_HASH=$GIT_HASH" && echo "GIT_TAG=$GIT_TAG" && go build -ldflags "-X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitHash=$GIT_HASH' -X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitTag=$GIT_TAG' -s" -installsuffix cgo -o sidecarinjector ./cmd/sidecarinjector
fatal: not a git repository (or any of the parent directories): .git
[2/2] STEP 1/4: FROM golang:1
Error: error building at STEP "RUN GIT_HASH=$(git rev-parse --short HEAD) && GIT_TAG=$(git tag | tail -1) && CGO_ENABLED=0 && GOOS=linux && GOARCH=amd64 && echo "GIT_HASH=$GIT_HASH" && echo "GIT_TAG=$GIT_TAG" && go build -ldflags "-X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitHash=$GIT_HASH' -X 'github.com/salesforce/generic-sidecar-injector/pkg/metrics.gitTag=$GIT_TAG' -s" -installsuffix cgo -o sidecarinjector ./cmd/sidecarinjector": error while running runtime: exit status 128
make: *** [podman] Error 125

@bman46
Copy link
Contributor

bman46 commented Jun 7, 2023

I think you downloaded the ZIP file instead of cloning the repo in git. Therefore, the git commands failed in the build step.

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