Estimated Time: 25 minutes

1. Preface

We’ve learned that buildpacks produce the droplets that are needed to run our applications. But how do we customize their behavior? In this lab, you’ll explore ways to configure the version of the java runtime that the java buildpack provisions for your application.

2. Exercises

2.1. Use a Custom Buildpack

  1. Review the documentation on deploying with custom buildpacks and how dependencies are handled with the Java Buildpack online package and the offline package.

  2. Review the Java Version reported by articulate.

    Java Version
  3. Review which buildpack is in use.

    cf app articulate
  4. Push articulate again, but this time specify a custom buildpack. In this case, we will use the latest version of the Java Buildpack on GitHub.

    cd ~/pivotal-cloud-foundry-developer-workshop/articulate/

    ..and:

    cf push articulate -p ./articulate-0.2.jar -b https://github.com/cloudfoundry/java-buildpack.git
  5. Using your browser, refresh the articulate application.

It’s likely (but not required) that the Java Version changed.

What Just Happened?

We instructed our application to use a custom buildpack (as opposed to a system provided one).

In this case, we used the Java Buildpack source on Github as our custom buildpack. The Java Buildpack source is continuously updated and it is an online package of the buildpack. Meaning it has access to all dependencies via the network (it has access to all JRE versions, etc). Whereas, the system provided Java buidpack is offline, with a limited set of dependencies. For both the online and offline packages, unless the Java version is specified the application is run with the latest version of Java available to the buildpack.

2.2. Change the Java version

  1. Review the Java Buildpack configuration and extension documentation.

  2. Let’s assume that we want to run articulate on a specific version Java.

    cf set-env articulate JBP_CONFIG_OPEN_JDK_JRE "{jre: { version: 1.8.0_45 }}"
  3. Using your browser, refresh the articulate application.

    QUESTION: Is the articulate running with 1.8.0_45? Why not?

  4. Restage articulate.

    cf restage articulate

    QUESTION: Would cf restart be sufficient instead of cf restage? Why not?

  5. Using your browser, refresh the articulate application.

2.3. Questions

  • What other items are easily customized with the Java Buildpack?

  • How would you go about customizing the java buildpack to use a different version of the new relic agent jar?

  • If you use Java, what items do you think would need customization in your environment?