SlideShare uma empresa Scribd logo
1 de 33
Dockerizing Ruby
Applications- The Best
Practices
Lauri Nevala, Co-Founder and Software Engineer
Kontena briefly
© 2015 Kontena, Inc.
What is Kontena?
Open Source container platform built
to maximize developer happiness.
Works on any cloud, easy to setup,
simple to use.
Quick Facts
650+GITHUB STARGAZERS
>100kNUMBER OF INSTALLS
FEATURED IN
The Container Platform
All Batteries Included!
Built-In Image Registry
Sometimes projects can not use publicly
hosted container image registries like
DockerHub. Kontena comes with built-in
container image registry providing private
and secure solution.
Built-In VPN Access
All containers are run inside a virtual private
network by default. Nothing is exposed to
Internet unless explicitly defined. With
Kontena’s built-in VPN access developers
can securely access those resources.
Built-In Load Balancer
Kontena comes with built-in load balancer.
Based on Haproxy. It features fully
automatic, zero-downtime operation due to
deep integration with Kontena’s service
discovery and orchestration technology.
Aggregated Stats & Logs
Kontena provides real-time log and statistics
streams containers. The streams may be
grouped and aggregated to produce service
level streams. This allows easy viewing of
logs and statistics for your application CPU,
memory, disk and network usage.
User Management with Audit Trail
All events and actions performed through
Kontena CLI or APIs are logged into audit
trail. Combined with users and access
control, the audit trail support makes
Kontena a reliable and secure solution for
any enterprise deployments.
Built-In Secrets Management
When your application requires access to
APIs or databases, you'll often need to use
secrets such as passwords and access
tokens for authenticating the access.
Kontena Vault is a secure key/value storage
that can be used to manage secrets in
Kontena.
“Includes all that sh*it you don’t need to
implement by yourself”
Dockerizing Ruby Application
Containers vs. VMs
© 2015 Kontena, Inc.
INFRA
HOST
OS
APP
INFRA
HOST
OS
APP
INFRA
HOST
OS
APP
INFRA
HOST OS
HYPERVISOR
GUEST
OS
GUEST
OS
GUEST
OS
APP APP APP
INFRA
HOST OS
CONTAINER ENGINE
APP APP APP
Legacy Virtualization Containerization
Year 2014 
Docker Core Concepts
• Dockerfile
• Describes a Docker image
• Docker image
• “Compiled” version of the Dockerfile
• Docker container
• Running instance of the Docker image
© 2015 Kontena, Inc.
Docker Image
• Packs up the application and environment required by the
application to run
• Consist of image layers
• Extends a base image
© 2015 Kontena, Inc.
Ruby Base Image Strategies
• Official Ruby images
• ruby:version
• defacto image, has a large number of extremely common Debian packages
• ruby:onbuild
• really useful for "getting off the ground running”.
• it's not recommended for long-term usage within a project due to the lack of control
over when the ONBUILD triggers fire
• ruby:slim
• contains the minimal packages needed to run ruby
• ruby:alpine
• based on Alpine Linux. The main caveat to note is that it does use musl libc instead
of glibc and friends, so certain software might run into issues depending on the depth
of their libc requirements
• Build your own Ruby image
• Include only those libraries that are needed for your app
© 2015 Kontena, Inc.
© 2015 Kontena, Inc.
Sometimes size does matter
© 2015 Kontena, Inc.
Ruby:2.3.1
729 MiB
Ruby:2.3.1-
slim
283 MiB Ruby:2.3.1-
alpine
125 MiB
Sizes of the Official
Ruby Images
Docker Containers – Best practices
• Run one process per container
• Twelve-Factor App FTW!
• Store config in the environment
• Treat backing services as attached resources
• Export services via port binding
• Treat logs as event streams
• Etc.
• Don’t rely on IP addresses
© 2015 Kontena, Inc.
Example
Dockerfile
FROM ruby:2.3.1-alpine
ADD Gemfile /app/
ADD Gemfile.lock /app/
RUN apk --update add --virtual build-dependencies ruby-dev build-base && 
gem install bundler --no-ri --no-rdoc && 
cd /app ; bundle install --without development test && 
apk del build-dependencies
ADD . /app
RUN chown -R nobody:nogroup /app
USER nobody
ENV RACK_ENV production
EXPOSE 9292
WORKDIR /app
Sending build context to Docker daemon 29.7 kB
Step 1 : FROM ruby:2.3.1-alpine
---> adae74697505
Step 2 : ADD Gemfile /app/
---> 81f926a9e4d6
Removing intermediate container 1000f93a8025
Step 3 : ADD Gemfile.lock /app/
---> ed3e4a1dfe0e
Removing intermediate container 5920c0c209e6
Step 4 : RUN apk --update add --virtual build-dependencies ruby-dev build-base && gem install bundler --no-ri --no-rdoc && cd /app ; bundle install -
-without development test && apk del build-dependencies
---> Running in 09029fc13d73
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz
fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz
(1/23) Installing gmp (6.1.0-r0)
(2/23) Installing libgcc (5.3.0-r0)
(3/23) Installing libstdc++ (5.3.0-r0)
(4/23) Installing libgmpxx (6.1.0-r0)
(5/23) Installing gmp-dev (6.1.0-r0)
(6/23) Installing libedit (20150325.3.1-r3)
(7/23) Installing ruby-libs (2.2.4-r0)
(8/23) Installing ruby-dev (2.2.4-r0)
(9/23) Installing binutils-libs (2.25.1-r0)
(10/23) Installing binutils (2.25.1-r0)
(11/23) Installing isl (0.14.1-r0)
(12/23) Installing libgomp (5.3.0-r0)
(13/23) Installing libatomic (5.3.0-r0)
(14/23) Installing mpfr3 (3.1.2-r0)
(15/23) Installing mpc1 (1.0.3-r0)
(16/23) Installing gcc (5.3.0-r0)
(17/23) Installing make (4.1-r0)
lauri@kontena.io ~/helsinki-ruby-
brigade/todo$
docker build -t kontena/todo-example:latest .
© 2015 Kontena, Inc.
(18/23) Installing musl-dev (1.1.12-r5)
(19/23) Installing libc-dev (0.7-r0)
(20/23) Installing fortify-headers (0.7-r0)
(21/23) Installing g++ (5.3.0-r0)
(22/23) Installing build-base (0.4-r1)
(23/23) Installing build-dependencies (0)
Executing busybox-1.24.1-r7.trigger
OK: 192 MiB in 55 packages
Successfully installed bundler-1.12.5
1 gem installed
Fetching gem metadata from https://rubygems.org/
Fetching version metadata from https://rubygems.org/
Installing i18n 0.7.0
Using json 1.8.3
Installing minitest 5.9.0
Installing thread_safe 0.3.5
Installing builder 3.2.2
Installing bson 4.1.1 with native extensions
Installing origin 2.2.0
Installing puma 3.4.0 with native extensions
Installing rack 1.5.2
Installing tilt 1.4.1
Using bundler 1.12.5
Installing tzinfo 1.2.2
Installing mongo 2.2.5
Installing rack-protection 1.5.3
Installing activesupport 4.2.6
Installing sinatra 1.4.5
Installing activemodel 4.2.6
Installing mongoid 5.1.3
Bundle complete! 3 Gemfile dependencies, 18 gems now installed.
Gems in the groups development and test were not installed.
© 2015 Kontena, Inc.
Bundled gems are installed into /usr/local/bundle.
(1/23) Purging build-dependencies (0)
(2/23) Purging ruby-dev (2.2.4-r0)
(3/23) Purging gmp-dev (6.1.0-r0)
(4/23) Purging libgmpxx (6.1.0-r0)
(5/23) Purging ruby-libs (2.2.4-r0)
(6/23) Purging build-base (0.4-r1)
(7/23) Purging make (4.1-r0)
(8/23) Purging fortify-headers (0.7-r0)
(9/23) Purging g++ (5.3.0-r0)
(10/23) Purging gcc (5.3.0-r0)
(11/23) Purging binutils (2.25.1-r0)
(12/23) Purging isl (0.14.1-r0)
(13/23) Purging libatomic (5.3.0-r0)
(14/23) Purging libc-dev (0.7-r0)
(15/23) Purging musl-dev (1.1.12-r5)
(16/23) Purging libstdc++ (5.3.0-r0)
(17/23) Purging mpc1 (1.0.3-r0)
(18/23) Purging mpfr3 (3.1.2-r0)
(19/23) Purging gmp (6.1.0-r0)
(20/23) Purging libgcc (5.3.0-r0)
(21/23) Purging libedit (20150325.3.1-r3)
(22/23) Purging binutils-libs (2.25.1-r0)
(23/23) Purging libgomp (5.3.0-r0)
Executing busybox-1.24.1-r7.trigger
OK: 23 MiB in 32 packages
---> 829379018bc7
Removing intermediate container 09029fc13d73
Step 5 : ADD . /app
---> 66705b32dc48
Removing intermediate container c7f73596c9ae
Step 6 : RUN chown -R nobody:nogroup /app
© 2015 Kontena, Inc.
---> Running in be356cda2cd6
---> 0673c22b8d74
Removing intermediate container be356cda2cd6
Step 7 : USER nobody
---> Running in fd495cb3838a
---> 83cb7493aa53
Removing intermediate container fd495cb3838a
Step 8 : ENV RACK_ENV production
---> Running in edac524bbd44
---> e3b6c26647b2
Removing intermediate container edac524bbd44
Step 9 : EXPOSE 9292
---> Running in 4369855c3ab4
---> 3d82b78a2213
Removing intermediate container 4369855c3ab4
Step 10 : WORKDIR /app
---> Running in 6172a5c18269
---> e73df80077b5
Removing intermediate container 6172a5c18269
Successfully built e73df80077b5
lauri@kontena.io ~/helsinki-ruby-brigade/todo$
From Containers to Microservices
• Docker Compose
• Tool for defining and running multi-container Docker applications
• Services and their configurations are defined in YAML file(s)
docker-compose.yml
© 2015 Kontena, Inc.
version: '2’
services:
web:
image: kontena/todo-example:latest
command: bundle exec puma -p 9292 -e production
environment:
- MONGODB_URI=mongodb://mongodb:27017/todo_production
ports:
- 9292:9292
links:
- mongodb:mongodb
mongodb:
image: mongo:3.2
command: mongod --smallfiles
Rolling to Production
• How big this app will be? How many users it will serve?
• Do you want your application to be infrastructure agnostic or
lean heavily on some cloud provider?
• How to run databases or save other persistent data?
• How to scale the application and handle load balancing?
• How do you pass sensitive data to your application and where
to store that data?
• How the application can be deployed and updated with zero
down-time?
© 2015 Kontena, Inc.
Example
kontena.yml
version: '2’
services:
mongodb: image: mongo:3.2
instances: 3
stateful: true
command: --replSet kontena –smallfiles
hooks:
post_start:
- cmd: sleep 10
name: sleep
instances: 1
oneshot: true
- cmd: mongo --eval "printjson(rs.initiate());”
name: rs_initiate
instances: 1
oneshot: true
- cmd: mongo --eval "printjson(rs.add('%{project}-mongodb-2'))”
name: rs_add2
instances: 1
oneshot: true
- cmd: mongo --eval "printjson(rs.add('%{project}-mongodb-3'))”
name: rs_add3
instances: 1
oneshot: true
© 2015 Kontena, Inc.
app:
image: kontena/todo-example:latest
links:
- mongodb:mongodb
- loadbalancer
environment:
- MONGODB_URI=mongodb://%{project}-mongodb-1.kontena.local:27017,%{project}-mongodb-
2.kontena.local:27017,%{project}-mongodb-3.kontena.local:27017/todo_production
- KONTENA_LB_VIRTUAL_PATH=/
- KONTENA_LB_INTERNAL_PORT=9292
command: bundle exec puma -p 9292 -e production
loadbalancer:
image: kontena/lb:latest
deploy:
strategy: daemon
ports:
- 80:80
Deploying Application
© 2015 Kontena, Inc.
lauri@kontena.io ~/helsinki-ruby-
brigade/todo$
kontena app deploy
Scaling Application
© 2015 Kontena, Inc.
lauri@kontena.io ~/helsinki-ruby-
brigade/todo$
kontena app scale app 10
Resources
• Todo Example: https://github.com/kontena/helsinki-meetup-
hackathon
• Getting started: http://www.kontena.io
• GitHub: https://github.com/kontena/kontena
• Gitter: https://gitter.im/kontena/kontena
• Kontena Meetup: http://www.meetup.com/Kontena-Helsinki/
© 2015 Kontena, Inc.
Thank You!
www.kontena.io
We are hiring!
kontena.io/jobs

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Barcelona MeetUp - Kontena Intro
Barcelona MeetUp - Kontena IntroBarcelona MeetUp - Kontena Intro
Barcelona MeetUp - Kontena Intro
 
Continuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & KontenaContinuous Delivery of Containers with Drone & Kontena
Continuous Delivery of Containers with Drone & Kontena
 
Running Docker in Production - The Good, the Bad and The Ugly
Running Docker in Production - The Good, the Bad and The UglyRunning Docker in Production - The Good, the Bad and The Ugly
Running Docker in Production - The Good, the Bad and The Ugly
 
Running and Scaling Docker Containers with Kontena
Running and Scaling Docker Containers with KontenaRunning and Scaling Docker Containers with Kontena
Running and Scaling Docker Containers with Kontena
 
Orchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failuresOrchestrating Linux Containers while tolerating failures
Orchestrating Linux Containers while tolerating failures
 
Practical Design Patterns in Docker Networking
Practical Design Patterns in Docker NetworkingPractical Design Patterns in Docker Networking
Practical Design Patterns in Docker Networking
 
Building High Availability Application with Docker
Building High Availability Application with DockerBuilding High Availability Application with Docker
Building High Availability Application with Docker
 
Docker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup SlidesDocker Datacenter Overview and Production Setup Slides
Docker Datacenter Overview and Production Setup Slides
 
Docker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker and Microsoft - Windows Server 2016 Technical Deep DiveDocker and Microsoft - Windows Server 2016 Technical Deep Dive
Docker and Microsoft - Windows Server 2016 Technical Deep Dive
 
Docker to the Rescue of an Ops Team
Docker to the Rescue of an Ops TeamDocker to the Rescue of an Ops Team
Docker to the Rescue of an Ops Team
 
LINE's Private Cloud - Meet Cloud Native World
LINE's Private Cloud - Meet Cloud Native WorldLINE's Private Cloud - Meet Cloud Native World
LINE's Private Cloud - Meet Cloud Native World
 
DCEU 18: Docker Containers in a Serverless World
DCEU 18: Docker Containers in a Serverless WorldDCEU 18: Docker Containers in a Serverless World
DCEU 18: Docker Containers in a Serverless World
 
Docker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&ADocker Online Meetup: Infrakit update and Q&A
Docker Online Meetup: Infrakit update and Q&A
 
Docker for Java Developers
Docker for Java DevelopersDocker for Java Developers
Docker for Java Developers
 
Containers without docker
Containers without dockerContainers without docker
Containers without docker
 
Docker SF Meetup January 2016
Docker SF Meetup January 2016Docker SF Meetup January 2016
Docker SF Meetup January 2016
 
Container orchestration from theory to practice
Container orchestration from theory to practiceContainer orchestration from theory to practice
Container orchestration from theory to practice
 
Kubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystemKubernetes design principles, patterns and ecosystem
Kubernetes design principles, patterns and ecosystem
 
Docker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT InfrastructureDocker for any type of workload and any IT Infrastructure
Docker for any type of workload and any IT Infrastructure
 
Monitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & MicroservicesMonitoring Dell Infrastructure using Docker & Microservices
Monitoring Dell Infrastructure using Docker & Microservices
 

Destaque

Destaque (20)

Beginners Guide To Kontena
Beginners Guide To KontenaBeginners Guide To Kontena
Beginners Guide To Kontena
 
Building Serverless with Firebase
Building Serverless with FirebaseBuilding Serverless with Firebase
Building Serverless with Firebase
 
Vincent's Vinyl - ERD
Vincent's Vinyl - ERDVincent's Vinyl - ERD
Vincent's Vinyl - ERD
 
Mule soft esb – data validation best practices
Mule soft esb – data validation best practicesMule soft esb – data validation best practices
Mule soft esb – data validation best practices
 
Dockerized tests with dockerized jenkins
Dockerized tests with dockerized jenkinsDockerized tests with dockerized jenkins
Dockerized tests with dockerized jenkins
 
Integration Testing with Docker Containers with DockerCompose
Integration Testing with Docker Containers  with DockerComposeIntegration Testing with Docker Containers  with DockerCompose
Integration Testing with Docker Containers with DockerCompose
 
How to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker ComposeHow to Dockerize Web Application using Docker Compose
How to Dockerize Web Application using Docker Compose
 
Dockerize it all
Dockerize it allDockerize it all
Dockerize it all
 
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOSDEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
DEPLOYING A DOCKERIZED DISTRIBUTED APPLICATION IN MESOS
 
SDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and ProfitSDLC Using Docker for Fun and Profit
SDLC Using Docker for Fun and Profit
 
Monitoring docker container and dockerized applications
Monitoring docker container and dockerized applicationsMonitoring docker container and dockerized applications
Monitoring docker container and dockerized applications
 
Docker Practical Use Cases
Docker Practical Use CasesDocker Practical Use Cases
Docker Practical Use Cases
 
Dockerize All The Things
Dockerize All The ThingsDockerize All The Things
Dockerize All The Things
 
Dockerize WordPress on Mac/Windows
Dockerize WordPress on Mac/WindowsDockerize WordPress on Mac/Windows
Dockerize WordPress on Mac/Windows
 
Modern DevOps with Docker
Modern DevOps with DockerModern DevOps with Docker
Modern DevOps with Docker
 
I tried to dockerize my app but I had to PaaS
I tried to dockerize my app but I had to PaaSI tried to dockerize my app but I had to PaaS
I tried to dockerize my app but I had to PaaS
 
9 de julio.pps
9 de julio.pps9 de julio.pps
9 de julio.pps
 
El papel del lurker en las Redes Sociales
El papel del lurker en las Redes SocialesEl papel del lurker en las Redes Sociales
El papel del lurker en las Redes Sociales
 
Financing Demographic Shifts Scenarios
 Financing Demographic Shifts   Scenarios Financing Demographic Shifts   Scenarios
Financing Demographic Shifts Scenarios
 
Blockchain Salesforce Executive Club 2016 09-07
Blockchain Salesforce Executive Club 2016 09-07Blockchain Salesforce Executive Club 2016 09-07
Blockchain Salesforce Executive Club 2016 09-07
 

Semelhante a Dockerizing Ruby Applications - The Best Practices

Docker, a new LINUX container technology based light weight virtualization
Docker, a new LINUX container technology based light weight virtualizationDocker, a new LINUX container technology based light weight virtualization
Docker, a new LINUX container technology based light weight virtualization
Suresh Balla
 

Semelhante a Dockerizing Ruby Applications - The Best Practices (20)

Docker and Puppet for Continuous Integration
Docker and Puppet for Continuous IntegrationDocker and Puppet for Continuous Integration
Docker and Puppet for Continuous Integration
 
Docker and IBM Integration Bus
Docker and IBM Integration BusDocker and IBM Integration Bus
Docker and IBM Integration Bus
 
DCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development PipelineDCEU 18: Building Your Development Pipeline
DCEU 18: Building Your Development Pipeline
 
Docker Timisoara: Dockercon19 recap slides, 23 may 2019
Docker Timisoara: Dockercon19 recap slides, 23 may 2019Docker Timisoara: Dockercon19 recap slides, 23 may 2019
Docker Timisoara: Dockercon19 recap slides, 23 may 2019
 
WebSphere Application Server Liberty Profile and Docker
WebSphere Application Server Liberty Profile and DockerWebSphere Application Server Liberty Profile and Docker
WebSphere Application Server Liberty Profile and Docker
 
Cicd.pdf
Cicd.pdfCicd.pdf
Cicd.pdf
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
 
FOSDEM 2017: GitLab CI
FOSDEM 2017:  GitLab CIFOSDEM 2017:  GitLab CI
FOSDEM 2017: GitLab CI
 
Pycon9 - Paas per tutti i gusti con Dokku and Kubernetes
Pycon9 - Paas per tutti i gusti con Dokku and KubernetesPycon9 - Paas per tutti i gusti con Dokku and Kubernetes
Pycon9 - Paas per tutti i gusti con Dokku and Kubernetes
 
ContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small businessContainerDayVietnam2016: Dockerize a small business
ContainerDayVietnam2016: Dockerize a small business
 
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
O'Reilly Software Architecture Conference London 2017: Building Resilient Mic...
 
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik DornJDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
JDD2014: Docker.io - versioned linux containers for JVM devops - Dominik Dorn
 
WSO2ConEU 2016 Tutorial - Deploying WSO2 Middleware on Containers
WSO2ConEU 2016 Tutorial - Deploying WSO2 Middleware on ContainersWSO2ConEU 2016 Tutorial - Deploying WSO2 Middleware on Containers
WSO2ConEU 2016 Tutorial - Deploying WSO2 Middleware on Containers
 
Deploying WSO2 Middleware on Containers
Deploying WSO2 Middleware on ContainersDeploying WSO2 Middleware on Containers
Deploying WSO2 Middleware on Containers
 
Docker engine - Indroduc
Docker engine - IndroducDocker engine - Indroduc
Docker engine - Indroduc
 
Docker, a new LINUX container technology based light weight virtualization
Docker, a new LINUX container technology based light weight virtualizationDocker, a new LINUX container technology based light weight virtualization
Docker, a new LINUX container technology based light weight virtualization
 
vodQA(Pune) 2018 - Docker in Testing
vodQA(Pune) 2018 - Docker in TestingvodQA(Pune) 2018 - Docker in Testing
vodQA(Pune) 2018 - Docker in Testing
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
Docker and Jenkins [as code]
Docker and Jenkins [as code]Docker and Jenkins [as code]
Docker and Jenkins [as code]
 
DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline  DCSF 19 Building Your Development Pipeline
DCSF 19 Building Your Development Pipeline
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

Dockerizing Ruby Applications - The Best Practices

  • 1. Dockerizing Ruby Applications- The Best Practices Lauri Nevala, Co-Founder and Software Engineer
  • 3. © 2015 Kontena, Inc. What is Kontena? Open Source container platform built to maximize developer happiness. Works on any cloud, easy to setup, simple to use.
  • 6. All Batteries Included! Built-In Image Registry Sometimes projects can not use publicly hosted container image registries like DockerHub. Kontena comes with built-in container image registry providing private and secure solution. Built-In VPN Access All containers are run inside a virtual private network by default. Nothing is exposed to Internet unless explicitly defined. With Kontena’s built-in VPN access developers can securely access those resources. Built-In Load Balancer Kontena comes with built-in load balancer. Based on Haproxy. It features fully automatic, zero-downtime operation due to deep integration with Kontena’s service discovery and orchestration technology. Aggregated Stats & Logs Kontena provides real-time log and statistics streams containers. The streams may be grouped and aggregated to produce service level streams. This allows easy viewing of logs and statistics for your application CPU, memory, disk and network usage. User Management with Audit Trail All events and actions performed through Kontena CLI or APIs are logged into audit trail. Combined with users and access control, the audit trail support makes Kontena a reliable and secure solution for any enterprise deployments. Built-In Secrets Management When your application requires access to APIs or databases, you'll often need to use secrets such as passwords and access tokens for authenticating the access. Kontena Vault is a secure key/value storage that can be used to manage secrets in Kontena.
  • 7. “Includes all that sh*it you don’t need to implement by yourself”
  • 8.
  • 10. Containers vs. VMs © 2015 Kontena, Inc. INFRA HOST OS APP INFRA HOST OS APP INFRA HOST OS APP INFRA HOST OS HYPERVISOR GUEST OS GUEST OS GUEST OS APP APP APP INFRA HOST OS CONTAINER ENGINE APP APP APP Legacy Virtualization Containerization Year 2014 
  • 11. Docker Core Concepts • Dockerfile • Describes a Docker image • Docker image • “Compiled” version of the Dockerfile • Docker container • Running instance of the Docker image © 2015 Kontena, Inc.
  • 12. Docker Image • Packs up the application and environment required by the application to run • Consist of image layers • Extends a base image © 2015 Kontena, Inc.
  • 13. Ruby Base Image Strategies • Official Ruby images • ruby:version • defacto image, has a large number of extremely common Debian packages • ruby:onbuild • really useful for "getting off the ground running”. • it's not recommended for long-term usage within a project due to the lack of control over when the ONBUILD triggers fire • ruby:slim • contains the minimal packages needed to run ruby • ruby:alpine • based on Alpine Linux. The main caveat to note is that it does use musl libc instead of glibc and friends, so certain software might run into issues depending on the depth of their libc requirements • Build your own Ruby image • Include only those libraries that are needed for your app © 2015 Kontena, Inc.
  • 14. © 2015 Kontena, Inc. Sometimes size does matter
  • 15. © 2015 Kontena, Inc. Ruby:2.3.1 729 MiB Ruby:2.3.1- slim 283 MiB Ruby:2.3.1- alpine 125 MiB Sizes of the Official Ruby Images
  • 16. Docker Containers – Best practices • Run one process per container • Twelve-Factor App FTW! • Store config in the environment • Treat backing services as attached resources • Export services via port binding • Treat logs as event streams • Etc. • Don’t rely on IP addresses © 2015 Kontena, Inc.
  • 18. Dockerfile FROM ruby:2.3.1-alpine ADD Gemfile /app/ ADD Gemfile.lock /app/ RUN apk --update add --virtual build-dependencies ruby-dev build-base && gem install bundler --no-ri --no-rdoc && cd /app ; bundle install --without development test && apk del build-dependencies ADD . /app RUN chown -R nobody:nogroup /app USER nobody ENV RACK_ENV production EXPOSE 9292 WORKDIR /app
  • 19. Sending build context to Docker daemon 29.7 kB Step 1 : FROM ruby:2.3.1-alpine ---> adae74697505 Step 2 : ADD Gemfile /app/ ---> 81f926a9e4d6 Removing intermediate container 1000f93a8025 Step 3 : ADD Gemfile.lock /app/ ---> ed3e4a1dfe0e Removing intermediate container 5920c0c209e6 Step 4 : RUN apk --update add --virtual build-dependencies ruby-dev build-base && gem install bundler --no-ri --no-rdoc && cd /app ; bundle install - -without development test && apk del build-dependencies ---> Running in 09029fc13d73 fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/main/x86_64/APKINDEX.tar.gz fetch http://dl-cdn.alpinelinux.org/alpine/v3.3/community/x86_64/APKINDEX.tar.gz (1/23) Installing gmp (6.1.0-r0) (2/23) Installing libgcc (5.3.0-r0) (3/23) Installing libstdc++ (5.3.0-r0) (4/23) Installing libgmpxx (6.1.0-r0) (5/23) Installing gmp-dev (6.1.0-r0) (6/23) Installing libedit (20150325.3.1-r3) (7/23) Installing ruby-libs (2.2.4-r0) (8/23) Installing ruby-dev (2.2.4-r0) (9/23) Installing binutils-libs (2.25.1-r0) (10/23) Installing binutils (2.25.1-r0) (11/23) Installing isl (0.14.1-r0) (12/23) Installing libgomp (5.3.0-r0) (13/23) Installing libatomic (5.3.0-r0) (14/23) Installing mpfr3 (3.1.2-r0) (15/23) Installing mpc1 (1.0.3-r0) (16/23) Installing gcc (5.3.0-r0) (17/23) Installing make (4.1-r0) lauri@kontena.io ~/helsinki-ruby- brigade/todo$ docker build -t kontena/todo-example:latest .
  • 20. © 2015 Kontena, Inc. (18/23) Installing musl-dev (1.1.12-r5) (19/23) Installing libc-dev (0.7-r0) (20/23) Installing fortify-headers (0.7-r0) (21/23) Installing g++ (5.3.0-r0) (22/23) Installing build-base (0.4-r1) (23/23) Installing build-dependencies (0) Executing busybox-1.24.1-r7.trigger OK: 192 MiB in 55 packages Successfully installed bundler-1.12.5 1 gem installed Fetching gem metadata from https://rubygems.org/ Fetching version metadata from https://rubygems.org/ Installing i18n 0.7.0 Using json 1.8.3 Installing minitest 5.9.0 Installing thread_safe 0.3.5 Installing builder 3.2.2 Installing bson 4.1.1 with native extensions Installing origin 2.2.0 Installing puma 3.4.0 with native extensions Installing rack 1.5.2 Installing tilt 1.4.1 Using bundler 1.12.5 Installing tzinfo 1.2.2 Installing mongo 2.2.5 Installing rack-protection 1.5.3 Installing activesupport 4.2.6 Installing sinatra 1.4.5 Installing activemodel 4.2.6 Installing mongoid 5.1.3 Bundle complete! 3 Gemfile dependencies, 18 gems now installed. Gems in the groups development and test were not installed.
  • 21. © 2015 Kontena, Inc. Bundled gems are installed into /usr/local/bundle. (1/23) Purging build-dependencies (0) (2/23) Purging ruby-dev (2.2.4-r0) (3/23) Purging gmp-dev (6.1.0-r0) (4/23) Purging libgmpxx (6.1.0-r0) (5/23) Purging ruby-libs (2.2.4-r0) (6/23) Purging build-base (0.4-r1) (7/23) Purging make (4.1-r0) (8/23) Purging fortify-headers (0.7-r0) (9/23) Purging g++ (5.3.0-r0) (10/23) Purging gcc (5.3.0-r0) (11/23) Purging binutils (2.25.1-r0) (12/23) Purging isl (0.14.1-r0) (13/23) Purging libatomic (5.3.0-r0) (14/23) Purging libc-dev (0.7-r0) (15/23) Purging musl-dev (1.1.12-r5) (16/23) Purging libstdc++ (5.3.0-r0) (17/23) Purging mpc1 (1.0.3-r0) (18/23) Purging mpfr3 (3.1.2-r0) (19/23) Purging gmp (6.1.0-r0) (20/23) Purging libgcc (5.3.0-r0) (21/23) Purging libedit (20150325.3.1-r3) (22/23) Purging binutils-libs (2.25.1-r0) (23/23) Purging libgomp (5.3.0-r0) Executing busybox-1.24.1-r7.trigger OK: 23 MiB in 32 packages ---> 829379018bc7 Removing intermediate container 09029fc13d73 Step 5 : ADD . /app ---> 66705b32dc48 Removing intermediate container c7f73596c9ae Step 6 : RUN chown -R nobody:nogroup /app
  • 22. © 2015 Kontena, Inc. ---> Running in be356cda2cd6 ---> 0673c22b8d74 Removing intermediate container be356cda2cd6 Step 7 : USER nobody ---> Running in fd495cb3838a ---> 83cb7493aa53 Removing intermediate container fd495cb3838a Step 8 : ENV RACK_ENV production ---> Running in edac524bbd44 ---> e3b6c26647b2 Removing intermediate container edac524bbd44 Step 9 : EXPOSE 9292 ---> Running in 4369855c3ab4 ---> 3d82b78a2213 Removing intermediate container 4369855c3ab4 Step 10 : WORKDIR /app ---> Running in 6172a5c18269 ---> e73df80077b5 Removing intermediate container 6172a5c18269 Successfully built e73df80077b5 lauri@kontena.io ~/helsinki-ruby-brigade/todo$
  • 23. From Containers to Microservices • Docker Compose • Tool for defining and running multi-container Docker applications • Services and their configurations are defined in YAML file(s)
  • 24. docker-compose.yml © 2015 Kontena, Inc. version: '2’ services: web: image: kontena/todo-example:latest command: bundle exec puma -p 9292 -e production environment: - MONGODB_URI=mongodb://mongodb:27017/todo_production ports: - 9292:9292 links: - mongodb:mongodb mongodb: image: mongo:3.2 command: mongod --smallfiles
  • 25. Rolling to Production • How big this app will be? How many users it will serve? • Do you want your application to be infrastructure agnostic or lean heavily on some cloud provider? • How to run databases or save other persistent data? • How to scale the application and handle load balancing? • How do you pass sensitive data to your application and where to store that data? • How the application can be deployed and updated with zero down-time? © 2015 Kontena, Inc.
  • 27. kontena.yml version: '2’ services: mongodb: image: mongo:3.2 instances: 3 stateful: true command: --replSet kontena –smallfiles hooks: post_start: - cmd: sleep 10 name: sleep instances: 1 oneshot: true - cmd: mongo --eval "printjson(rs.initiate());” name: rs_initiate instances: 1 oneshot: true - cmd: mongo --eval "printjson(rs.add('%{project}-mongodb-2'))” name: rs_add2 instances: 1 oneshot: true - cmd: mongo --eval "printjson(rs.add('%{project}-mongodb-3'))” name: rs_add3 instances: 1 oneshot: true
  • 28. © 2015 Kontena, Inc. app: image: kontena/todo-example:latest links: - mongodb:mongodb - loadbalancer environment: - MONGODB_URI=mongodb://%{project}-mongodb-1.kontena.local:27017,%{project}-mongodb- 2.kontena.local:27017,%{project}-mongodb-3.kontena.local:27017/todo_production - KONTENA_LB_VIRTUAL_PATH=/ - KONTENA_LB_INTERNAL_PORT=9292 command: bundle exec puma -p 9292 -e production loadbalancer: image: kontena/lb:latest deploy: strategy: daemon ports: - 80:80
  • 29. Deploying Application © 2015 Kontena, Inc. lauri@kontena.io ~/helsinki-ruby- brigade/todo$ kontena app deploy
  • 30. Scaling Application © 2015 Kontena, Inc. lauri@kontena.io ~/helsinki-ruby- brigade/todo$ kontena app scale app 10
  • 31. Resources • Todo Example: https://github.com/kontena/helsinki-meetup- hackathon • Getting started: http://www.kontena.io • GitHub: https://github.com/kontena/kontena • Gitter: https://gitter.im/kontena/kontena • Kontena Meetup: http://www.meetup.com/Kontena-Helsinki/ © 2015 Kontena, Inc.