• Stars
    star
    425
  • Rank 98,741 (Top 2 %)
  • Language
    Ruby
  • License
    Apache License 2.0
  • Created about 11 years ago
  • Updated 8 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Cloud Foundry buildpack for running Java applications

Cloud Foundry Java Buildpack

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.

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/cloudfoundry/java-buildpack.git

Examples

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

Configuration and Extension

The buildpack default configuration can be overridden with an environment variable matching the configuration file you wish to override minus the .yml extension. It is not possible to add new configuration properties and properties with nil or empty values will be ignored by the buildpack (in this case you will have to extend the buildpack, see below). The value of the variable should be valid inline yaml, referred to as "flow style" in the yaml spec (Wikipedia has a good description of this yaml syntax).

There are two levels of overrides: operator and application developer.

  • If you are an operator that wishes to override configuration across a foundation, you may do this by setting environment variable group entries that begin with a prefix of JBP_DEFAULT.
  • If you are an application developer that wishes to override configuration for an individual application, you may do this by setting environment variables that begin with a prefix of JBP_CONFIG.

Here are some examples:

Operator

  1. To change the default version of Java to 11 across all applications on a foundation.
$ cf set-staging-environment-variable-group '{"JBP_DEFAULT_OPEN_JDK_JRE":"{jre: {version: 11.+ }}"}'
  1. To change the default repository root across all applications on a foundation. Be careful to ensure that your JSON is properly escaped.
$ cf set-staging-environment-variable-group '{"JBP_DEFAULT_REPOSITORY": "{default_repository_root: \"http://repo.example.io\" }"}'
  1. To change the default JVM vendor across all applications on a foundation. Be careful to ensure that your JSON is properly escaped.
$ cf set-staging-environment-variable-group '{"JBP_DEFAULT_COMPONENTS": "{jres: [\"JavaBuildpack::Jre::ZuluJRE\"]}"}'

Application Developer

  1. To change the default version of Java to 11 and adjust the memory heuristics then apply this environment variable to the application.
$ cf set-env my-application JBP_CONFIG_OPEN_JDK_JRE '{ jre: { version: 11.+ }, memory_calculator: { stack_threads: 25 } }'
  1. If the key or value contains a special character such as : it should be escaped with double quotes. For example, to change the default repository path for the buildpack.
$ cf set-env my-application JBP_CONFIG_REPOSITORY '{ default_repository_root: "http://repo.example.io" }'
  1. If the key or value contains an environment variable that you want to bind at runtime you need to escape it from your shell. For example, to add command line arguments containing an environment variable to a Java Main application.
$ cf set-env my-application JBP_CONFIG_JAVA_MAIN '{ arguments: "--server.port=9090 --foo=bar" }'
  1. An example of configuration is to specify a javaagent that is packaged within an application.
$ cf set-env my-application JAVA_OPTS '-javaagent:app/META-INF/myagent.jar -Dmyagent.config_file=app/META-INF/my_agent.conf'
  1. Environment variable can also be specified in the applications manifest file. For example, to specify an environment variable in an applications manifest file that disables Auto-reconfiguration.
env:
  JBP_CONFIG_SPRING_AUTO_RECONFIGURATION: '{ enabled: false }'
  1. This final example shows how to change the version of Tomcat that is used by the buildpack with an environment variable specified in the applications manifest file.
env:
  JBP_CONFIG_TOMCAT: '{ tomcat: { version: 8.0.+ } }'

See the Environment Variables documentation for more information.

To learn how to configure various properties of the buildpack, follow the "Configuration" links below.

The buildpack supports 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 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. 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.

Note that this process is not currently supported on Windows. It is possible it will work, but it is not tested, and no additional functionality has been added to make it work.

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 250K in size. To create the online package, run:

$ bundle install
$ bundle exec rake clean 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. To create the offline package, use the OFFLINE=true argument:

To pin the version of dependencies used by the buildpack to the ones currently resolvable use the PINNED=true argument. This will update the config/ directory to contain exact version of each dependency instead of version ranges.

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

If you would rather specify the exact version to which the buildpack should bundle, you may manually edit the config/ file for the component and indicate the specific version to use. For most components, there is a single version property which defaults to a pattern to match the latest version. By setting the version property to a fixed version, the buildpack will install that exact version when you run the package command. For JRE config files, like config/open_jdk_jre.yml, you need to set the version_lines array to include the specific version you'd like to install. By default, the version_lines array is going to have a pattern entry for each major version line that matches to the latest patch version. You can override the items in the version_lines array to set a specific versions to use when packaging the buildpack. For a JRE, the jre.version property is used to set the default version line and must match one of the entries in the version_lines property.

This package size will vary depending on what dependencies are included. You can reduce the size by removing unused components, because only packages referenced in the config/components.yml file will be cached. In addition, you can remove entries from the version_lines array in JRE configuration files, this removes that JRE version line, to further reduce the file size.

Additional packages may be added using the ADD_TO_CACHE argument. The value of ADD_TO_CACHE should be set to the name of a .yml file in the config/ directory with the .yml file extension omitted (e.g. sap_machine_jre). Multiple file names may be separated by commas. This is useful to add additional JREs. These additional components will not be enabled by default and must be explicitly enabled in the application with the JBP_CONFIG_COMPONENTS environment variable.

$ bundle install
$ bundle exec rake clean package OFFLINE=true ADD_TO_CACHE=sap_machine_jre,ibm_jre
...
Caching https://public.dhe.ibm.com/ibmdl/export/pub/systems/cloud/runtimes/java/8.0.6.26/linux/x86_64/ibm-java-jre-8.0-6.26-x86_64-archive.bin
Caching https://github.com/SAP/SapMachine/releases/download/sapmachine-11.0.10/sapmachine-jre-11.0.10_linux-x64_bin.tar.gz
...
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 clean package VERSION=2.1
...
Creating build/java-buildpack-2.1.zip

Packaging Caveats

  1. Prior to version 4.51 when pinning versions, only the default JRE version is pinned. There is special handling to package additional versions of a JRE and the way this works, it will pick the latest version at the time you package not at the time of the version's release. Starting with version 4.51, the version number for all JRE version lines is tracked in the config/ file.

  2. The index.yml file for a dependency is packaged in the buildpack cache when building offline buildpacks. The index.yml file isn't versioned with the release, so if you package an offline buildpack later after the release was tagged, it will pull the current index.yml, not the one from the time of the release. This can result in errors at build time if a user tells the buildpack to install the latest version of a dependency because the latest version is calculated from the index.yml file which has more recent versions than what are packaged in the offline buildpack. For example, if the user says give me Java 11._+ and the buildpack is pinned to Java 11.0.13_8 but at the time you packaged the buildpack the latest version in index.yml is 11.0.15_10 then the user will get an error. The buildpack will want to install 11.0.15_10 but it won't be present because 11.0.13_8 is all that's in the buildpack.

    Because of #1 for versions prior to 4.51, this only impacts the default JRE. Non-default JREs always package the most recent version, which is also the most recent version in index.yml at the time you package the offline buildpack. For 4.51 and up, this can impact all versions.

  3. Because of #1 and #2, it is not possible to accurately reproduce packages of the buildpack, after releases have been cut. If building pinned or offline buildpacks, it is suggested to build them as soon as possible after a release is cut and save the produced artifact. Alternatively, you would need to maintain your own buildpack dependency repository and keep snapshots of the buildpack dependency repository for each buildpack release you'd like to be able to rebuild.

See #892 for additional details.

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.

Contributing

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

License

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

More Repositories

1

bosh

Cloud Foundry BOSH is an open source tool chain for release engineering, deployment and lifecycle management of large scale distributed services.
Ruby
2,010
star
2

cli

The official command line client for Cloud Foundry
Go
1,733
star
3

uaa

CloudFoundry User Account and Authentication (UAA) Server
Java
1,541
star
4

java-buildpack-memory-calculator

Cloud Foundry JVM Memory Calculator
Go
602
star
5

gosigar

A Golang implementation of the Sigar API
Go
453
star
6

gorouter

CF Router
Go
429
star
7

go-diodes

Diodes are ring buffers manipulated via atomics.
Go
411
star
8

cf-java-client

Java Client Library for Cloud Foundry
Java
318
star
9

cf-for-k8s

The open source deployment manifest for Cloud Foundry on Kubernetes
Shell
302
star
10

korifi

Cloud Foundry on Kubernetes
Go
284
star
11

cf-deployment

The canonical open source deployment manifest for Cloud Foundry
Go
279
star
12

stratos

Stratos: Web-based Management UI for Cloud Foundry and Kubernetes
TypeScript
241
star
13

credhub

CredHub centralizes and secures credential generation, storage, lifecycle management, and access
Java
225
star
14

garden

Go Warden
Go
223
star
15

java-buildpack-auto-reconfiguration

Auto-reconfiguration functionality for the Java Buildpack
Java
219
star
16

loggregator-release

Cloud Native Logging
Go
217
star
17

bytefmt

Human readable byte formatter
Go
208
star
18

diego-release

BOSH Release for Diego
HTML
199
star
19

staticfile-buildpack

Deploy static HTML/JS/CSS apps to Cloud Foundry
Go
199
star
20

cloud_controller_ng

Cloud Foundry Cloud Controller
Ruby
181
star
21

bosh-bootloader

Command line utility for standing up a BOSH director on an IAAS of your choice.
Go
176
star
22

bosh-cli

BOSH CLI v2+
Go
174
star
23

nodejs-buildpack

Cloud Foundry buildpack for Node.js
Go
161
star
24

diego-design-notes

Diego Architectural Design Musings and Explications
HTML
142
star
25

php-buildpack

A Cloud Foundry Buildpack for PHP.
Python
142
star
26

bosh-deployment

Collection of BOSH manifests referenced by cloudfoundry/docs-bosh
Shell
125
star
27

python-buildpack

Cloud Foundry buildpack for the Python Language
Go
118
star
28

eirini

Pluggable container orchestration for Cloud Foundry, and a Kubernetes backend
Go
115
star
29

go-buildpack

Cloud Foundry buildpack for the Go Language
Go
80
star
30

cloud-service-broker

OSBAPI service broker that uses Terraform to provision and bind services. Derived from https://github.com/GoogleCloudPlatform/gcp-service-broker
Go
78
star
31

multiapps-cli-plugin

A CLI plugin for Multi-Target Application (MTA) operations in Cloud Foundry
Go
77
star
32

guardian

containers4life
Go
75
star
33

lager

An opinionated logger for Go.
Go
73
star
34

app-autoscaler

Auto Scaling for CF Applications
Go
73
star
35

ibm-websphere-liberty-buildpack

IBM WebSphere Application Server Liberty Buildpack
Ruby
71
star
36

summit-training-classes

Opensourced content for cloud foundry training classes: zero to hero (beginner), bosh/operator, and microservices
JavaScript
69
star
37

cf-acceptance-tests

CF Acceptance tests
Go
68
star
38

cf-networking-release

Container Networking for CloudFoundry
Go
68
star
39

ruby-buildpack

Cloud Foundry buildpack for Ruby, Sinatra and Rails
Go
63
star
40

garden-runc-release

Shell
63
star
41

bosh-google-cpi-release

BOSH Google CPI
Go
62
star
42

bosh-azure-cpi-release

BOSH Azure CPI
Ruby
61
star
43

loggregator

Archived: Now bundled in https://github.com/cloudfoundry/loggregator-release
Go
60
star
44

cf-mysql-release

Cloud Foundry MySQL Release
Go
58
star
45

go-pubsub

Tree based pubsub library for Go.
Go
56
star
46

bosh-agent

BOSH Agent runs on each BOSH deployed VM
Go
56
star
47

docs-book-cloudfoundry

The bookbinder repository for open source Cloud Foundry documentation
HTML
55
star
48

homebrew-tap

Cloud Foundry Homebrew packages
Ruby
53
star
49

multiapps-controller

The server side component (controller) for Multi-Target Application (MTA) for Cloud Foundry
Java
52
star
50

socks5-proxy

This is a go library for starting a socks5 proxy server via SSH
Go
44
star
51

cf-uaac

Ruby
41
star
52

docs-cloudfoundry-concepts

A place for architecture and concept docs
HTML
41
star
53

buildpacks-ci

Concourse CI pipelines for the buildpacks team
HTML
41
star
54

service-fabrik-broker

Cloud Foundry service broker which provisions service instances as Docker containers and BOSH deployments.
JavaScript
40
star
55

grootfs

Garden root file system
Go
40
star
56

routing-release

This is the BOSH release for cloud foundry routers
Ruby
39
star
57

docs-dev-guide

Documentation for application developers who want to deploy their applications to Cloud Foundry
HTML
39
star
58

community

Governance and contact information for Cloud Foundry
Python
38
star
59

cf-smoke-tests

Smoke tests for CloudFoundry that are safe to run in a production environment
Go
38
star
60

credhub-cli

CredHub CLI provides a command line interface to interact with CredHub servers
Go
38
star
61

bosh-linux-stemcell-builder

BOSH Ubuntu Linux stemcells
Ruby
37
star
62

haproxy-boshrelease

A BOSH release for haproxy (based on cf-release's haproxy job)
Ruby
37
star
63

pmc-notes

Agendas and Notes for Cloud Foundry Project Management Committee Meetings
36
star
64

eirini-release

Helm release for Project Eirini
Shell
36
star
65

bosh-s3cli

Go CLI for S3
Go
36
star
66

bpm-release

isolated bosh jobs
Go
35
star
67

cfdot

A command-line tool to interact with a Cloud Foundry Diego deployment.
Go
34
star
68

libbuildpack

A library for writing buildpacks
Go
34
star
69

bosh-openstack-cpi-release

BOSH OpenStack CPI
Ruby
33
star
70

java-test-applications

Applications used for testing the Java buildpack
Java
33
star
71

switchboard

Golang TCP Proxy
JavaScript
33
star
72

docs-bosh

The docs repo for BOSH
HTML
32
star
73

cf-k8s-networking

building a cloud foundry without gorouter....
Go
32
star
74

cflinuxfs2

The official Cloud Foundry app container rootfs
Ruby
31
star
75

pxc-release

BOSH release of Percona Xtradb Cluster
JavaScript
30
star
76

clock

time provider & rich fake for Go
Go
30
star
77

bosh-vsphere-cpi-release

BOSH vSphere CPI
Ruby
30
star
78

os-conf-release

Additional Linux OS configuration release
Go
30
star
79

binary-buildpack

Deploy binaries to Cloud Foundry
Shell
28
star
80

bbs

Internal API to access the database for Diego.
Go
28
star
81

nginx-buildpack

Cloud Foundry buildpack that provides NGINX
Go
28
star
82

jumpbox-deployment

Deploy single vanilla jumpbox machine with BOSH
Shell
28
star
83

bosh-aws-cpi-release

BOSH AWS CPI
Ruby
27
star
84

uaa-release

Bosh Release for the UAA
Ruby
27
star
85

app-autoscaler-release

Automated scaling for apps running on Cloud Foundry
Go
26
star
86

archiver

Utilities for extracting and compressing tgz and zip files.
Go
26
star
87

bosh-backup-and-restore

Go
26
star
88

exemplar-release

Shell
25
star
89

apt-buildpack

Go
25
star
90

diego-notes

Diego Notes
23
star
91

capi-release

Bosh Release for Cloud Controller and friends
HTML
23
star
92

noaa

NOAA is a client library to consume metric and log messages from Doppler.
Go
23
star
93

metric-store-release

Metric Store: A Cloud-Native Time Series Database for Cloud Foundry
Go
23
star
94

cli-plugin-repo

Public repository for community created CF CLI plugins.
Go
23
star
95

cf-deployment-concourse-tasks

Shell
23
star
96

buildpack-packager

Buildpack Packager
Ruby
23
star
97

uaa-cli

CLI for UAA written in Go
Go
22
star
98

galera-healthcheck

A lightweight web server written in Golang to check the health of a node in a Galera cluster
Go
21
star
99

docs-buildpacks

HTML
21
star
100

winc

CLI tool for spawning and running containers on Windows according to the OCI specification
Go
21
star