A build spec is a collection of build commands and related settings, in YAML format, that AWS CodeBuild uses to run a build.
You are going to include a build specification as part of the source code.
You are going to add
buildspec.yml to Northwind solution, not CDK project.
buildspec.yml file in the root of the solution (next to
Northwind.sln file) that describes how to build and publish Docker container to the Amazon ECR.
version: 0.2 phases: install: runtime-versions: docker: 18 pre_build: commands: - echo Logging in to Amazon ECR... - $(aws ecr get-login --no-include-email --region $AWS_DEFAULT_REGION) build: commands: - echo Build started on `date` - echo Building the Docker image... - docker build -t $IMAGE_REPO_NAME:$IMAGE_TAG . - docker tag $IMAGE_REPO_NAME:$IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG post_build: commands: - echo Build completed on `date` - echo Pushing the Docker image... - docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_DEFAULT_REGION.amazonaws.com/$IMAGE_REPO_NAME:$IMAGE_TAG
This build spec simply does the following:
Please note the following environment variables that you will setup in next module:
AWS_DEFAULT_REGIONwith a value of region ID
AWS_ACCOUNT_IDwith a value of account ID
IMAGE_TAGwith a value of Latest
IMAGE_REPO_NAMEwith a value of Amazon ECR repository name
Add this new file to source control:
git add buildspec.yml git commit -m "Add buildspec file" git push aws master
git add buildspec.yml git commit -m "Add buildspec file" git push origin master