Slide 1

Slide 1 text

Building reproducible dev environments with Docker @grahamgilchrist

Slide 2

Slide 2 text

Scenario 1 - The old project

Slide 3

Slide 3 text

Scenario 2 - The new member of staff Image credit: Paul Inkles https://www.flickr.com/photos/dumfstar/8553473662

Slide 4

Slide 4 text

Scenario 3 - The missing documentation

Slide 5

Slide 5 text

Scenario 4 - Different hardware, different OS

Slide 6

Slide 6 text

The problem ● Large number of projects and variations on environments ● Different hardware, operating systems and software versions trying to run same project ● Environment setup in installation guide is forgotten or becomes out of date ● All these things take up your time to maintain, often fixing the same issue on multiple machines

Slide 7

Slide 7 text

How do we keep the environments consistent and automate this boring job? Image credit: Steve Jurvetson https://www.flickr.com/photos/jurvetson/9690512888/

Slide 8

Slide 8 text

We want a solution that: 1. Stores environment config versioned with project code 2. Makes everyone use the same environment 3. Is reproducible from scratch 4. Automate the build process

Slide 9

Slide 9 text

+ docker compose

Slide 10

Slide 10 text

Advantages of Docker over VM ● Run speed ● Build speed (image and build step caching) ● Disk space - economical re-use of base system images etc. ● Re-use of common services between projects ● Large resource of pre-built community images setup via the docker hub image registry

Slide 11

Slide 11 text

Typical web project > docker-compose up project docker-compose.yml

Slide 12

Slide 12 text

python docker-compose.yml python: build: python/ command: manage.py runserver environment: DATABASE_URL: 'postgres://dbname@db/postgres' volumes: - ./python:/usr/src/app links: - db ports: - "8000:8000" db: image: postgres:9.3 ports: - "5432:5432"

Slide 13

Slide 13 text

python Dockerfile FROM python:3.4.3 # We add libmemcached from debian repositories RUN apt-get update && \ apt-get install -y \ libmemcached-dev \ && rm -rf /var/lib/apt/lists/* RUN mkdir -p /usr/src/app WORKDIR /usr/src/app COPY requirements.txt /usr/src/app/ RUN pip install -r requirements.txt

Slide 14

Slide 14 text

NodeJS docker-compose.yml grunt: build: node/ volumes: - ./web:/usr/src/app command: grunt bower: image: blinkmobile/bower:1.3.12 environment: bower_allow_root: true bower_analytics: false working_dir: /data volumes: - ./web:/data

Slide 15

Slide 15 text

How is it working out for us? Much higher bus factor Saving time Image credits: Tom Page https://www.flickr.com/photos/tompagenet/6935847473/ Steve Collis https://www.flickr.com/photos/swampa/8105520673/

Slide 16

Slide 16 text

Outstanding issues ● Mac OS - not native ○ slow for disk access via volume mounts ● SSH issues ○ rsync, ssh ○ installing packages via github ssh auth ● Learning curve for 'the docker way' ○ Separation concepts are hard and totally new to most devs. ○ Hard to get people to configure it themselves

Slide 17

Slide 17 text

Future improvements Identical dev / Deployment setup Issues on Mac OS Image credit: Steve Jurvetson https://www.flickr.com/photos/jurvetson/3327872958

Slide 18

Slide 18 text

Thanks! Final thoughts @grahamgilchrist