Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cloud Native Developer workflows for Docker

Cloud Native Developer workflows for Docker

A talk from DockerCon EU 2018 about software development building blocks with Docker, how they are linked together into workflows, and various new tools aimed at reducing developer friction.

Gareth Rushgrove

December 05, 2018
Tweet

More Decks by Gareth Rushgrove

Other Decks in Technology

Transcript

  1. - The building blocks for Docker applications - What we

    mean by developer workflow - Reducing developer friction - Lots of demos What we’ll cover
  2. - Describe the steps to build a Docker image -

    More than 1.1m Dockerfiles public on GitHub Dockerfile # We name the `base` stage so we can reference it in multiple later # stages but only need to update it in one place if we change it FROM python:3-alpine AS base WORKDIR /app RUN pip install pipenv==2018.10.13 COPY Pipfile /app/ COPY Pipfile.lock /app/ RUN pipenv install --system --deploy # The `app` stage is used as the base for images that don't # need the development dependencies FROM base AS app COPY src /app # The `test-base` stage is used as the base for images that require # the development dependencies. FROM base AS test-base
  3. Compose and Kubernetes config - Describe the components of your

    multi-service application in code version: '3.7' services: sensu-backend: image: sensu/sensu:latest command: sensu-backend start hostname: sensu-backend ports: - 3000:3000 - 8080:8080 sensu-agent: image: sensu/sensu:latest command: sensu-agent start --backend-url ws://sensu-backend:8081 depends_on: - sensu-backend deploy: replicas: 4
  4. Your source code - The most important part. Your application.

    export default () => ( <div> Hello world <p>scoped!</p> <style jsx>{` p { color: blue; } div { background: red; } @media (max-width: 600px) { div { background: blue; } } `}</style>
  5. workflow Noun the sequence of industrial, administrative, or other processes

    through which a piece of work passes from initiation to completion.
  6. The hard way - Just use the low-level tools -

    Workflow is by memory, or maybe documentation if you’re lucky $ kubectl run --image hello-dockercon:1 hello --port=8080 deployment.apps "hello" created $ kubectl get deployment hello -o json { "apiVersion": "extensions/v1beta1", "kind": "Deployment", "metadata": { "annotations": { "deployment.kubernetes.io/revision": "1" }, "creationTimestamp": "2018-11-26T12:42:53Z", "generation": 1, "labels": { "run": "hello" }, "name": "hello", "namespace": "default",
  7. Pick and mix - Wrap everything in a Makefile (or

    similar) - Introduce other tools $ make do-everything
  8. From within an IDE - Integrated functionality in your editor

    - Customisation via plugins $ cat spec.txt Cloud Native Application Bundle Core 1.0.0 (CNAB1) Working Draft, Nov. 2018 Cloud Native Application Bundles (CNAB) are a standard packaging format for multi-component distributed applications. It allows packages to target different runtimes and architectures. It empowers application distributors to package applications for deployment on a wide variety of cloud platforms, cloud providers, and cloud services. It also provides the capabilities necessary for delivering multi-container applications in disconnected environments. CNAB is not a platform-specific tool. While it uses
  9. The same fundamentals - Writing code - Testing code -

    Building artefacts - Running code
  10. Docker registry - Store your artefacts centrally - Avoid the

    need to constantly rebuild and retest
  11. The same fundamentals - Writing code - Testing code -

    Building artefacts - Running code
  12. Build - Multi-stage builds can reduce the need for scripts

    - New tools like docker assemble reduce the need for configuration at all $ docker fab build . [+] Building 8.2s (13/16) => local://project (docker-hlb.yaml) => => transferring project: 2B => local://project (*.[fc]sproj) => => transferring project: 2B => local://project (pom.xml) => => transferring project: 29B => resolve image config for docker.io/library/maven:3-jdk-10-slim => resolve image config for docker.io/docker/dockerfile-copy:v0.1.8 => resolve image config for docker.io/library/openjdk:10-jre-slim => runtime image => => resolve docker.io/library/openjdk:10-jre-slim@sha25 => => sha256:7e9a9557c5738bcf45787bbc6bf5fff60f06562c2ddb
  13. Inner-loop development - Change code or configuration, automatically rebuild images

    and run application locally $ cat skaffold.yaml apiVersion: skaffold/v1alpha5 kind: Config build: tagPolicy: sha256: {} artifacts: - image: garethr/skaffold-example local: useBuildkit: true deploy: kubectl: manifests: - stack.yaml
  14. Testing - Fast feedback - Share tests between applications to

    help enforce organisational policy $ cat .github/main.workflow action "test" { uses = "actions/docker/cli@master" args = "build --target test ." } action "security" { uses = "actions/docker/cli@master" secrets = ["MICROSCANNER"] args = "build --target security --build-arg MICROSCANNER } action "lint" { uses = "actions/docker/cli@master" args = "run -i hadolint/hadolint hadolint - <Dockerfile" }
  15. Packaging multi-service applications - Share applications with others easily with

    docker app - Reduce operator friction by defining clear interfaces $ docker-app install garethr/myapp Waiting for the stack to be stable and running... service1: Ready service2: Ready mysql: Ready Stack hello is stable and running
  16. - Always be looking for ways to reduce developer friction

    - Improvements might be incremental, or they might be revolutionary - Composable tools are one honking great idea, let's do more of those! In summary
  17. Take A Breakout Survey Access your session and/or workshop surveys

    for the conference at any time by tapping the Sessions link on the navigation menu or block on the home screen. Find the session/workshop you attended and tap on it to view the session details. On this page, you will find a link to the survey.