SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
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/

Contenu connexe

Tendances

OpenShift in your own backyard - DevConf CZ 2021
OpenShift in your own backyard - DevConf CZ 2021OpenShift in your own backyard - DevConf CZ 2021
OpenShift in your own backyard - DevConf CZ 2021
Freddy Rolland
 
Apache Continuum Build, Test, and Release
Apache Continuum Build, Test, and ReleaseApache Continuum Build, Test, and Release
Apache Continuum Build, Test, and Release
elliando dias
 

Tendances (20)

Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
Profile your Java apps in production on Red Hat OpenShift with Cryostat | Dev...
 
Elasticsearch Monitoring in Openshift
Elasticsearch Monitoring in OpenshiftElasticsearch Monitoring in Openshift
Elasticsearch Monitoring in Openshift
 
OpenShift In a Nutshell - Episode 02 - Architecture
OpenShift In a Nutshell - Episode 02 - ArchitectureOpenShift In a Nutshell - Episode 02 - Architecture
OpenShift In a Nutshell - Episode 02 - Architecture
 
Cloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring CloudCloud Native Microservices with Spring Cloud
Cloud Native Microservices with Spring Cloud
 
Continuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CIContinuous Deployment with Kubernetes, Docker and GitLab CI
Continuous Deployment with Kubernetes, Docker and GitLab CI
 
Test your Kubernetes operator with Operator Lifecycle Management
Test your Kubernetes operator with Operator Lifecycle ManagementTest your Kubernetes operator with Operator Lifecycle Management
Test your Kubernetes operator with Operator Lifecycle Management
 
Migrating Java JBoss EAP Applications to Kubernetes With S2I
Migrating Java JBoss EAP Applications to Kubernetes With S2IMigrating Java JBoss EAP Applications to Kubernetes With S2I
Migrating Java JBoss EAP Applications to Kubernetes With S2I
 
Open shift 4 infra deep dive
Open shift 4    infra deep diveOpen shift 4    infra deep dive
Open shift 4 infra deep dive
 
CI/CD Pipeline mit Gitlab CI und Kubernetes
CI/CD Pipeline mit Gitlab CI und KubernetesCI/CD Pipeline mit Gitlab CI und Kubernetes
CI/CD Pipeline mit Gitlab CI und Kubernetes
 
Cloud Foundry Introduction for CF Meetup Tokyo March 2016
Cloud Foundry Introduction for CF Meetup Tokyo March 2016Cloud Foundry Introduction for CF Meetup Tokyo March 2016
Cloud Foundry Introduction for CF Meetup Tokyo March 2016
 
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the ProxyCloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
Cloud Foundry Day in Tokyo Lightning Talk - Cloud Foundry over the Proxy
 
OpenShift in your own backyard - DevConf CZ 2021
OpenShift in your own backyard - DevConf CZ 2021OpenShift in your own backyard - DevConf CZ 2021
OpenShift in your own backyard - DevConf CZ 2021
 
Pluggable Providers - Greg Blomquist - ManageIQ Design Summit 2016
Pluggable Providers - Greg Blomquist - ManageIQ Design Summit 2016Pluggable Providers - Greg Blomquist - ManageIQ Design Summit 2016
Pluggable Providers - Greg Blomquist - ManageIQ Design Summit 2016
 
Apache Continuum Build, Test, and Release
Apache Continuum Build, Test, and ReleaseApache Continuum Build, Test, and Release
Apache Continuum Build, Test, and Release
 
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
邁向 Windows Server 應用程式現代化 (Windows Server Application Modernization)
 
WJAX 2013: Java8-Tooling in Eclipse
WJAX 2013: Java8-Tooling in EclipseWJAX 2013: Java8-Tooling in Eclipse
WJAX 2013: Java8-Tooling in Eclipse
 
Red Hat OpenShift Operators - Operators ABC
Red Hat OpenShift Operators - Operators ABCRed Hat OpenShift Operators - Operators ABC
Red Hat OpenShift Operators - Operators ABC
 
OpenShift In a Nutshell - Episode 06 - Core Concepts Part II
OpenShift In a Nutshell - Episode 06 - Core Concepts Part IIOpenShift In a Nutshell - Episode 06 - Core Concepts Part II
OpenShift In a Nutshell - Episode 06 - Core Concepts Part II
 
クラウドネイティブ時代の分散トレーシング - Distributed Tracing in a Cloud Native Age
クラウドネイティブ時代の分散トレーシング - Distributed Tracing in a Cloud Native Ageクラウドネイティブ時代の分散トレーシング - Distributed Tracing in a Cloud Native Age
クラウドネイティブ時代の分散トレーシング - Distributed Tracing in a Cloud Native Age
 
Cicd pixelfederation
Cicd pixelfederationCicd pixelfederation
Cicd pixelfederation
 

En vedette

Scala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.jsScala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.js
takezoe
 

En vedette (15)

A day with sbt
A day with sbtA day with sbt
A day with sbt
 
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
Cloud Foundry Summit 2015: 12 Factor Apps For OperationsCloud Foundry Summit 2015: 12 Factor Apps For Operations
Cloud Foundry Summit 2015: 12 Factor Apps For Operations
 
JavaOne 2015: 12 Factor App
JavaOne 2015: 12 Factor AppJavaOne 2015: 12 Factor App
JavaOne 2015: 12 Factor App
 
[Tech Talks] Typesafe Stack Introduction
[Tech Talks] Typesafe Stack Introduction[Tech Talks] Typesafe Stack Introduction
[Tech Talks] Typesafe Stack Introduction
 
Ruby object model
Ruby object modelRuby object model
Ruby object model
 
Advanced Ruby Idioms So Clean You Can Eat Off Of Them
Advanced Ruby Idioms So Clean You Can Eat Off Of ThemAdvanced Ruby Idioms So Clean You Can Eat Off Of Them
Advanced Ruby Idioms So Clean You Can Eat Off Of Them
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaSphere ver)
 
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
The state of sbt 0.13, sbt server, and sbt 1.0 (ScalaMatsuri ver)
 
Scala : language of the future
Scala : language of the futureScala : language of the future
Scala : language of the future
 
Scala Days NYC 2016
Scala Days NYC 2016Scala Days NYC 2016
Scala Days NYC 2016
 
Beyond the Twelve-Factor App
Beyond the Twelve-Factor AppBeyond the Twelve-Factor App
Beyond the Twelve-Factor App
 
Preparing for distributed system failures using akka #ScalaMatsuri
Preparing for distributed system failures using akka #ScalaMatsuriPreparing for distributed system failures using akka #ScalaMatsuri
Preparing for distributed system failures using akka #ScalaMatsuri
 
12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment12 Factor App: Best Practices for JVM Deployment
12 Factor App: Best Practices for JVM Deployment
 
Scala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.jsScala Warrior and type-safe front-end development with Scala.js
Scala Warrior and type-safe front-end development with Scala.js
 
La démarche Qualité des APP
La démarche Qualité des APP La démarche Qualité des APP
La démarche Qualité des APP
 

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

Jax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud FoundryJax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
martinlippert
 
Comparison of control plane deployment architectures in the scope of hypercon...
Comparison of control plane deployment architectures in the scope of hypercon...Comparison of control plane deployment architectures in the scope of hypercon...
Comparison of control plane deployment architectures in the scope of hypercon...
Miroslav Halas
 

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

The twelve factor app
The twelve factor appThe twelve factor app
The twelve factor app
 
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
 
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud EnvironmentsTools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
Tools and Recipes to Replatform Monolithic Apps to Modern Cloud Environments
 
PaaS Anywhere - Deploying an OpenShift PaaS into your Cloud Provider of Choice
PaaS Anywhere - Deploying an OpenShift PaaS into your Cloud Provider of ChoicePaaS Anywhere - Deploying an OpenShift PaaS into your Cloud Provider of Choice
PaaS Anywhere - Deploying an OpenShift PaaS into your Cloud Provider of Choice
 
Mastinder singh visualcv_resume
Mastinder singh visualcv_resumeMastinder singh visualcv_resume
Mastinder singh visualcv_resume
 
Serverless Pune Meetup 1
Serverless Pune Meetup 1Serverless Pune Meetup 1
Serverless Pune Meetup 1
 
Cloud development technology sharing (BlueMix premier)
Cloud development technology sharing (BlueMix premier)Cloud development technology sharing (BlueMix premier)
Cloud development technology sharing (BlueMix premier)
 
PHP Buildpacks in the Cloud on Bluemix
PHP Buildpacks in the Cloud on BluemixPHP Buildpacks in the Cloud on Bluemix
PHP Buildpacks in the Cloud on Bluemix
 
Cloud Foundry for PHP developers
Cloud Foundry for PHP developersCloud Foundry for PHP developers
Cloud Foundry for PHP developers
 
Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6Learning ASP.NET 5 and MVC 6
Learning ASP.NET 5 and MVC 6
 
The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)The next step from Microsoft - Vnext (Srdjan Poznic)
The next step from Microsoft - Vnext (Srdjan Poznic)
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring BootSpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
 
Node.js an Exectutive View
Node.js an Exectutive ViewNode.js an Exectutive View
Node.js an Exectutive View
 
Viridians on Rails
Viridians on RailsViridians on Rails
Viridians on Rails
 
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud FoundryJax2013 PaaS-Parade - Part 1: Cloud Foundry
Jax2013 PaaS-Parade - Part 1: Cloud Foundry
 
GIDS_15FactorWorkshop.pdf
GIDS_15FactorWorkshop.pdfGIDS_15FactorWorkshop.pdf
GIDS_15FactorWorkshop.pdf
 
Comparison of control plane deployment architectures in the scope of hypercon...
Comparison of control plane deployment architectures in the scope of hypercon...Comparison of control plane deployment architectures in the scope of hypercon...
Comparison of control plane deployment architectures in the scope of hypercon...
 
Development on Cloud,PaaS and SDDC
Development on Cloud,PaaS and SDDCDevelopment on Cloud,PaaS and SDDC
Development on Cloud,PaaS and SDDC
 
Ramji
RamjiRamji
Ramji
 
Introduction to Docker - Vellore Institute of Technology
Introduction to Docker - Vellore Institute of TechnologyIntroduction to Docker - Vellore Institute of Technology
Introduction to Docker - Vellore Institute of Technology
 

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 | neil@nts-dev.com 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/