| // ======================================================================== |
| // Copyright (c) 1995-2017 Mort Bay Consulting Pty. Ltd. |
| // ======================================================================== |
| // All rights reserved. This program and the accompanying materials |
| // are made available under the terms of the Eclipse Public License v1.0 |
| // and Apache License v2.0 which accompanies this distribution. |
| // |
| // The Eclipse Public License is available at |
| // http://www.eclipse.org/legal/epl-v10.html |
| // |
| // The Apache License v2.0 is available at |
| // http://www.opensource.org/licenses/apache2.0.php |
| // |
| // You may elect to redistribute this code under either of these licenses. |
| // ======================================================================== |
| |
| [[cloudfoundry]] |
| === CloudFoundry |
| |
| ____ |
| [WARNING] |
| This is an increasingly aged integration, things like likely changed enough this is not directly useful but may serve as a useful starting point should someone want to look into it. |
| ____ |
| |
| [[cloudfoundry-overview]] |
| ==== Overview |
| |
| http://www.cloudfoundry.com[CloudFoundry] is an open platform intended as a place to deploy end user applications in a manner which is both simple and eminently scalable to fit the needs of the application. |
| With the release of their V2 framework the Jetty project has created a buildpack which allows you to deploy your java based web application onto Jetty and still make use of the remainder of the CloudFoundry platform. |
| |
| This buildpack itself is quite simple to use. |
| A collection of ruby scripting and the buildpack conventions will allow Jetty to be downloaded, configured and customized to your needs and then have your web application deployed onto it. |
| While the default buildpack we have created is useful to deploy a stock configuration of jetty, it is quite likely that you will want to fork the buildpack and tweak it to fit your immediate needs. |
| This process is made trivial since buildpacks install from a github repository. |
| For example, to change the jetty version simply fork it in GitHub and tweak the `JETTY_VERSION` string in the `jetty_web.rb` file. |
| |
| If you have additional modifications to make to the Jetty server, like perhaps configuring additional static contexts, setting up a proxy servlet, adding jar files to the jetty home/lib/ext directory, etc you can either adapt the ruby scripting directly or place them under the appropriate location in the `/resources` directory of this buildpack and they will be copied into the correct location. |
| |
| For the time being I'll leave this buildpack under my personal github account and should there be interest expressed I am more then happy to push it over to https://github.com/jetty-project down the road for proper contributions, etc. |
| |
| [[cloudfoundry-usage]] |
| ==== Usage |
| |
| To show how incredibly easy it is to use the Jetty buildpack with cloudfoundry, this is all the more you need to do to deploy your application. |
| Refer to the CloudFoundry http://docs.cloudfoundry.com/[documentation] to get started, get the `cf` utilities installed and an environment configured. |
| |
| [source, screen, subs="{sub-order}"] |
| .... |
| $ cf push snifftest --buildpack=git://github.com/jmcc0nn3ll/jetty-buildpack.git |
| |
| .... |
| |
| ____ |
| [TIP] |
| In this example the web application is uploaded from the *current* directory so make sure you have changed directory into the root of your web application. |
| The `snifftest` on the commandline referrs to what you are calling the application, not the directory to deploy. |
| Also note that the webapplication is installed into the `ROOT` context of Jetty as is available at the root context of the server. |
| Any additional web applications will have to be configured within the buildpack as mentioned above. |
| ____ |
| |
| You will be prompted to answer a series of questions describing the execution environment and any additional services you need enabled (databases, etc). |
| |
| [source, plain, subs="{sub-order}"] |
| ---- |
| |
| Instances> 1 |
| |
| Custom startup command> none |
| |
| 1: 64M |
| 2: 128M |
| 3: 256M |
| 4: 512M |
| 5: 1G |
| Memory Limit> 256M |
| |
| Creating snifftest... OK |
| |
| 1: snifftest |
| 2: none |
| Subdomain> snifftest |
| |
| 1: a1-app.cf-app.com |
| 2: none |
| Domain> a1-app.cf-app.com |
| |
| Binding snifftest.a1-app.cf-app.com to snifftest... OK |
| |
| Create services for application?> n |
| |
| Save configuration?> n |
| |
| |
| ---- |
| |
| Once answered you will see the installation process of your application. |
| |
| [source, plain, subs="{sub-order}"] |
| ---- |
| |
| Uploading snifftest... OK |
| Starting snifftest... OK |
| -> Downloaded app package (4.0K) |
| Initialized empty Git repository in /tmp/buildpacks/jetty-buildpack.git/.git/ |
| Installing jetty-buildpack.git. |
| Downloading JDK... |
| Copying openjdk-1.7.0_21.tar.gz from the buildpack cache ... |
| Unpacking JDK to .jdk |
| Downloading Jetty: jetty-distribution-{VERSION}.tar.gz |
| Downloading jetty-distribution-{VERSION}.tar.gz from http://repo2.maven.org/maven2/org/eclipse/jetty/jetty-distribution/9.0.3.v20130506/ ... |
| Unpacking Jetty to .jetty |
| -> Uploading staged droplet (36M) |
| -> Uploaded droplet |
| Checking snifftest... |
| Staging in progress... |
| Staging in progress... |
| Staging in progress... |
| Staging in progress... |
| Staging in progress... |
| Staging in progress... |
| 0/1 instances: 1 starting |
| 0/1 instances: 1 starting |
| 0/1 instances: 1 starting |
| 0/1 instances: 1 starting |
| 1/1 instances: 1 running |
| OK |
| |
| ---- |
| |
| The application is now available at the configured location! Under the url `http://snifftest.a1-app.cf-app.com/` in this particular example. |
| |
| [[cloudfoundry-acknowledgements]] |
| ==== Acknowledgements |
| |
| The Jetty buildpack was forked from the CloudFoundry Java buildpack. The Virgo Buildpack that Glyn worked on was used as a sanity check. |
| |
| * http://github.com/cloudfoundry/cloudfoundry-buildpack-java |
| * http://github.com/glyn/virgo-buildpack |
| |
| CloudFoundry buildpacks were modelled on Heroku buildpacks. |
| |