This Amazon Cloud Development Kit (CDK) project provides you with a continuous integration (CI) pipeline to build Docker images and push them to Amazon Elastic Container Registry (ECR).
This project deploys:
-
An empty AWS CodeCommit repository to later hold your Dockerfile. We will call this your "Dockerfile repository".
-
An empty ECR container repository, which we will call your "container repository".
-
A AWS CodePipeline pipeline that triggers when changes are pushed to the master branch of your Dockerfile repository. The pipeline passes the contents of your Dockerfile repository to an AWS CodeBuild project. The project executes whatever statements you specify within the
buildspec.yml
file within the Dockerfile repository. At it's heart, these should bedocker build
anddocker push
commands, with a few other administrative requirements. I will provide you with an example, later on.
The AWS CDK is a library that is (as of 11/13/2019) GA for Python, Javascript, and Typescript, and is in preview for Java and .Net. You may refer to the [CDK docs](for details), but at a high level, it is an abstraction over AWS CloudFormation that makes it much faster and simpler to write CloudFormation templates. The abstraction requires far fewer lines of code, but is still ultimately compiled by the accompanying CDK CLI into native CloudFormation and launched as a standard CloudFormation stack.
npm run build
compile typescript to jsnpm run watch
watch for changes and compilenpm run test
perform the jest unit testscdk deploy
deploy this stack to your default AWS account/regioncdk diff
compare deployed stack with current statecdk synth
emits the synthesized CloudFormation template