docker - 在 docker 中使用 gitlab private repo 作为 golang 依赖项

标签 docker go gitlab

我在我的组织 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/

相关文章:

docker - Nginx反向代理不重定向?

amazon-web-services - 在同一台机器或每台机器上运行多个图像/容器?

docker - 如何使用NGINX将请求转发到Docker Microservice

go - 处理 Gorilla mux 空变量

Gitlab Pages 访问时抛出 404

docker - 从从属镜像创建独立的docker镜像

go - 这个 Go print 语句的顺序是什么?

go - 未知运营商 : "$or" in mgo

git - 让 git 用户的 sshd 登录转发到(GitLab)Docker 容器

git - 如何授予用户级别访问私有(private) GitLab 存储库的权限?