简体   繁体   English

使用TFS将docker映像部署到AWS ECR

[英]Deploy docker image with TFS to AWS ECR

I'm building docker images with TFS. 我正在使用TFS构建Docker映像。 After the image is build I would like to push it to Amazon EC2 Container Registry (ECR). 生成映像后,我想将其推送到Amazon EC2容器注册表(ECR)。

What is the best way to achieve this? 实现此目标的最佳方法是什么?

There is a extension for TFS to eg upload data to AWS S3 or run AWS CLI commands. TFS有一个扩展,例如可以将数据上传到AWS S3或运行AWS CLI命令。 With the CLI I could run aws ecr get-login --no-include-email --region xxx and then push the image manually. 使用CLI,我可以运行aws ecr get-login --no-include-email --region xxx ,然后手动推送映像。 As our buildserver is a linux machine and "AWS Tools for Windows PowerShell Script" runs only on Windows it also does not work. 由于我们的buildserver是一台Linux计算机,并且“用于Windows PowerShell脚本的AWS工具”仅在Windows上运行,因此它也不起作用。

The TFS extension mentioned in the question supports now pushing images to ECR. 问题中提到TFS扩展现在支持将图像推送到ECR。 (Version 1.0.14) (版本1.0.14)

There is now the "AWS Elastic Container Registry Push" task 现在有“ AWS Elastic Container Registry推送”任务 在此处输入图片说明

I would avoid the extension and just figure out how to get TFS to trigger shell scripts upon successful build. 我会避免扩展,而只是想出如何在成功构建后使TFS触发Shell脚本。 (I don't know exactly how to do that half of the equation, but I do know how to do the rest). (我不知道该怎么做方程式的那一半,但我知道如何去做其余的)。

You can download the AWS CLI for Unix , which gives you this command. 您可以下载适用于UnixAWS CLI ,它提供了此命令。 Then docker login $(aws ecr get-login --no-include-email --region xxx) as you've seen and docker push your image to the ECR you've created. 然后,如您所见, docker login $(aws ecr get-login --no-include-email --region xxx)docker login $(aws ecr get-login --no-include-email --region xxx) docker push映像docker push送到您创建的ECR。

The best practice I've seen is to keep the little "build scripts" like this in the same repository as your code, in like a build-scripts folder or something. 我见过的最佳实践是将像这样的小“构建脚本”与代码保存在相同的存储库中,例如build-scripts文件夹之类。 Then the "hard part" is only hooking up TFS to run that script on success, and that's all that needs to know. 然后,“困难的部分”只是连接TFS以成功运行该脚本,这就是所有需要知道的。

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

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