Slide 1

Slide 1 text

Belgian node.js User Group Nils De Moor - @ndemoor - woorank.com Scaling Node with Docker + Nginx

Slide 2

Slide 2 text

• Nils De Moor • CTO & co-founder at WooRank • #node #mongo #ansible #aws #devops #docker About me

Slide 3

Slide 3 text

Why docker? Source: https://www.docker.io/learn_more/

Slide 4

Slide 4 text

Why docker? Source: https://www.docker.io/learn_more/

Slide 5

Slide 5 text

Why docker? Source: https://www.docker.io/learn_more/

Slide 6

Slide 6 text

Why docker? Source: https://www.docker.io/learn_more/

Slide 7

Slide 7 text

• Isolation • Portability • Compatibility • Automation • Speed Why docker? “Run anything... anywhere”

Slide 8

Slide 8 text

• LXC Containers • “Chroot on steroids” • AUFS • layered view on merged directories • copy-on-write What and how?

Slide 9

Slide 9 text

BUILDING Images Source: https://docs.docker.io

Slide 10

Slide 10 text

git clone github.com/ndemoor/njugbe9

Slide 11

Slide 11 text

• Scripting language • Automated builder • Create images • Cached Dockerfile

Slide 12

Slide 12 text

FROM ubuntu # make sure the package repository is up to date RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update # install memcached RUN apt-get install -y memcached # run as user daemon (memcached doesn't allow to run as root) USER daemon # expose memcached port EXPOSE 11211 # Launch memcached when launching the container # CMD [ "memcached" ] ENTRYPOINT ["memcached"]

Slide 13

Slide 13 text

FROM ubuntu MAINTAINER Nils De Moor RUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.list RUN apt-get update RUN apt-get install -y python-software-properties software-properties-common RUN add-apt-repository ppa:chris-lea/node.js RUN apt-get update RUN apt-get install -y nodejs CMD [ "node" ]

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

FROM njugbe/node:0.10.26 MAINTAINER Nils De Moor ADD . /var/www RUN cd /var/www && npm install EXPOSE 3000 CMD [ "node", "/var/www/server.js" ]

Slide 16

Slide 16 text

0.1

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

0.1

Slide 19

Slide 19 text

0.1 0.2 ?

Slide 20

Slide 20 text

0.1 0.2

Slide 21

Slide 21 text

0.1 0.2

Slide 22

Slide 22 text

# Configuration for the server server { listen 80; location / { proxy_pass http://app_containers; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Host $server_name; } }

Slide 23

Slide 23 text

#!/bin/sh IMAGE=$1 VERSION=$2 DOCKER_ID=`docker run \ -link memcache:mc \ -v /tmp/log/app:/var/log/app:rw \ -p 3000 \ -d \ $IMAGE:$VERSION` PORT=`sudo docker inspect $DOCKER_ID | grep HostPort | cut -d '"' -f 4 | head -1` cat >/etc/nginx/conf.d/app_containers.conf <

Slide 24

Slide 24 text

0 0 0 0

Slide 25

Slide 25 text

• Deis - deployment and orchestration • Dokku - deployment • Fig - deployment • Flynn - deployment and orchestration • Shipyard - monitoring Community

Slide 26

Slide 26 text

Thank you! Belgian node.js User Group Nils De Moor - @ndemoor - woorank.com

Slide 27

Slide 27 text

Thank you! Psst... we’re hiring