Skip to content

smlingesh/java-buildpack

 
 

Cloud Foundry Java Buildpack + support zip files are having *.war + CT-agent jar support + Shared lib support with YAML upload having maven GAV co-ordinates

Build Status Dependency Status Code Climate Code Climate

The java-buildpack is a Cloud Foundry buildpack for running JVM-based applications. It is designed to run many JVM-based applications (Grails, Groovy, Java Main, Play Framework, Spring Boot, and Servlet) with no additional configuration, but supports configuration of the standard components, and extension to add custom components. Also we can push *.zip file which has contain multiple war files. cleartrust-plugin jar will be available in part of buildpack and will be extracted into tomcat/libs folders. Also Tomcat-Valve config entry will be part of section in server.xml

currently this buildback has been enhanced for supporting YAML structure which will have libraries , webapps , repository url , credentials for getting maven application artifacts. multple context path mapping also take care.

CT -agent jars Support for Tomcat shard lib.

cleartrust-plugin jar will be part of buildpack resources/tomcat/lib folder. so during compile phase ct agent jar will be extracted into tomcat/lib folders. tomcat valve entry will be part of server.xml entry.

shared lib - webapps support using YAML file upload.

web applications along with supported libraries can be uploaded as YAML format with GAV co-ordinates. below are the sample YAML structure. Also multiple context path will be dynamically added to Server.xml as a entry.

  location: <LOCATION>
  repo-id: <REPOSITORY>
  authentication:
    username: <username>
    password: <password>
libraries: #specify all libraries as a sequence of GAV Coordinates. These would go in tomcat\lib folder
- g: <groupId>
  a: <artifactId>
  v: <version>
      
webapps: #specify all wars as a sequence of GAV Coordinates this would go into tomcat\webapps folder
- g: <groupId>
  a: <artifactId>
  v: <version>
  context-path: <contextpath>
- g: <groupId>
     a:<artifactId>
     v:<version>

all the jars and wars will be downloaded and verify SHA checksum for validation. all the jars will be copied over to tomcat/lib and webapps will have all wars.

###Even shared libs can be (optional). if we want to use libraries as optional then remove the below section from YAML

libraries: #specify all libraries as a sequence of GAV Coordinates. These would go in tomcat\lib folder
- g: <groupId>
  a: <artifactId>
  v: <version>

cf push for YAML steps

##Following are the steps to push this yaml and test out the buildpack..
1.	Copy the attached YAML to an empty directory
2.	With PWD being the directory in 1 do a "cf p <app-name> -b https://github.com/happiestminds-covisint/java-buildpack.git”
3.	Your instance should come up with out issue.
4.	Now go to http://<domain>/check. And you should get a success response.
5.	Now go to http://<domain>/classes?className=sample.SampleTCValve. And it will tell the sample.SampleTCValve class was found. This class is part of the library that is being pushed using the manifest and it goes into the shared classpath.

##Notes:

  1. Passing the manifest using "–p” does not work. Looks like the CF CLI does not support upload of a single file which is not an Archive. I think this might work using the CF rest APIs. Let me know if it does not.. Will find some work around for you.
  2. Use *.yaml for now. *.yml does not work. Looks like CF CLI strips *.yml files before upload. Should work with the rest API. But stick to *.yaml as that seems to the official extension

##convert YAML file into zip formation and use like below

 cf p <app-name> -b https://github.com/happiestminds-covisint/java-buildpack.git -p repo-manifest.zip 

Usage

To use this buildpack specify the URI of the repository when pushing an application to Cloud Foundry:

cf push <APP-NAME> -p <ARTIFACT> -b https://github.com/happiestminds-covisint/java-buildpack.git

Examples

The following are very simple examples for deploying the artifact types that we support.

Configuration and Extension

The buildpack supports configuration and extension through the use of Git repository forking. The easiest way to accomplish this is to use GitHub's forking functionality to create a copy of this repository. Make the required configuration and extension changes in the copy of the repository. Then specify the URL of the new repository when pushing Cloud Foundry applications. If the modifications are generally applicable to the Cloud Foundry community, please submit a pull request with the changes.

To learn how to configure various properties of the buildpack, follow the "Configuration" links below. More information on extending the buildpack is available here.

Additional Documentation

Building Packages

The buildpack can be packaged up so that it can be uploaded to Cloud Foundry using the cf create-buildpack and cf update-buildpack commands. In order to create these packages, the rake package task is used.

Online Package

The online package is a version of the buildpack that is as minimal as possible and is configured to connect to the network for all dependencies. This package is about 50K in size. To create the online package, run:

bundle install
bundle exec rake package
...
Creating build/java-buildpack-cfd6b17.zip

Offline Package

The offline package is a version of the buildpack designed to run without access to a network. It packages the latest version of each dependency (as configured in the config/ directory) and disables remote_downloads. This package is about 180M in size. To create the offline package, use the OFFLINE=true argument:

bundle install
bundle exec rake package OFFLINE=true
...
Creating build/java-buildpack-offline-cfd6b17.zip

Package Versioning

Keeping track of different versions of the buildpack can be difficult. To help with this, the rake package task puts a version discriminator in the name of the created package file. The default value for this discriminator is the current Git hash (e.g. cfd6b17). To change the version when creating a package, use the VERSION=<VERSION> argument:

bundle install
bundle exec rake package VERSION=2.1
...
Creating build/java-buildpack-2.1.zip

Running Tests

To run the tests, do the following:

bundle install
bundle exec rake

Running Cloud Foundry locally is useful for privately testing new features.

Running Tests with Vagrant for Zip supported files

To run the tests, do the following: Bring up the vagrant virtual machine and ssh into it.

vagrant up
vagrant ssh

Run the detect, compile and release commands within the vagrant machine.

cd /vagrant/<directory-containing-war-or-zip-files>

/vagrant/vagrant/run/detect
/vagrant/vagrant/run/compile
/vagrant/vagrant/run/release

Connect to the Tomcat instance on port 12345 on your local machine.

http://localhost:12345

Contributing

Pull requests are welcome; see the contributor guidelines for details.

License

This buildpack is released under version 2.0 of the Apache License.

About

Cloud Foundry buildpack for running Java applications

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 96.5%
  • Groovy 2.0%
  • Shell 1.5%