0
votes

I'm building docker images with TFS. After the image is build I would like to push it to Amazon EC2 Container Registry (ECR).

What is the best way to achieve this?

There is a extension for TFS to e.g. upload data to AWS S3 or run AWS CLI commands. With the CLI I could run aws ecr get-login --no-include-email --region xxx and then push the image manually. As our buildserver is a linux machine and "AWS Tools for Windows PowerShell Script" runs only on Windows it also does not work.

2

2 Answers

1
votes

The TFS extension mentioned in the question supports now pushing images to ECR. (Version 1.0.14)

There is now the "AWS Elastic Container Registry Push" task enter image description here

0
votes

I would avoid the extension and just figure out how to get TFS to trigger shell scripts upon successful build. (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. 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.

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. Then the "hard part" is only hooking up TFS to run that script on success, and that's all that needs to know.