docker - 在 Docker 中运行 dep ensure -vendor-only 挂起无法拉取私有(private) repo

标签 docker go dockerfile dep glide-golang

我的 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

它无法拉取私有(private)仓库的依赖项

是否有可能在 Docker 中存储 git 凭据或以任何方式使用一个或多个 GOlang 私有(private)存储库构建 Docker

最佳答案

使用这样的东西

# 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

引用this将 ssh key 添加到你的 git 仓库

关于docker - 在 Docker 中运行 dep ensure -vendor-only 挂起无法拉取私有(private) repo ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55058056/

相关文章:

go - 语义 - 将外部接口(interface)类型值传递给内部接口(interface)变量

go - 获取在 kubebuilder 中触发 Controller 的事件类型

docker - 在amazonlinux docker镜像上安装python3.6

docker 撰写 : absolute path for shared volumes in version 3

docker - 在 kubernetes pod 中运行 nginx 容器,该容器具有使用 Gunicorn 运行的 python 应用程序

linux - 更改 docker 容器内的/proc/sys/kernel/core_pattern 文件

docker - Docker工具箱卷安装在Windows 10上不起作用

Dockerized Vue 应用程序 - 热重载不起作用

go - 是我的 gofmt 工作错误还是我不明白什么?

tomcat - 使用 Docker-compose 将文件复制到 Docker 容器中的 tomcat webapps 文件夹