Continuous Delivery with Docker and Amazon ECS
-
Upload
amazon-web-services -
Category
Business
-
view
6.880 -
download
3
Transcript of Continuous Delivery with Docker and Amazon ECS
![Page 1: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/1.jpg)
Daniele Stroppa
AWS Solutions Architect
@moviolone
Continuous Delivery with Docker
and Amazon ECS
![Page 2: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/2.jpg)
What to expect from the session
• Best practices for containers in continuous delivery
solutions
• Toolset to implement such solutions
• Demos
![Page 3: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/3.jpg)
Why use containers?
• Process isolation
• Portable
• Fast
• Efficient
![Page 4: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/4.jpg)
Why use containers for continuous delivery?
• Roll out features as quickly as possible
• Predictable and reproducible environment
• Fast feedback
![Page 5: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/5.jpg)
Demo application architecture
Nginx ProxyRuby on Rails
web app
PostgreSQL
on RDS
![Page 6: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/6.jpg)
Development and deployment workflow
Orchestration
layer
Code
repository
Build
environment
Test
environmentDeployment
environment
Source
![Page 7: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/7.jpg)
Stage 1 - Source
![Page 8: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/8.jpg)
Development environment
Code
repository
Source
![Page 9: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/9.jpg)
AWS CodeCommit
• Private Git repository
• Fully managed
• Secure
• Highly available and scalable
• Alternatives:
• Github
• Bitbucket
![Page 10: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/10.jpg)
Docker and Docker Toolbox
• Docker (Linux > 3.10) or Docker Toolbox (OS X,
Windows)
• Define app environment with Dockerfile
![Page 11: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/11.jpg)
Dockerfile
FROM ruby:2.2.2
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev
RUN mkdir -p /opt/web
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN bundle install
ADD . /opt/web
WORKDIR /opt/web
![Page 12: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/12.jpg)
Docker Compose
Define and run multi-container applications:
1. Define app environment with Dockerfile
2. Define services that make up your app in docker-
compose.yml
3. Run docker-compose up to start and run entire app
![Page 13: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/13.jpg)
docker-compose.yml
proxy:
build: ./proxy
ports:
- "80:80"
links:
- web
web:
build: ./web
command: bundle exec rails server -b 0.0.0.0
environment:
- SECRET_KEY_BASE=secretkey
expose:
- "3000"
![Page 14: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/14.jpg)
Amazon ECS CLI
• Easily create Amazon ECS clusters & supporting
resources such as EC2 instances
• Run Docker Compose configuration files on Amazon
ECS
• Available today – http://amzn.to/1jBf45a
![Page 15: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/15.jpg)
Amazon ECS CLI
> ecs-cli configure
> ecs-cli compose build
> ecs-cli compose up --local
![Page 16: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/16.jpg)
It’s Dem-o-clock!
![Page 17: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/17.jpg)
Stage 2 - Build
![Page 18: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/18.jpg)
Build environment
Build
environment
![Page 19: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/19.jpg)
Partners
![Page 20: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/20.jpg)
Jenkins
• Extensible
• Flexible builds
• Ant or Maven based projects
• Docker images
• Optionally runs in Docker container
![Page 21: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/21.jpg)
CloudBees Docker Build and Publish plugin
![Page 22: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/22.jpg)
Stage 3 - Test
![Page 23: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/23.jpg)
Test environment
Test
environment
![Page 24: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/24.jpg)
rspec and capybara-webkit
require 'rails_helper.rb'
feature 'Signing in' do
scenario 'can sign in' do
visit '/users/sign_in'
within("#new_user") do
fill_in 'Email', :with => '[email protected]'
fill_in 'Password', :with => 'password'
end
click_button 'Log in'
expect(page).to have_content('Signed in successfully.')
end
end
![Page 25: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/25.jpg)
Jenkins
• Run tests directly via Docker run
• Run tests in a Docker slave on Amazon ECS
![Page 26: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/26.jpg)
CloudBees Jenkins ECS plugin
![Page 27: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/27.jpg)
Jenkins slave Dockerfile
FROM jenkinsci/jnlp-slave
USER root
RUN apt-get update -qq && \
apt-get install -y -qq git curl wget build-essential […]
RUN apt-get install -y qt5-default libqt5webkit5-dev
RUN apt-get install -y xvfb x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic x11-apps
ENV RUBY_VERSION 2.2.2
RUN echo 'gem: --no-document' >> /usr/local/etc/gemrc &&\
mkdir /src && cd /src && git clone https://github.com/sstephenson/ruby-build.git &&\
cd /src/ruby-build && ./install.sh &&\
cd / && rm -rf /src/ruby-build && ruby-build $RUBY_VERSION /usr/local
![Page 28: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/28.jpg)
Jenkins slave Dockerfile
RUN gem update --system && gem install bundler
# Install Gems
WORKDIR /tmp
ADD Gemfile /tmp/
ADD Gemfile.lock /tmp/
RUN bundle install
USER jenkins
![Page 29: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/29.jpg)
Stage 4 - Deploy
![Page 30: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/30.jpg)
Deployment environment
Deployment
environment
![Page 31: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/31.jpg)
Amazon ECS CLI
> ecs-cli up
> ecs-cli compose up
> ecs-cli compose ps
![Page 32: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/32.jpg)
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)
![Page 33: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/33.jpg)
Putting it all together
![Page 34: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/34.jpg)
Putting it all together
Orchestration
layer
![Page 35: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/35.jpg)
AWS CodePipeline
Model and automate your software release processes
• Rapid delivery
• Configurable workflow
• Customizable
• Highly integrated
![Page 36: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/36.jpg)
It’s Dem-o-clock!
![Page 37: Continuous Delivery with Docker and Amazon ECS](https://reader035.fdocuments.in/reader035/viewer/2022062412/586fb4431a28abe57d8b70a5/html5/thumbnails/37.jpg)
Daniele Stroppa
AWS Solutions Architect
@moviolone
Thank you!