如何从私有Github回购构建Docker镜像?比如说,来自github.com的?我是一个私人项目团队的一员,在没有登录的情况下我无法访问它。
它也适用于Github Enterprise吗?比如说,github.company.com?因为这个项目将是开源的,我也有同样的需求…
发布于 2019-10-31 02:27:48
您可以使用对Github存储库具有读取访问权限的github个人令牌。使用令牌作为用户名,密码为空:
https://${TOKEN}:@github.company.com/org/repo.git#branch:dir
您可以将URL与令牌放在一起,并且假定Dockerfile位于存储库的根目录中。
下面的任何示例都保存在docker-compose.yaml中。您可以使用以下命令构建它们:
docker-compose build主分支
下面是一个例子:
version: "3"
services:
reference:
build: "https://f4d***3a8:@github.company.com/org/repo.git"
command: ["./wait-for-it.sh", "--timeout=60", "config-server:8888", "--", "java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]
This works! At this point, you can define an environment variable for the token such your OPS team can provide their own token.默认环境令牌
TOKEN或使用默认的version: "3"
services:
reference:
build: "https://${TOKEN:-f4d2***3a8}:@github.company.com/org/repo.git"
command: ["./wait-for-it.sh", "--timeout=60", "config-server:8888", "--", "java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]开发分支中的Dockerfile
可以在#branch中使用
version: "3"
services:
reference:
build: "https://${TOKEN:-f4d***a8}:@github.company.com/org/repo.git#develop"
command: ["./wait-for-it.sh", "--timeout=60", "config-server:8888", "--", "java","-D分支和不同目录中的Dockerfile
在分支#branch:dir之后使用目录。下面的示例使用repo github.company.com/org/repo.git中的目录docker-ci/。
version: "3"
services:
reference:
build: "https://${TOKEN:-f4d***a8}:@github.company.com/org/repo.git#develop:docker-ci"
command: ["./wait-for-it.sh", "--timeout=60", "config-server:8888", "--", "java","-Dhttps://stackoverflow.com/questions/58631670
复制相似问题