Home > front end >  AWS CDK: How to reference custom Docker image from public ECR repository
AWS CDK: How to reference custom Docker image from public ECR repository

Time:10-19

I've successfully tested out a manual CodePipeline/CodeBuild test action to run Cypress UI tests with the public Docker image public.ecr.aws/cypress-io/cypress/browsers:node16.17.0-chrome106

Now on trying to codify the setup into CDK, I can't find a complete code example on how to reference the custom image. The docs only offers a very terse block that doesn't explain where the (public) ECR repository comes from.

https://docs.aws.amazon.com/cdk/api/v2/dotnet/api/Amazon.CDK.AWS.CodeBuild.html

Environment = new BuildEnvironment {
    BuildImage = LinuxBuildImage.FromEcrRepository(ecrRepository, "v1.0")
}

Checking out the AWS.ECR namespace doesn't explain how to reference public repositories with the static methods either.

https://docs.aws.amazon.com/cdk/api/v2/dotnet/api/Amazon.CDK.AWS.ECR.Repository.html#methods

How is the CodeBuild project's BuildEnvironment object supposed to be coded to properly use that public custom image?

CodePudding user response:

BuildImage = LinuxBuildImage.FromDockerRegistry("public.ecr.aws/docker/library/node:16-bullseye-slim")

  • Related