我在我的组织 gitlab 组中镜像了一个流行的 go 库(为了冗余)。
在我的代码中我有:import ( "gitlab.com/org/group/library.git")
我用了this answer有关将 go get 与私有(private)存储库一起使用的指南。在我的机器上 go get ./...
可以工作,因为我使用以下命令配置了 git:
$ git config --global url.git@gitlab.com:.insteadOf https://gitlab.com/
当我尝试构建 docker 容器时,命令 RUN go get ./...
失败,输出如下:
package gitlab.com/org/group/library.git: cannot download, git://gitlab.com/org/group/library uses insecure protocol
似乎来自 similar thread 的流行答案或 this article就是做一些事情,比如将你的 ssh key 上传到 docker 容器。我对此不太满意,因为我不完全了解正在做什么或安全隐患。
任何关于如何正确配置我的 dockerfile 或我的 golang 工作流程的见解都会有很大的帮助。
最佳答案
golang v1.11 似乎包含 modules .
引用出处
A module is a collection of related Go packages that are versioned together as a single unit. Most often, a single version-control repository corresponds exactly to a single module.
使用最新版本的 golang 和模块允许我使用我所有的依赖项。
关于docker - 在 docker 中使用 gitlab private repo 作为 golang 依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53061061/