gpt4 book ai didi

amazon-web-services - aws cdk 将镜像推送到 ECR

转载 作者:行者123 更新时间:2023-12-04 12:29:23 25 4
gpt4 key购买 nike

我正在尝试做一些看起来相当合乎逻辑和直接的事情。
我正在使用 AWS CDK 来配置 ecr 存储库:

     repository = ecr.Repository(
self,
id="Repo",
repository_name=ecr_repo_name,
removal_policy=core.RemovalPolicy.DESTROY
)
然后我有一个 Dockerfile,它位于我的项目的根目录中,我试图将其推送到部署中的同一个 ECR 存储库。
我在相同的服务代码中执行此操作:
    assets = DockerImageAsset(
self,
"S3_text_image",
directory=str(Path(__file__).parent.parent),
repository_name=ecr_repo_name
)
部署正常并继续进行,并创建了 ECR 存储库,但镜像被推送到默认位置 aws-cdk/assets如何让部署将我的 Dockerfile 发送到我希望它存在的确切 ECR 存储库?

最佳答案

AWS CDK 弃用了 repositoryName属性(property)在 DockerImageAsset . GitHub 上有几个问题引用了这个问题。见 this comment来自其中一位开发人员:

At the moment the CDK comes with 2 asset systems:

The legacy one (currently still the default), where you get to specify a repositoryName per asset, and the CLI will create and push to whatever ECR repository you name.

The new one (will become the default in the future), where a single ECR repository will be created by doing cdk bootstrap and all images will be pushed into it. The CLI will not create the repository any more, it must already exist. IIRC this was done to limit the permissions required for deployments. @eladb, can you help me remember why we chose to do it this way?


(aws-ecr-assets) ecr-deployment #12597 处有一个新构造的请求,允许您部署到自定义 ECR 存储库。 .

Use Case

I would like to use this feature to completely deploy my local image source code to ECR for me using an ECR repo that I have previously created in my CDK app or more importantly outside the app using an arn. The biggest problem is that the image cannot be completely abstracted into the assets repo because of auditing and semantic versioning.


https://github.com/wchaws/cdk-ecr-deployment 也有第三方解决方案如果您不想等待 CDK 团队实现新构造。

关于amazon-web-services - aws cdk 将镜像推送到 ECR,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67392204/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com