This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Containers can be used in two ways: • Execution environment for the build jobs • Output of the build process itself
Containers as build execution environment
Containers as build artifacts
Amazon EC2 Container Registry
• Security• IAM Resource-based Policies• CloudTrail Audit Logs• Images encrypted at transit and at rest
• Easily Manage & Deploy Images• Tight Integration with ECS• Integration with Docker Toolset• Management Console & AWS CLI
• Reliability & Performance• S3 Backed
Stage 3 - Test
Test environment
Test environment
Running test inside a container
Usual Docker commands available within your test environmentRun the container with the commands necessary to execute your tests, e.g.:docker run web bundle exec rake test
Running test against a container
Start a container running in detached mode with an exposed port serving your appRun browser tests or other black box tests against the container, e.g. headless browser tests
Stage 4 - Deploy
Deployment environment
Deployment environment
Amazon EC2 Container Service
• Highly scalable container management service• Easily manage clusters for any scale• Flexible container placement• Integrated with other AWS services• Extensible
• Amazon ECS concepts• Cluster and container instances• Task definition and task
Recent Enhancements to ECS
• Task Roles• Dynamic Port Mapping and path based routing• Auto-scaling policies for services• Network modes for Docker
AWS Elastic Beanstalk
• Deploy and manage applications without worrying about the infrastructure
• AWS Elastic Beanstalk manages your database, Elastic Load Balancing (ELB), Amazon ECS cluster, monitoring and logging
• Docker support• Single container (on Amazon EC2)• Multi container (on Amazon ECS)
Amazon ECS CLI
• Easily create Amazon ECS clusters & supporting resources such as EC2 instances
• Run Docker Compose configuration files on Amazon ECS
# Configure the CLI using an existing AWS CLI profile> ecs-cli configure --region us-west-2 --profile ecs-profile --cluster ecs-cli-demo
Deploy and scale Compose app with ECS CLI
# Deploy a Compose app as a Task or as a Service> ecs-cli compose up> ecs-cli compose ps > ecs-cli compose service create> ecs-cli compose service start
# Scale a Compose app deployed as a Task or as a Service> ecs-cli compose scale n> ecs-cli compose service scale n
Continuous Delivery Workflows
Continuous delivery to ECS with Jenkins
4. Push image to Docker registry
2. Build image from sources 3. Run test on image
1. Code push triggers build
5. Update Service
6. Pull image
Continuous delivery to ECS with Jenkins
Easy DeploymentDevelopers – Merge into master, done!
Jenkins Build StepsTrigger via Webhooks, Monitoring, LambdaBuild Docker image via Build and Publish plugin Push Docker image into RegistryRegister Updated Job with ECS API
Continuous delivery to ECS with CodePipeline
1. Code push triggers pipeline
2. Lambda function creates EC2 instance
3. Image is built and pushed to ECR
4. Lambda function terminates EC2 instance
5. Lambda function deploy new task revision to ECS
Continuous delivery to ECS with CodePipeline
• Lambda custom actions• Create and terminate EC2 instance• Update ECS service
• EC2 instance uses user data to build an image and push it to Amazon ECR