SlideShare a Scribd company logo
Building and Deploying 12
Factor Apps in Scala, Java,
Ruby, and Node.js
Neil Shannon
February 24, 2017
About Me
Polyglot Developer/Architect
Founder at NTS Development LLC
Staff Software Engineer @ The Home Depot
@ntshannon | neil@nts-dev.com
https://linkedin.com/in/neilshannon
https://github.com/neilshannon
Agenda
What is a 12-factor app and why do I care?
How do I build a 12 factor app in Java? Scala? Ruby? Node.js?
How do I deploy my app to Pivotal Cloud Foundry?
12 factors for the Impatient
I. Codebase - use version control (e.g. git)
II. Dependencies - use a dependency manager (e.g. gradle/maven/sbt)
III. Config - separate configuration from code (use the OS environment)
IV. Backing Services - reference resources such as DBs by URLs in the config
V. Build release run - separate build from run. Use versions.
VI. Processes - run the app as one or more stateless processes.
VII. Port binding - app should be self-contained. No app server.
VIII. Concurrency - scale horizontally
IX. Disposability - fast startup, graceful shutdown
X. Dev/Prod parity - keep environments similar
XI. Logs - treat logs as event streams (no FileAppenders!)
XII. Admin Processes - treat admin processes as one-off events
A 12-factor app is an application
designed to be deployed in the cloud.
Deployment Environment
The Environment
development uat
mLab service: devnexus
(dev mongodb credentials)
mLab service: devnexus
(dev mongodb credentials)
encironment
Same access to config
Same code
Same
● Application Code
● Access to config
● Build model
● Deployment model
● Environment
Different
● Config values
● Endpoint URIs
● Number of
instances
What are we going to do next?
We’re going to build an executable JAR file containing a Java web service and
its dependencies.
We will tell Pivotal Cloud Foundry how to execute our application using a
cloud manifest (manifest.yml).
We’re going to push our JAR to Pivotal Cloud Foundry and boot up our
application.
Let’s Get Started
$ git clone https://github.com/neilshannon/devnexus-microservices
Prepare Environment
1. Create org in Pivotal Web Services
2. Create space in Pivotal Web Services
3. Create MongoLab service
Prepare cloud manifest
---
applications:
- name: devnexus-microservices-scala
buildpack: java_buildpack
path:
target/scala-2.11/devnexus-microservices-scala-assembly-0.1.0-SNAPSHOT.ja
r
services:
- devnexus
manifest.yml
Scala Stack
Scala Stack
Build - sbt
Test - specs2
Platform - Scalatra hosted in embedded Jetty container
Persistence - ReactiveMongo
REST - Scalatra
Deploy - Cloud Foundry
Scala pitfalls and caveats!
Scala generates a lot of code with long class names.
CloudFoundry aufs only supports file lengths of a maximum of 243 characters.
Guess how many characters this generated class has...
Copying into the container failed: stream-in: nstar: error streaming in: exit status 2. Output: tar:
shapeless/TupleTypeableInstances$$anon$17$$anonfun$cast$17$$anonfun$app$$$$9e2cdc6fa02ebaeef8cffbef37753
221$$$$$128$$anonfun$apply$129$$anonfun$apply$130$$anonfun$apply$131$$anonfun$apply$132$$anonfun$apply$1
33$$anonfun$apply$134$$anonfun$apply$135.class: Cannot open: File name too long
Java Stack
Java Stack
Build - gradle
Test - JUnit
Platform - Spring Boot
Persistence - Spring Data MongoDB
REST (with hypermedia!)- Spring Data REST
Deploy - Cloud Foundry (Pivotal Web Services)
Ruby Stack
rack-test
Ruby Stack
Build - bundler
Test - Minitest, rack-test
Platform - Sinatra
Persistence - mongodb (Ruby official driver)
REST - Sinatra
Deploy - Cloud Foundry (Pivotal Web Services)
Node Stack
Node Stack
Build - npm
Test - mocha, chai
Platform - restify
Persistence - mongodb (official Node.js MongoDB driver)
REST - restify
Deploy - Cloud Foundry (Pivotal Web Services)
Resources
The 12 Factor App - http://12factor.net
Cloud Foundry - https://www.cloudfoundry.org/
Pivotal Web Services - https://run.pivotal.io/

More Related Content

What's hot (20)

PDF
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Red Hat Developers
 
PDF
Elasticsearch Monitoring in Openshift
Lukas Vlcek
 
PDF
OpenShift In a Nutshell - Episode 02 - Architecture
Behnam Loghmani
 
PDF
Cloud Native Microservices with Spring Cloud
Conor Svensson
 
PDF
Continuous Deployment with Kubernetes, Docker and GitLab CI
alexanderkiel
 
PDF
Test your Kubernetes operator with Operator Lifecycle Management
Baiju Muthukadan
 
PPTX
Migrating Java JBoss EAP Applications to Kubernetes With S2I
Konveyor Community
 
PDF
Open shift 4 infra deep dive
Winton Winton
 
PDF
CI/CD Pipeline mit Gitlab CI und Kubernetes
inovex GmbH
 
PDF
Cloud Foundry Introduction for CF Meetup Tokyo March 2016
Tomohiro Ichimura
 
PPTX
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Maki Toshio
 
PDF
OpenShift in your own backyard - DevConf CZ 2021
Freddy Rolland
 
PPTX
Pluggable Providers - Greg Blomquist - ManageIQ Design Summit 2016
ManageIQ
 
PDF
Apache Continuum Build, Test, and Release
elliando dias
 
PPTX
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
Will Huang
 
PDF
WJAX 2013: Java8-Tooling in Eclipse
martinlippert
 
PDF
Red Hat OpenShift Operators - Operators ABC
Robert Bohne
 
PDF
OpenShift In a Nutshell - Episode 06 - Core Concepts Part II
Behnam Loghmani
 
PDF
クラウドネイティブ時代の分散トレーシング - Distributed Tracing in a Cloud Native Age
Yoichi Kawasaki
 
PDF
Cicd pixelfederation
Juraj Hantak
 
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Red Hat Developers
 
Elasticsearch Monitoring in Openshift
Lukas Vlcek
 
OpenShift In a Nutshell - Episode 02 - Architecture
Behnam Loghmani
 
Cloud Native Microservices with Spring Cloud
Conor Svensson
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
alexanderkiel
 
Test your Kubernetes operator with Operator Lifecycle Management
Baiju Muthukadan
 
Migrating Java JBoss EAP Applications to Kubernetes With S2I
Konveyor Community
 
Open shift 4 infra deep dive
Winton Winton
 
CI/CD Pipeline mit Gitlab CI und Kubernetes
inovex GmbH
 
Cloud Foundry Introduction for CF Meetup Tokyo March 2016
Tomohiro Ichimura
 
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Maki Toshio
 
OpenShift in your own backyard - DevConf CZ 2021
Freddy Rolland
 
Pluggable Providers - Greg Blomquist - ManageIQ Design Summit 2016
ManageIQ
 
Apache Continuum Build, Test, and Release
elliando dias
 
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
Will Huang
 
WJAX 2013: Java8-Tooling in Eclipse
martinlippert
 
Red Hat OpenShift Operators - Operators ABC
Robert Bohne
 
OpenShift In a Nutshell - Episode 06 - Core Concepts Part II
Behnam Loghmani
 
クラウドネイティブ時代の分散トレーシング - Distributed Tracing in a Cloud Native Age
Yoichi Kawasaki
 
Cicd pixelfederation
Juraj Hantak
 

Viewers also liked (15)

PDF
A day with sbt
Marcus Lönnberg
 
PDF
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
VMware Tanzu
 
PDF
JavaOne 2015: 12 Factor App
Joe Kutner
 
PDF
[Tech Talks] Typesafe Stack Introduction
Klika Tech, Inc
 
PPTX
Ruby object model
Chamnap Chhorn
 
KEY
Advanced Ruby Idioms So Clean You Can Eat Off Of Them
Brian Guthrie
 
PDF
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
Eugene Yokota
 
PDF
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
Eugene Yokota
 
PDF
Scala : language of the future
AnsviaLab
 
PDF
Scala Days NYC 2016
Martin Odersky
 
PDF
Beyond the Twelve-Factor App
Kazuya Takahashi
 
PDF
Preparing for distributed system failures using akka #ScalaMatsuri
TIS Inc.
 
PDF
12 Factor App: Best Practices for JVM Deployment
Joe Kutner
 
PDF
Scala Warrior and type-safe front-end development with Scala.js
takezoe
 
PPT
La démarche Qualité des APP
FFFOD
 
A day with sbt
Marcus Lönnberg
 
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
VMware Tanzu
 
JavaOne 2015: 12 Factor App
Joe Kutner
 
[Tech Talks] Typesafe Stack Introduction
Klika Tech, Inc
 
Ruby object model
Chamnap Chhorn
 
Advanced Ruby Idioms So Clean You Can Eat Off Of Them
Brian Guthrie
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
Eugene Yokota
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
Eugene Yokota
 
Scala : language of the future
AnsviaLab
 
Scala Days NYC 2016
Martin Odersky
 
Beyond the Twelve-Factor App
Kazuya Takahashi
 
Preparing for distributed system failures using akka #ScalaMatsuri
TIS Inc.
 
12 Factor App: Best Practices for JVM Deployment
Joe Kutner
 
Scala Warrior and type-safe front-end development with Scala.js
takezoe
 
La démarche Qualité des APP
FFFOD
 
Ad

Similar to DevNexus 2017 - Building and Deploying 12 Factor Apps in Scala, Java, Ruby, and Node.js (20)

PPTX
The twelve factor app
Ravi Okade
 
PDF
Pycon9 - Paas per tutti i gusti con Dokku and Kubernetes
Claudio Mignanti
 
PDF
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
VMware Tanzu
 
PDF
PaaS Anywhere - Deploying an OpenShift PaaS into your Cloud Provider of Choice
Isaac Christoffersen
 
PDF
Mastinder singh visualcv_resume
Mastinder Singh
 
PPTX
Serverless Pune Meetup 1
Vishal Biyani
 
PPTX
Cloud development technology sharing (BlueMix premier)
湯米吳 Tommy Wu
 
PDF
PHP Buildpacks in the Cloud on Bluemix
IBM
 
PDF
Cloud Foundry for PHP developers
Daniel Krook
 
PPTX
Learning ASP.NET 5 and MVC 6
Ido Flatow
 
PPTX
The next step from Microsoft - Vnext (Srdjan Poznic)
Geekstone
 
PDF
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
VMware Tanzu
 
PDF
Node.js an Exectutive View
Manuel Eusebio de Paz Carmona
 
PPT
Viridians on Rails
Viridians
 
PDF
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
martinlippert
 
PDF
GIDS_15FactorWorkshop.pdf
RichHagarty
 
PDF
Comparison of control plane deployment architectures in the scope of hypercon...
Miroslav Halas
 
PDF
Development on Cloud,PaaS and SDDC
seungdon Choi
 
DOC
Ramji
Ram Ji Soni
 
PDF
Introduction to Docker - Vellore Institute of Technology
Ajeet Singh Raina
 
The twelve factor app
Ravi Okade
 
Pycon9 - Paas per tutti i gusti con Dokku and Kubernetes
Claudio Mignanti
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
VMware Tanzu
 
PaaS Anywhere - Deploying an OpenShift PaaS into your Cloud Provider of Choice
Isaac Christoffersen
 
Mastinder singh visualcv_resume
Mastinder Singh
 
Serverless Pune Meetup 1
Vishal Biyani
 
Cloud development technology sharing (BlueMix premier)
湯米吳 Tommy Wu
 
PHP Buildpacks in the Cloud on Bluemix
IBM
 
Cloud Foundry for PHP developers
Daniel Krook
 
Learning ASP.NET 5 and MVC 6
Ido Flatow
 
The next step from Microsoft - Vnext (Srdjan Poznic)
Geekstone
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
VMware Tanzu
 
Node.js an Exectutive View
Manuel Eusebio de Paz Carmona
 
Viridians on Rails
Viridians
 
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
martinlippert
 
GIDS_15FactorWorkshop.pdf
RichHagarty
 
Comparison of control plane deployment architectures in the scope of hypercon...
Miroslav Halas
 
Development on Cloud,PaaS and SDDC
seungdon Choi
 
Introduction to Docker - Vellore Institute of Technology
Ajeet Singh Raina
 
Ad

DevNexus 2017 - Building and Deploying 12 Factor Apps in Scala, Java, Ruby, and Node.js

  • 1. Building and Deploying 12 Factor Apps in Scala, Java, Ruby, and Node.js Neil Shannon February 24, 2017
  • 2. About Me Polyglot Developer/Architect Founder at NTS Development LLC Staff Software Engineer @ The Home Depot @ntshannon | [email protected] https://linkedin.com/in/neilshannon https://github.com/neilshannon
  • 3. Agenda What is a 12-factor app and why do I care? How do I build a 12 factor app in Java? Scala? Ruby? Node.js? How do I deploy my app to Pivotal Cloud Foundry?
  • 4. 12 factors for the Impatient I. Codebase - use version control (e.g. git) II. Dependencies - use a dependency manager (e.g. gradle/maven/sbt) III. Config - separate configuration from code (use the OS environment) IV. Backing Services - reference resources such as DBs by URLs in the config V. Build release run - separate build from run. Use versions. VI. Processes - run the app as one or more stateless processes. VII. Port binding - app should be self-contained. No app server. VIII. Concurrency - scale horizontally IX. Disposability - fast startup, graceful shutdown X. Dev/Prod parity - keep environments similar XI. Logs - treat logs as event streams (no FileAppenders!) XII. Admin Processes - treat admin processes as one-off events
  • 5. A 12-factor app is an application designed to be deployed in the cloud.
  • 7. The Environment development uat mLab service: devnexus (dev mongodb credentials) mLab service: devnexus (dev mongodb credentials)
  • 8. encironment Same access to config Same code Same ● Application Code ● Access to config ● Build model ● Deployment model ● Environment Different ● Config values ● Endpoint URIs ● Number of instances
  • 9. What are we going to do next? We’re going to build an executable JAR file containing a Java web service and its dependencies. We will tell Pivotal Cloud Foundry how to execute our application using a cloud manifest (manifest.yml). We’re going to push our JAR to Pivotal Cloud Foundry and boot up our application.
  • 10. Let’s Get Started $ git clone https://github.com/neilshannon/devnexus-microservices
  • 11. Prepare Environment 1. Create org in Pivotal Web Services 2. Create space in Pivotal Web Services 3. Create MongoLab service
  • 12. Prepare cloud manifest --- applications: - name: devnexus-microservices-scala buildpack: java_buildpack path: target/scala-2.11/devnexus-microservices-scala-assembly-0.1.0-SNAPSHOT.ja r services: - devnexus manifest.yml
  • 14. Scala Stack Build - sbt Test - specs2 Platform - Scalatra hosted in embedded Jetty container Persistence - ReactiveMongo REST - Scalatra Deploy - Cloud Foundry
  • 15. Scala pitfalls and caveats! Scala generates a lot of code with long class names. CloudFoundry aufs only supports file lengths of a maximum of 243 characters. Guess how many characters this generated class has... Copying into the container failed: stream-in: nstar: error streaming in: exit status 2. Output: tar: shapeless/TupleTypeableInstances$$anon$17$$anonfun$cast$17$$anonfun$app$$$$9e2cdc6fa02ebaeef8cffbef37753 221$$$$$128$$anonfun$apply$129$$anonfun$apply$130$$anonfun$apply$131$$anonfun$apply$132$$anonfun$apply$1 33$$anonfun$apply$134$$anonfun$apply$135.class: Cannot open: File name too long
  • 17. Java Stack Build - gradle Test - JUnit Platform - Spring Boot Persistence - Spring Data MongoDB REST (with hypermedia!)- Spring Data REST Deploy - Cloud Foundry (Pivotal Web Services)
  • 19. Ruby Stack Build - bundler Test - Minitest, rack-test Platform - Sinatra Persistence - mongodb (Ruby official driver) REST - Sinatra Deploy - Cloud Foundry (Pivotal Web Services)
  • 21. Node Stack Build - npm Test - mocha, chai Platform - restify Persistence - mongodb (official Node.js MongoDB driver) REST - restify Deploy - Cloud Foundry (Pivotal Web Services)
  • 22. Resources The 12 Factor App - http://12factor.net Cloud Foundry - https://www.cloudfoundry.org/ Pivotal Web Services - https://run.pivotal.io/