Slide 1

Slide 1 text

Technology that unlocks the value of your professional audience Docker for .NET Developers Steve Gordon - Senior Software Developer Madgex Ltd @stevejgordon | stevejgordon.co.uk youtube.stevejgordon.co.uk https://www.meetup.com/dotnetsoutheast

Slide 2

Slide 2 text

Technology that unlocks the value of your professional audience What we’ll cover • Our journey To Docker • Why use Docker? • What is Docker? • dockerfiles and docker-compose • Using Jenkins for builds • Running containers on AWS ECS

Slide 3

Slide 3 text

Technology that unlocks the value of your professional audience What is Docker? • Containerisation and application platform • Offers frictionless development and deployment • An image is a template for a container • Images are lightweight, standalone packages for an application • A container is a running instance of an image • A host is a physical or virtual machine on which you will run containers (running the Docker Engine)

Slide 4

Slide 4 text

Technology that unlocks the value of your professional audience Lightweight Significantly smaller resource footprint Small unit of deployment Smaller file size Containers vs. Virtual Machines PHYSICAL HOST HOST OS DOCKER ENGINE BINS / LIBS APP A BINS / LIBS APP C BINS / LIBS APP B Reliability Trust that what worked locally will work in production Fast start-up Can start in under 1 second PHYSICAL HOST HOST OS HYPERVISOR GUEST OS GUEST OS BINS / LIBS BINS / LIBS APP B APP A APP C

Slide 5

Slide 5 text

Technology that unlocks the value of your professional audience Microservice based Single responsibility Discrete scaling Independent releases .NET Core & ASP.NET Core Cross platform Improved performance API driven SPA Backend ASP.NET Core APIs Madgex Insights

Slide 6

Slide 6 text

Technology that unlocks the value of your professional audience Insights Architecture FRONT END SPA USER API SCHEDULE API REPORT API QUERY API ELASTICSEARCH

Slide 7

Slide 7 text

Technology that unlocks the value of your professional audience Developer Workflow PULL CLIENT PROJECT PULL PLATFORM BUILD x2 EDIT DOCKER-COMPOSE PULL EDIT DOCKER-COMPOSE UP

Slide 8

Slide 8 text

Technology that unlocks the value of your professional audience “This is amazing!” James Wragg (Senior Front End Developer at Madgex)

Slide 9

Slide 9 text

Technology that unlocks the value of your professional audience Developing with Docker On Windows • Docker for Windows (Win 10 Pro) • Docker Toolbox (Win 7 / Win 8 / Win 10 Home) On Mac • Docker for Mac (OS X El Capitan 10.11 or newer) • Docker Toolbox Visual Studio • Visual Studio Tools for Docker VS Code • Install the vscode-docker extension

Slide 10

Slide 10 text

Technology that unlocks the value of your professional audience Demo dockerfiles Building and running an image

Slide 11

Slide 11 text

Technology that unlocks the value of your professional audience Anatomy of an image – ASP.NET Core 2.0 Build Image FILE SYSTEM – DEBIAN STRETCH - debian:stretch (45MB) DEPENDENCIES (PACKAGES) – CURL - buildpack-deps:stretch-curl (61MB) DEPENDENCIES (PACKAGES) – SCM - buildpack-deps:stretch-scm (111MB) .NET CORE SDK AND CLI - microsoft/dotnet:2.0.6-sdk-2.1.104-stretch (580MB) ASP.NET CORE NUGET PACKAGE CACHE - microsoft/aspnetcore-build:2.0 (699MB) YOUR ASP.NET APPLICATION SCRATCH

Slide 12

Slide 12 text

Technology that unlocks the value of your professional audience Naming and Tagging Images registry-prefix/name:tag • We can optionally name and tag images during build using –t or --tag • Image names can contain lowercase letters, digits and separators • Image names can be optionally prefixed with a registry hostname • A tag can be used to specify a “version” of an image e.g. myservice:1.02 • You can tag a pre-existing image using the docker image tag command

Slide 13

Slide 13 text

Technology that unlocks the value of your professional audience Images pushed to a registry Store for images Docker Registries Images pulled from a registry REGISTRY 123456789012.dkr.ecr.eu-west-2.amazonaws.com docker push 123456789012.dkr.ecr.eu-west-2.amazonaws.com/myimage:1.1 docker pull123456789012.dkr.ecr.eu-west-2.amazonaws.com/myimage:1.1

Slide 14

Slide 14 text

Technology that unlocks the value of your professional audience Demo docker-compose Build and run multiple images

Slide 15

Slide 15 text

Technology that unlocks the value of your professional audience Docker in Production AWS ECR AWS ECS PRODUCTION

Slide 16

Slide 16 text

Technology that unlocks the value of your professional audience Orchestration • Tool(s) to assist with the management of multiple containers • Automated deployment with rollback support • Scaling • Health monitoring and healing of failed containers • Service discovery • Load balancing • Configuration management

Slide 17

Slide 17 text

Technology that unlocks the value of your professional audience Amazon ECS Services Manage how tasks run and scale. ALB CLUSTER EC2 INSTANCE ECS AGENT TASK A TASK B EC2 INSTANCE ECS AGENT TASK A TASK B TASK B SERVICE A Desired Count = 2 Task Def = Task Def A SERVICE B Desired Count = 4 Task Def = Task Def B Task Definition A recipe to execute your application TASK B ECS is a Managed Service No patching or maintenance Cluster Logical grouping of EC2 instances ALB ALB with path routing to multiple services Task A running instance of a task definition

Slide 18

Slide 18 text

Technology that unlocks the value of your professional audience Demo Deploying to AWS ECS using Docker and Jenkins

Slide 19

Slide 19 text

Technology that unlocks the value of your professional audience Zero Downtime Deployments CLUSTER EC2 INSTANCE TASK A ServiceA : v2 EC2 INSTANCE TASK A ServiceA : v3 SERVICE A Desired Count = 1 Task Def = Task Definition A TASK DEFINITION A Task Definition A : 3 Task Definition A : 2 Task Definition A : 1 ECR ServiceA : v1 ServiceA : v2 ServiceA : v3

Slide 20

Slide 20 text

Technology that unlocks the value of your professional audience Challenges and lessons learnt • There is a learning curve… but it's shallow at first • Start with basic dockerfiles – enhance in stages • Get started just by using a pre-built image e.g. Postgres • Amazon ECS a little complex • Use CloudFormation to define ECS environments • Vendor Lock • Logging • Placement of containers – Balance memory/memory reservation

Slide 21

Slide 21 text

Technology that unlocks the value of your professional audience Benefits • Improved developer productivity and reduced onboarding time • No more "it runs on my machine" arguments • Dependable deployments • Simple build and deploy process • Zero downtime, fast, continuous deployments • Lower costs

Slide 22

Slide 22 text

Technology that unlocks the value of your professional audience Thank you @stevejgordon | stevejgordon.co.uk https://www.meetup.com/dotnetsoutheast