Skip to content

Issues: meet Git safety protection When run ./demo/build-driver-image.shΒ #142

@FengGaoCSC

Description

@FengGaoCSC

Issue description:

  • When running ./demo/build-driver.sh, output the following log
...........
#9 exporting to image 
#9 exporting layers 
#9 exporting layers 7.4s done #9 writing image sha256:f6cca1f2b91d15561324185f4e992e29ff586f0789978f2feb71bb75ce6939d7 done 
#9 naming to registry.k8s.io/dra-example-driver/dra-example-driver-build:golang1.25.5 done 
#9 DONE 7.4s 
Running 'make generate' in container registry.k8s.io/dra-example-driver/dra-example-driver-build:golang1.25.5 
docker run \ 
  --rm \ 
    -e HOME=/home/anode/Work/dra-example-driver \ 
    -e GOCACHE=/home/anode/Work/dra-example-driver/.cache/go \ 
    -e GOPATH=/home/anode/Work/dra-example-driver/.cache/gopath \ 
    -v /home/anode/Work/dra-example-driver:/home/anode/Work/dra-example-driver:z --user $(id -u):$(id -g) \ 
    -w /home/anode/Work/dra-example-driver \ registry.k8s.io/dra-example-driver/dra-example-driver-build:golang1.25.5 \ 

    make generate go mod vendor fatal: 
   detected dubious ownership in repository at '/home/anode/Work/dra-example-driver' 
      To add an exception for this directory, 
      call: git config --global --add safe.directory /home/anode/Work/dra-example-driver fatal: 
   detected dubious ownership in repository at '/home/anode/Work/dra-example-driver' 
      To add an exception for this directory, call:
 ........

How to fix:

  • modify the /docker/Dockerfile.devel and add the following code
diff --git a/docker/Dockerfile.devel b/docker/Dockerfile.devel

ARG GOLANG_VERSION=x.x.x
FROM golang:${GOLANG_VERSION}

+ ENV GIT_CONFIG_COUNT=1
+ ENV GIT_CONFIG_KEY_0=safe.directory
+ ENV GIT_CONFIG_VALUE_0=*

RUN go install github.com/gordonklaus/ineffassign@latest && \
    go install github.com/client9/misspell/cmd/misspell@latest

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    πŸ”– Ready

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions