简体   繁体   English

在docker Hangs中运行dep sure -vendor-only-only不能拉私有Repos

[英]Running dep ensure -vendor-only inside Docker Hangs not able to pull private Repos

My Dockerfile: 我的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 

When i am building this docker file it hangs at RUN dep ensure -vendor-only 当我构建此RUN dep ensure -vendor-only文件时,它挂在RUN dep ensure -vendor-only

It fails to pull the dependencies which are private repos 它无法拉出作为私有存储库的依赖项

Is there any possiblities to store git credentials inside Docker or any way to build Docker with one or more private repos of GOlang 是否有可能在Docker内部存储git凭证或以任何方式使用一个或多个GOlang私有存储库构建Docker

Use some thing like this 用这样的东西

# ensure that the private Github repo is
# accessed using SSH instead of HTTPS
RUN ssh-keyscan github.com > /root/.ssh/known_hosts
RUN echo "$SSH_KEY" > /root/.ssh/id_rsa && chmod 0600 /root/.ssh/id_rsa
RUN echo '[url "ssh://git@github.com/*your_repo*/"]' >> /root/.gitconfig && echo 'insteadOf = https://github.com/*your_repo*/' >> /root/.gitconfig

Refer this to add ssh key to your git repo 引用将SSH密钥添加到您的git repo

Adding .netrc file will pass credentials inside the docker containers and helps to pull more than one private repositories to build dependencies 添加.netrc文件将在Docker容器内传递凭据,并有助于拉取多个私有存储库以建立依赖关系

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

add those 2 lines and pass your github token 添加这两行并传递您的github令牌

 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 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM