Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid `go get` `unknown revision` problem which occurs only inside Docker?

Tags:

git

docker

go

When I follow an exact sequence of steps of cloning and building my project outside of docker it works well. When I place the exact same sequence into a docker file I am seeing the following error.

I don't know enough about docker to know how to formulate this question more succinctly, except to say, does anyone know how to resolve this type of error.

Step 18/22 : RUN go build
 ---> Running in 27e0719b2e7d
go: gitlab.com/myorg/[email protected]: reading gitlab.com/myorg/lalo/go.mod at revision v0.12.3: unknown revision v0.12.3

To be clear, I am able to create a new empty temporary folder on my computer (without docker and do a full clean build), it is only when I do the same in docker that I see this unknown revision issue.

like image 575
Jay Avatar asked Jan 14 '20 04:01

Jay


2 Answers

Add the following to the docker config.

RUN git config --global url."[email protected]:".insteadOf "https://gitlab.com/"

(That rather obscure error obfuscates the fact that it go get is having some more basic problems.)

like image 70
Qi Yin Avatar answered Oct 15 '22 08:10

Qi Yin


You are most likely missing something in your environment that is set up for you upon login. Go builds are affected by environment variables like GOPATH and GOROOT. Your gitlab repo might require ssh keys for access. It's something you would have had to set up at some point. Look in your .bashrc and .profile files, and the output of the env command for hints.

like image 39
Karl Bielefeldt Avatar answered Oct 15 '22 08:10

Karl Bielefeldt