duanliaouu965826
2018-10-30 09:27
浏览 602

在docker中使用gitlab私有仓库作为golang依赖

I am mirroring a popular go library in my organizations gitlab's group (for redundancy).

In my code I have: import ( "gitlab.com/org/group/library.git" )

I used this answer for guidance on using go get with a private repository. On my machine go get ./... works because I configured git using the following command:

$ git config --global url.git@gitlab.com:.insteadOf https://gitlab.com/

When I try to build a docker container the command RUN go get ./... fails with the following output:

package gitlab.com/org/group/library.git: cannot download, git://gitlab.com/org/group/library uses insecure protocol

It seems the popular answer from a similar thread or this article is to do something like upload your ssh keys to the docker container. I don't really feel comfortable with that because I don't exactly understand what is doing, or the security implications.

Any insight on how to properly configure my dockerfile or my golang work flow would be of great assistance.

图片转代码服务由CSDN问答提供 功能建议

我正在镜像我的组织gitlab组中一个流行的go库(出于冗余目的)。 \ n

在我的代码中,我有: import(“ gitlab.com/org/group/library.git”)

我使用了此答案有关在私有存储库中使用go get的指导。 在我的机器上, go get ./...可以工作,因为我使用以下命令配置了git:

  $ git config --global url.git  @ gitlab.com:.insteadOf https://gitlab.com/
   
 
 

当我尝试构建docker容器时,命令 RUN进入get ./ ... 失败,并显示以下输出:

  package gitlab.com/org/group/library.git:无法下载,git://gitlab.com  / org / group / library使用不安全的协议
   
 
 

这似乎是类似线程本文的作用是将ssh密钥上传到docker容器。 我对此不太满意,因为我不完全了解正在执行的操作或安全隐患。

任何有关如何正确配置dockerfile或golang工作流程的见识都将提供极大的帮助。

  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanjia4220 2018-11-16 17:44
    已采纳

    It appears that golang v1.11 includes modules.

    To quote the source

    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.

    Using the latest version of golang along with modules allows me to use all of my dependencies.

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题