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

Rails and Docker in Production at NDrive

Rails and Docker in Production at NDrive

Our experience in deploying Ruby on Rails webservices with Docker and Ansible in Production.

F39ba0d46b1b830bc15de539ab21542b?s=128

André Freitas

September 24, 2016
Tweet

Transcript

  1. Rails and Docker in Production at NDrive André Freitas github.com/andrefreitas

    Euruko 2016
  2. We build offline gps navigation apps

  3. We have microservices Made with Ruby on Rails, Golang and

    Python
  4. How we build any Rails service? FROM docker.ndrive.com/rails ONBUILD COPY

    Gemfile* /code/ ONBUILD RUN bundle install --without="development test" ONBUILD COPY . /code ONBUILD RUN chown 99:99 -R /code ONBUILD USER 99 ONBUILD ARG version ONBUILD LABEL com.ndrive.version=$version DOCKER_TAG=0.1.0 make docker-build docker-push
  5. How we deploy? ansible-playbook site.yml -i production.ini --limit web1.ndrive.com --tags

    store environment server or group of servers service
  6. - name: container docker: name: auth state: reloaded restart_policy: always

    pull: always net: bridge log_driver: journald image: "docker.ndrive.com/auth:{{ auth.tag }}" ports: - "4001:4001" volumes: - /srv/settings/auth.json:/code/config/settings.json Example of an Ansible Role
  7. Dashboard of Containers (Rancher)

  8. Logs - Rails logs to stdout - Container sends logs

    to Journald journalctl CONTAINER_NAME=auth -f
  9. Pros of Docker - Configuration of servers is simple -

    We build all in a single artifact (Docker image) - Less surprises in deployments - Easy to spin up a test environment (CI) - Friend of microservices
  10. Cons of Docker - We need to know how to

    deal with Docker issues - Low maturity in orchestration (maybe Swarm or Rancher in the future) - Risky for databases
  11. Links - http://docs.ansible.com/ansible/docker_contain er_module.html - http://rancher.com/rancher/