This project is setup to be a demo application for an ECS cluster running in Fargate mode.
The only thing special in this source code repo is the buildspec.yml
file.
Code is committed to this repository. CodePipeline pick up the change and triggers a build using CodeBuild. CodeBuild pushes the image to ECR. An ECR cluster will automatically deploy the new image when it's pushed.
- Make sure you tick on
Privileged
in theEnvironment: How to build
. As the documentation says: Enable this flag if you want to build Docker images or want your builds to get elevated privileges. - Make sure you have the IAM permissions in place to interact with ECR for the CodeBuild service role. It will need:
- ecr:GetAuthorizationToken
- ecr:InitiateLayerUpload
- ecr:UploadLayerPart
- ecr:CompleteLayerUpload
- ecr:BatchCheckLayerAvailability
- ecr:PutImage
- When configuring the service, make sure you under
Configure network
selectENABLED
underAuto-assign public IP
. If you don't do this your ECS can't pull your image from ECR. Another way is to use a NAT Gateway.
Build it: docker build -t spring .
Run it: docker container run --rm -p 9090:8080 spring