Moving to our own meteor docker infrastructure



Moving to our own meteor docker infrastructure

0 0


moving-to-our-own-meteor-docker-infrastructure

Moving to our own meteor docker infrastructure

On Github peterpeerdeman / moving-to-our-own-meteor-docker-infrastructure

Moving to our own meteor docker infrastructure

@peterpeerdeman

from

to

Why

application portability
availability problems
slow support response
control over servers and expenses
scalability and reproducability

What is Docker?

"Docker is an open-source program that enables a Linux application and its dependencies to be packaged as a container."

Virtual Machines

Containers

In practice

Think of it like creating and mounting an ISO file

In practice

  • convert dvd to iso
  • upload the iso file
  • install fake dvd drive
  • download iso
  • mount iso
  • building a container
  • pushing container to repository
  • install docker
  • pull container
  • run the container

Docker build file

                        
FROM node:0.10.40-wheezy

RUN curl https://install.meteor.com/ | sh && \
    apt-get install -y imagemagick

COPY . /code
WORKDIR /code

RUN cd app && \
    meteor build --directory . && \
    cd bundle/programs/server && \
    npm install

EXPOSE 3000
CMD ["node", "app/bundle/main.js"]
                        
                    

building and pushing the docker image

                        

docker build . --tag=$GIT_COMMIT

                        
                    
                        

docker login -e test@test.com -p password
docker push lifely/partup:$GIT_COMMIT

                        
                    
"Jenkins is an award-winning, cross-platform, continuous integration and continuous delivery application that increases your productivity."

Jenkins "Docker build step plugin"

triggers on each git commit

pull and run the container

                        

docker pull lifely/partup:$GIT_COMMIT

                        
                    
                        

docker run lifely/partup:$GIT_COMMIT -p 3000:3000 -e MONGO_URL=mongodb://locationofyourmongo -e MAIL_URL: smtp://locationofyouremailserver

                        
                    

Ansible docker module

                        
---
- name: docker | start application
  docker:
    name: app
    image: "lifely/partup:{{ tag }}"
    username: "{{ docker.registry.username }}"
    email: "{{ docker.registry.email }}"
    password: "{{ docker.registry.password }}"
    state: reloaded
    restart_policy: always
    pull: always
    ports:
      - "{{ansible_eth1.ipv4.address}}:3000:3000"
    env: "{{ app.env }}"
  tags: app

                        
                    

http://docs.ansible.com/ansible/docker_module.html

Loadbalancer

Nginx + Nginx Sticky Module

nginx config

                        
upstream webapp {
    sticky secure;
    server 10.131.97.50:3000;
    server 10.131.77.207:3000;
}
                        
                    

https://bitbucket.org/nginx-goodies/nginx-sticky-module-ng/

DEMO

Disadvantages

  • Ops experience required
  • Plenty of alternatives (modulus, scalingo, galaxy)
  • Image building lengthens deploy loop cycle
  • Own loadbalancing required when scaling

Advantages

  • Hassle free instance creation
  • Full control over servers/ instances
  • Portability of application
  • Cheaper than hosted alternatives

Should everyone be doing this?

"no"

Thank you for your attention

Moving to our own meteor docker infrastructure

@peterpeerdeman