本文介绍了在Docker内运行dep sure -vendor-only-only挂起无法提取私有存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Dockerfile:

My Dockerfile:

FROM golang:1.11.4
RUN apt-get update && apt-get install git bash curl -yqq
ENV ENV test
ENV GIT_TERMINAL_PROMPT=1
ENV GITHUB_TOKEN XXXXXXXXXXXXXXXXXX 
    RUN curl -Ls https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-linux-amd64.tar.gz | tar xz -C /tmp \
&& mv /tmp/linux-amd64/glide /usr/bin/
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
RUN mkdir -p $GOPATH/src/github.com/<Myrepo>/
COPY . $GOPATH/src/github.com/<Myrepo>/
WORKDIR $GOPATH/src/github.com/<Myrepo>/

RUN dep ensure -vendor-only

当我构建此docker文件时,它挂在RUN dep ensure -vendor-only

When i am building this docker file it hangs at RUN dep ensure -vendor-only

它无法提取作为私有存储库的依赖项

It fails to pull the dependencies which are private repos

是否可以在Docker内部存储git凭证,或者是否可以通过一个或多个GOlang私有存储库来构建Docker

Is there any possiblities to store git credentials inside Docker or any way to build Docker with one or more private repos of GOlang

推荐答案

添加 .netrc 文件将在Docker容器内传递凭据,并有助于提取多个私有存储库以建立依赖关系

Adding .netrc file will pass credentials inside the docker containers and helps to pull more than one private repositories to build dependencies

#vim .netrc
  machine github.com
      login < your github token >

添加这两行并传递您的github令牌

add those 2 lines and pass your github token

FROM golang:1.11.4
RUN apt-get update && apt-get install git bash curl -yqq
ENV ENV test
ENV GIT_TERMINAL_PROMPT=1
ENV GITHUB_TOKEN XXXXXXXXXXXXXXXXXX 

RUN curl -Ls https://github.com/Masterminds/glide/releases/download/v0.12.3/glide-v0.12.3-linux-amd64.tar.gz | tar xz -C /tmp \
&& mv /tmp/linux-amd64/glide /usr/bin/
RUN curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
RUN mkdir -p $GOPATH/src/github.com/<Myrepo>/
COPY . $GOPATH/src/github.com/<Myrepo>/
COPY .netrc /root/
WORKDIR $GOPATH/src/github.com/<Myrepo>/

RUN dep ensure -vendor-only

这篇关于在Docker内运行dep sure -vendor-only-only挂起无法提取私有存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-01 21:33