【发布时间】:2019-03-08 00:27:10
【问题描述】:
我们目前使用 Codeship Pro 将 Docker 镜像推送到 AWS 上的私有注册表,并将这些镜像部署到 ECS 集群。
但是,codeship-steps.yml 文件包含我要推送到的 AWS 区域的硬编码区域名称。例如:
- name: push_production
service: app
type: push
image_name: 123456789012.dkr.ecr.us-east-1.amazonaws.com/project/app-name
image_tag: "{{.Timestamp}}"
tag: master
registry: https://123456789012.dkr.ecr.us-east-1.amazonaws.com
dockercfg_service: aws_generator
我希望能够相当轻松地将其切换为部署到不同的 AWS 区域。因此问题:
是否可以在 codeship-steps.yml 文件中使用变量?
我知道某些属性可以使用 Codeship 提供的少数内置变量(例如用于 image_tag 属性的 {{.Timestamp}} 值),但我不知道是否可以使用值来自env_file 可用于步骤的image_name、registry 和/或command 属性。
我在想象这样的事情......
codeship-steps.yml:
- name: push_production
service: app
type: push
image_name: "123456789012.dkr.ecr.{{.AWS_REGION}}.amazonaws.com/project/app-name"
image_tag: "{{.Timestamp}}"
tag: master
registry: "https://123456789012.dkr.ecr.{{.AWS_REGION}}.amazonaws.com"
dockercfg_service: aws_generator
...但这会导致“在推送步骤中解析图像名称时出错:在推送步骤中引用格式无效”。
我尝试过在image_name 中不指定注册表...
image_name: project/app-name
...但我在推送步骤中收到“构建错误:没有基本身份验证凭据”。在这一点上,我的想法已经不多了。
【问题讨论】:
标签: codeship