Version: 9.4.20.v20190813 |

CloudFoundry
Previous | Chapter 31. Platforms, Stacks and Alternative Distributions Home | Next

##### Contact the core Jetty developers at www.webtide.com

private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services for sponsored feature development

## 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.

### Overview

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.

### 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 documentation to get started, get the `cf` utilities installed and an environment configured.

    $ 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 refers 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).

    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.

    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-9.4.20.v20190813.tar.gz
    Downloading jetty-distribution-9.4.20.v20190813.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.

### 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.

Previous | Top | Next
Jelastic | Home | Amazon Elastic Beanstalk

See an error or something missing? Contribute to this documentation at Github!(Generated: 2019-08-13)