简体   繁体   English

Github:在具有多个 Dockerfile 的存储库中构建 docker 映像

[英]Github: Building a docker image in a repository with multiple Dockerfile

I have a repository that has multiple directories each containing a python script, a requirements.txt, and a Dockerfile.我有一个存储库,它有多个目录,每个目录都包含一个 python 脚本、一个 requirements.txt 和一个 Dockerfile。 I want to use Github actions to build an image on merge to the main branch and push this image to Github packages.我想使用 Github 操作在合并到主分支时构建图像,并将此图像推送到 Github 包。 Each Dockerfile defines a running environment for the accompanying python script.每个 Dockerfile 都为随附的 python 脚本定义了一个运行环境。 But want to build only that directory's Dockerfile on which changes are made and tag each image with the directory name and a version number that is different from other directories version changes.但只想构建该目录的 Dockerfile 并在其上进行更改,并使用目录名称和与其他目录版本更改不同的版本号标记每个图像。 How can I accomplish this?我怎样才能做到这一点? An example workflow.yml file would be awesome.一个示例 workflow.yml 文件会很棒。

Yes, it is possible.对的,这是可能的。

In order to trigger a separate build for every Dockerfile, you will need a separate workflow - eg for every Dockerfile - one workflow.为了为每个 Dockerfile 触发单独的构建,您将需要一个单独的工作流 - 例如对于每个 Dockerfile - 一个工作流。 The workflows should be triggered on push to main and specify paths for the Dockerfile.工作流应在推送到 main 时触发,并为 Dockerfile 指定路径

For building the images themselves you can use GitHub Action Build and push Docker images要自己构建图像,您可以使用 GitHub Action Build 并推送 Docker 图像

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

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