$30 off During Our Annual Pro Sale. View Details »

The DShell Pattern (DevOpsDays London 2019)

David McKay
September 27, 2019

The DShell Pattern (DevOpsDays London 2019)

David McKay

September 27, 2019
Tweet

More Decks by David McKay

Other Decks in Technology

Transcript

  1. The DShell Pattern
    DevOps Days London, 2019

    View Slide

  2. David McKay
    ➔ Developer Advocate for
    InfluxData
    ➔ Kubernetes Release
    Team
    ➔ Tweets @rawkode
    ★ Scottish
    ★ Lover of esoteric
    programming languages
    ★ Likes symmetry

    View Slide

  3. BREAKING NEWS
    Some* developers don’t
    want to use Docker
    * No developer with macOS wants to use Docker

    View Slide

  4. Docker is useful
    Encapsulated
    Dependencies
    Documented Build
    Process
    Deployable

    View Slide

  5. 3 Components
    Dockerfile
    Docker
    Compose
    Makefile

    View Slide

  6. Dockerfile
    Make it work for all environments

    View Slide

  7. Dockerfile
    FROM elixir:1.9-alpine AS base
    FROM base AS development
    RUN apk add --update vim git make
    FROM base AS build
    RUN make compile
    FROM base AS production
    COPY --from=build … ...

    View Slide

  8. Docker Compose
    Make it as (more) painful as possible (than normal)

    View Slide

  9. dshell
    dshell:
    @docker-compose run \
    --rm \
    --service-ports \
    --user $UID \
    --use-aliases \
    --entrypoint=ash \
    myapp

    View Slide

  10. Encourage DShell
    Block Up
    service:
    myapp:
    entrypoint: sh
    command: echo
    Publish Service Ports
    --service-ports
    Override Entrypoint
    --entrypoint=ash

    View Slide

  11. UNPOPULAR OPINION
    DO NOT
    use compose syntax v3
    in dev

    View Slide

  12. Best Practice
    Use Depends On
    depends_on:
    mongodb:
    condition:
    service_healthy
    12-Factor
    env_file: .env
    env_file:
    - .env
    - .env.secret

    View Slide

  13. Makefile
    Unify Developers

    View Slide

  14. The Sausage
    .PHONY: dshell dclean up
    up: deps
    @mix run --no-halt
    compile: deps
    @mix compile

    View Slide

  15. up
    up:
    @npm run develop
    @mix test
    @FLASK_APP=hello flask run

    View Slide

  16. dclean!
    dclean:
    @docker-compose down --rmi=local -v

    View Slide

  17. Final API
    ❏ make dshell [host]
    ❏ make up [container]
    ❏ make test | deps | whatever [container]
    ❏ make dclean [host]

    View Slide

  18. Better Together
    We’re deploying Docker to production (I hope), so encourage (not
    force) it’s usage for local development; make it easy for people to
    dip their toe in.

    View Slide

  19. VSCode Remotes
    {
    "dockerComposeFile": [
    "../docker-compose.yml",
    ],
    "service": "node",
    }

    View Slide

  20. Thank You
    ➔ Follow me on Twitter (@rawkode)
    ➔ At the InfluxData booth
    (I’ve got badges and stickers)
    ➔ Come speak to me about InfluxDB, Cloud Native,
    Monitoring, Docker, or Kubernetes

    View Slide