From b8b134f3892954887562b125247c5cd98f7a1096 Mon Sep 17 00:00:00 2001 From: Evan Lezar Date: Tue, 31 Oct 2023 15:25:29 +0100 Subject: [PATCH] Ensure git works in container Signed-off-by: Evan Lezar --- Makefile | 8 ++++---- docker/Dockerfile.devel | 6 +++++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 420b0a5a..a9247f81 100644 --- a/Makefile +++ b/Makefile @@ -120,8 +120,8 @@ $(DOCKER_TARGETS): docker-%: .build-image --rm \ -e GOCACHE=/tmp/.cache \ -e GOLANGCI_LINT_CACHE=/tmp/.cache \ - -v $(PWD):$(PWD) \ - -w $(PWD) \ + -v $(PWD):/work \ + -w /work \ --user $$(id -u):$$(id -g) \ $(BUILDIMAGE) \ make $(*) @@ -134,7 +134,7 @@ PHONY: .shell -ti \ -e GOCACHE=/tmp/.cache \ -e GOLANGCI_LINT_CACHE=/tmp/.cache \ - -v $(PWD):$(PWD) \ - -w $(PWD) \ + -v $(PWD):/work \ + -w /work \ --user $$(id -u):$$(id -g) \ $(BUILDIMAGE) diff --git a/docker/Dockerfile.devel b/docker/Dockerfile.devel index a3aa25d0..c664467f 100644 --- a/docker/Dockerfile.devel +++ b/docker/Dockerfile.devel @@ -20,4 +20,8 @@ RUN go install github.com/matryer/moq@latest RUN go install github.com/gordonklaus/ineffassign@d2c82e48359b033cde9cf1307f6d5550b8d61321 RUN go install github.com/client9/misspell/cmd/misspell@latest RUN go install github.com/google/go-licenses@latest -RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} \ No newline at end of file +RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VERSION} + +# We need to set the /work directory as a safe directory. +# This allows git commands to run in the container. +RUN git config --file=/.gitconfig --add safe.directory /work