soc*_*pet 3 azure docker azure-devops azure-container-service
我正在尝试学习 Azure DevOps Pipelines 和 AKS。最终目标是构建并部署到 Azure Kubernetes 服务,但我将其分解为更小的部分,以便了解每个阶段发生的情况。
因此,我当前的目标是构建并推送到 Azure 容器注册表。
我正在使用一个非常基本的 monorepo,它具有以下简化的结构:
acr-test/
client/
Dockerfile
db/
Dockerfile
server/
Dockerfile
Run Code Online (Sandbox Code Playgroud)
我想为应用程序的每个部分生成一个图像,以便生成一个arc-test-client和。arc-test-server
当我在 Azure DevOps 中“创建管道”并让它构建时,当前发生的情况azure-pipelines.yml是它只是找到第一个Dockerfile并基于它的所有参数,而忽略其他参数。
有些我很好奇:
azure-pipelines.yml?.yml每个我都需要多个吗Dockerfile?.sh来单独构建和推送它们(示例)?azure-pipelines.yml为此修改。.sh脚本,但可能更容易在azure-pipelines.yml你需要做这样的事情:
steps:
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository1)
dockerfile: $(dockerfilePath1)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag1)
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository2)
dockerfile: $(dockerfilePath2)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag2)
- task: Docker@2
displayName: Build and push an image to container registry
inputs:
command: buildAndPush
repository: $(imageRepository3)
dockerfile: $(dockerfilePath3)
containerRegistry: $(dockerRegistryServiceConnection)
tags: |
$(tag3)
Run Code Online (Sandbox Code Playgroud)
或者可以有多个something.yml,并为每个组件进行单独的构建(说实话,更有意义)
或者,根据您的文件结构,您可以重复使用相同的 yaml 文件作为模板并为其提供参数。这将减少代码重复并允许更轻松地管理您的构建
| 归档时间: |
|
| 查看次数: |
2230 次 |
| 最近记录: |