This document discusses using Jenkins and Amazon ECS for continuous delivery of Docker containers. It describes setting up a Jenkins master and agent in AWS, using plugins to manage Docker containers. The Jenkinsfile and Dockerfile are kept in source control. The pipeline builds a Docker image, pushes it to Docker Hub, then updates an ECS service to deploy the new image. Finally, it provides the URLs to demo the continuous delivery pipeline deploying an app to staging and production environments on ECS.
5. What is Jenkins?
Over
1000 Jenkins
Plugins
Integration
with over 100
DevOps Tools
Orchestration
of the DevOps
Toolchain
End-to-End
CD Pipeline
Management
Code & Commit Build & Config Scan & Test Release Deploy
16. The Jenkinsfile
● Kept in GitHub project’s root directory, Jenkins executes
● Scripts out the target deployment pipeline
● Triggered by pipeline job
17. The Dockerfile
● Kept in GitHub project’s root directory - copied into the Jenkins workspace
● Copies built artifact into a Docker container running Tomcat 8
● Triggered by pipeline step
18. Target Docker registry - Docker Hub
● Docker pipeline step “withRegistry” specifies target registry for push
● “push” step sends built image to target registry, tagged “docker-demo”
19. Target flow in ECS
● ECS steps run in an agent container (cloudbees/java-build-tools:0.0.7.1) with
AWS CLI
○ AWS credentials in Jenkins
○ Wraps AWS-related services
○ Calls ECS agent to trigger task that pulls the newly built app image
○ Checks ECS service status
○ “update-service” = “docker stop”
○ Manually gated deployment
20. Target environments in ECS
● 2 clusters: “production” and “staging” for the webapp
○ Service per cluster
■ Task definitions for pulling the app image
○ EC2 instance per cluster
■ “ECS-optimized”
■ IAM roles
23. Additional reading
Jenkins Pipeline
How to point Jenkins to a custom registry (e.g. local)
Setting up Jenkins slaves on AWS
Game of Life pipeline deployment to ECS
AWS’s alternative approach to building a pipeline with Jenkins and ECS
Creating an ECS cluster with ELB and autoscaling
Building multiple containers with Docker Compose and pipeline
Blue-green ECS deployments
24. Jenkins goodies
Join our meetup group(s)!
Jenkins http://www.meetup.com/San-Francisco-Jenkins-Area-Meetup/
Product management http://www.meetup.com/San-Jose-Product-
Management-Meetup/
Upcoming area events
Jenkins World - Sept 13-15 in Santa Clara
Jenkins 2.0 Webcast - May 17 online
JFrog swampUp - May 23 in Napa
Hinweis der Redaktion
Build a Github-based project : https://github.com/lavaliere/couchbase-javaee
Any push to the source code should
Build the workspace
Run the tests
Build Docker image using Dockerfile
Deploy it to a Docker registry
Kill previously running container
Start a new container using this image
Build a Github-based project https://github.com/lavaliere/couchbase-javaee/blob/master/Docker-Pipeline.md
Any push to the source code should
Build the workspace
Run the tests
Build Docker image using Dockerfile
Deploy it to a local Docker registry
Kill previously running container
Start a new container using this image
Build a Github-based project : https://github.com/lavaliere/couchbase-javaee
Any push to the source code should
Build the workspace
Run the tests
Build Docker image using Dockerfile
Deploy it to a local Docker registry
Kill previously running container
Start a new container using this image
Build a Github-based project : https://github.com/lavaliere/couchbase-javaee
Any push to the source code should
Build the workspace
Run the tests
Build Docker image using Dockerfile
Deploy it to a local Docker registry
Kill previously running container
Start a new container using this image
Any push to the source code should
Build the workspace
Run the tests
Build Docker image using Dockerfile
Deploy it to a local Docker registry
Kill previously running container
Start a new container using this image
Build a Github-based project : https://github.com/lavaliere/couchbase-javaee
Any push to the source code should
Build the workspace
Run the tests
Build Docker image using Dockerfile
Deploy it to a local Docker registry
Kill previously running container
Start a new container using this image