Cloud Foundry Documentation
- General Information
- Contribute to Cloud Foundry documentation
- Cloud Foundry concepts
- Cloud Foundry Command Line Interface (cf CLI)
-
- Information for Operators
- Deploying Cloud Foundry
- Administering Cloud Foundry
- Managing the runtime
- User accounts and communications
- Routing
- Enabling IPv6 for hosted apps
- Distributed tracing
- Enabling Zipkin tracing
- Enabling W3C tracing
- Supporting WebSockets
- Configuring load balancer health checks for CF routers
- Troubleshooting slow requests
- Troubleshooting router error responses
- Securing incoming traffic
- Configuring trusted system certificates for apps
- Bulletin Board System data store encryption
- Enabling and configuring TCP routing
- Configuring HTTP/2 support
- Isolation segments
- Delayed jobs in Cloud Foundry
- Managing apps and their stacks
- Running and Troubleshooting Cloud Foundry
- Cloud Foundry logging
- Configuring system logging
- Configuring Diego for upgrades
- Audit Events
- UAA audit requirements
- Usage events and billing
- Configuring SSH access for Cloud Foundry
- Configuring Diego Cell disk cleanup scheduling
- Configuring Health Monitor Notifications
- Adding a custom stack
- Monitoring and testing Diego components
- Troubleshooting Cloud Foundry
- UAA performance
- UAA performance metrics
- Scaling Cloud Controller
- Cloud Controller Multi-Process Mode (Puma)
- Scaling Cloud Controller (cf-for-k8s)
- Logging and metrics in Cloud Foundry
- Logging and metrics architecture
- Installing the Loggregator plug-in for cf CLI
- Security event logging
- App logging in Cloud Foundry
- Limiting your app log rate in Cloud Foundry
- Cloud Foundry component metrics
- Container metrics
- Loggregator guide for Cloud Foundry operators
- Logging and metrics in Cloud Foundry
- Configuring the OpenTelemetry Collector
- Deploying a nozzle to your Cloud Foundry Loggregator Firehose
- BOSH Documentation
- BOSH Backup and Restore (BBR)
- Information for developers
- Developing and managing apps
- How to push your app with Cloud Foundry CLI (cf push)
- Pushing your app using Cloud Foundry CLI (cf push)
- Deploying with app manifests
- App manifest attribute reference
- Deploying an app with Docker
- Deploying your large apps
- Starting, restarting, and restaging apps
- Pushing an app with multiple processes
- Running cf push sub-step commands
- Configuring app deployments
- Pushing apps with sidecar processes
- Using blue-green deployment to reduce downtime
- Troubleshooting app deployment and health
- SSH for apps and services
- Routes and domains
- Managing services
- Streaming app logs
- Managing apps with the cf CLI
- Cloud Foundry environment variables
- Available Cloud Controller API client libraries
- Designing and running your app in the cloud
- Cloud Foundry API app revisions
- How to push your app with Cloud Foundry CLI (cf push)
- Cloud Foundry Buildpacks
- Cloud Native Buildpacks
- Classic Buildpacks
- What are classic buildpacks?
- Binary buildpack
- Go buildpack
- Hosted Web Core buildpack
- Java buildpack
- .NET Core buildpack
- NGINX buildpack
- Node.js buildpack
- Using PHP buildpack with runtimes
- Python buildpack
- R buildpack
- Ruby buildpack
- Staticfile buildpacks
- Creating custom buildpacks
- Information for Managed Service Authors
- Services in Cloud Foundry
- Service Broker API
- Managing service brokers in Cloud Foundry
- Managing access to service plans
- Binding credentials in Cloud Foundry
- CredHub
- Dashboard Single Sign-on
- Service instance sharing in Cloud Foundry
- Service broker examples
- App log streaming in Cloud Foundry
- Offering Route Services in Cloud Foundry
- Supporting multiple CF instances
- User Account and Authentication
- API Reference
- UAA API
- CAPI API
Using Java Native Image in Cloud Foundry
Page last updated:
You can build your Java apps with native image support and deploy those apps to Cloud Foundry.
A growing number of Java users are building Java apps using support for native images. For more information, see Native Image in the GraalVM documentation.
Java users deploying to Cloud Foundry can deploy apps compiled using native image support. However, the Cloud Foundry Java buildpack does not provide support to build, compile, and turn apps into a native image. You must perform those steps before deploying to Cloud Foundry.
To build an app to run on Cloud Foundry, use native build tools as described below.
Building using Native Build Tools
This section describes how to deploy a Java app with native image support using Native Build Tools. If you do not want to build using Cloud Native Buildpacks, you can build and compile directly using the Native Build Tools.
To build a Java app using Native Build Tools:
Obtain an Ubuntu Bionic computer, VM, or container. Ubuntu Bionic is recommended for best compatibility with the Cloud Foundry
cflinuxfs3root filesystem. Ubuntu 22.04 LTS (Jammy Jellyfish) is recommended for use withcflinuxfs4.Install GraalVM. See Get Started with GraalVM.
Install the Java Native Image tools. See Install Native Image.
To add the Native Build Tools to your Maven or Gradle project, follow the instructions in Add the native build tools plugin in the Spring documentation. This only needs to be done once.
Clone the example repository from GitHub:
git clone https://github.com/paketo-buildpacks/samples cd samples/java/native-image/java-native-image-sampleBuild the example image:
mvn -Pnative -DskipTests package
For more information about building with Native Build Tools, see Getting started with native build tools in the Spring documentation.
Deploying with direct build
This section describes how to deploy a Java app with native image support using a direct build.
To deploy a Java app with native image support using the binary buildpack:
Zip the executable created by your build tool, either Maven or Gradle. For example, with Maven,
zip demo.zip target/demo. Alternatively, you can copy the executable into a directory by itself. For example, with Maven,mkdir -p ./out && cp target/demo ./out/. This is the root forcf push.Push the root ZIP file or directory you created in the previous step. If you use a directory instead of a ZIP archive, adjust the
-pargument. This is important so that it only uploads the compiled binary, not your entire project. You can adjust other properties or use amanifest.ymlfile to deploy as well.cf push -b binary_buildpack -p demo.zip -c ./target/demo native-image
Spring Boot and Spring Native
Regardless of how you build your app, with Spring Boot v2.5 and Spring Native v0.10.1, there is a bug that causes cf push to fail.
The problem is caused by conditional behavior in Spring Boot Actuator when run on Cloud Foundry. It is fixed in Spring Native v0.10.2.
For more information, see the spring-projects-experimental repository on GitHub.
You can also work around this issue by adding the following hints above your @SpringBootapp annotation:
For example:
@NativeHint(trigger = ReactiveCloud FoundryActuatorAutoConfiguration.class, types = {
@TypeHint(types = EndpointCloud FoundryExtension.class, access = AccessBits.ANNOTATION),
@TypeHint(typeNames = "org.springframework.boot.actuate.autoconfigure.Cloud Foundry.Cloud FoundryEndpointFilter"),
@TypeHint(typeNames = "org.springframework.boot.actuate.autoconfigure.Cloud Foundry.reactive.Cloud FoundryWebFluxEndpointHandlerMapping$Cloud FoundryLinksHandler", access = AccessBits.LOAD_AND_CONSTRUCT
| AccessBits.DECLARED_METHODS) })
@NativeHint(trigger = Cloud FoundryActuatorAutoConfiguration.class, types = {
@TypeHint(types = EndpointCloud FoundryExtension.class, access = AccessBits.ANNOTATION),
@TypeHint(typeNames = "org.springframework.boot.actuate.autoconfigure.Cloud Foundry.Cloud FoundryEndpointFilter"),
@TypeHint(typeNames = "org.springframework.boot.actuate.autoconfigure.Cloud Foundry.servlet.Cloud FoundryWebEndpointServletHandlerMapping$Cloud FoundryLinksHandler", access = AccessBits.LOAD_AND_CONSTRUCT
| AccessBits.DECLARED_METHODS) })
@SpringBootapp
public class Demoapp {
public static void main(String[] args) {
Springapp.run(Demoapp.class, args);
}
}
Create a pull request or raise an issue on the source for this page in GitHub
