使用 docker push
将包发布到 Github 包注册表时,似乎该包链接到主分支上的最新提交。但是,我目前正在不同的分支上或特定标签上构建我的包。有没有办法将发布的图像绑定(bind)到特定的 git 提交,以便链接到图像的源代码 Assets 是正确的?
最佳答案
帮助页面“Configuring Docker for use with GitHub Package Registry”提到:
Push the image to GitHub Package Registry:
$ docker push docker.pkg.github.com/OWNER/REPOSITORY/IMAGE_NAME:VERSION
所以只要你已经从任何你想要的 Git 提交中构建并标记了你的图像,
docker push
step 独立于所述 Git 提交:它仅依赖于您构建的内容。您可以将变量添加到您的
docker build
包括 Git 信息。参见 How to Tag Docker Images with Git Commit Information 中的“Scott Lowe”
docker build -t flask-local-build --build-arg GIT_COMMIT=$(git log -1 --format=%h) .
docker inspect flask-local-build | jq '.[].ContainerConfig.Labels'
关于git - 在 Github 包注册表中绑定(bind) Docker 镜像以更正 Github 提交,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57583915/