Reputation: 1322
I'm trying to build a docker image of a go server. The source code is on gitlab.com. Based on this tuto i added git config in my Dockerfile
#Start from a Debian image with the latest version of Go installed
FROM golang:latest
ENV READIUM_LICENSE_CONFIG /config/config.yaml
ENV REPO=gitlab.com/gara-project/back-end-micro-services/lcp-server/readium-lcp-server
ADD src /src
ADD lcp-server/entrypoint.sh /entrypoint.sh
RUN git config \
--global \
url."https://username:[email protected]".insteadOf \
"https://gitlab.com"
RUN GIT_TERMINAL_PROMPT=1
RUN GOPATH=/ go install $REPO@latest
RUN chmod a+x /entrypoint.sh
VOLUME ["/files", "/config"]
CMD ["/bin/lcpserver"]
ENTRYPOINT ["/entrypoint.sh"]
EXPOSE 8989
The username and token is correct, because i try a git clone on with it. When I run the build of the docker file I got
go install gitlab.com/gara-project/back-end-micro-services/lcp-server/readium-lcp-server@latest: module gitlab.com/gara-project/back-end-micro-services/lcp-server/readium-lcp-server: git ls-remote -q origin in /pkg/mod/cache/vcs/389aeee014594569659e179bbd3e2519e3cd572a0adc7faf372d5fdbcb7d22bd: exit status 128: remote: The project you were looking for could not be found. fatal: repository 'https://xxxx:[email protected]/gara-project/back-end-micro-services.git/' not found
1- I don't know why go is looking for gara-project/back-end-micro-services.git
instead of looking for
gitlab.com/gara-project/back-end-micro-services/lcp-server/readium-lcp-server
2- How could i set my go to access my gitlab ? I tried many solution without success.
Thank
Upvotes: 2
Views: 2695
Reputation: 15963
I have run into the same problem:
go install gitlab.com/foo/bar/baz@latest
go install: gitlab.com/foo/bar/baz@latest: module gitlab.com/foo/bar/baz: git ls-remote -q origin in /Users/user/go/pkg/mod/cache/vcs/<hash>: exit status 128:
remote: The project you were looking for could not be found or you don't have permission to view it.
fatal: repository 'https://gitlab.com/foo/bar.git/' not found
Clearly, go install
isn't looking in the right place.
What has been recommended:
go env -w "GOPRIVATE=gitlab.com/foo/*"
(to get go
to look in the "right" places)~/.netrc
to have machine gitlab.com username <USERNAME> password <GITLAB_PAT>
, OR~/.gitconfig
to have:[url "ssh://[email protected]/"]
insteadOf = https://gitlab.com/
As recommended in: https://gitlab.com/gitlab-org/gitlab-foss/-/issues/65681 and https://go.dev/doc/faq#git_https
However, none of these solutions currently work for me.
Upvotes: -2