VMware tc Server Cloud Native Buildpack
This document describes tc Server Cloud Native Buildpack integration.
tc Server Cloud Native Buildpack (4.1.4+)
This feature uses tc Server 4.1.4 or newer
tc Server includes integration with Cloud Native Buildpacks. This integration is intended to provide simplicity of use and flexibility for advanced use cases.
This integration features the ability to detect an existing instance, a tc Runtime Instance descriptor file (when using required filename), or webapp as the source directory.
Requirements
- An account on Tanzu Network
- The pack command
- An existing environment in which to deploy the generated container
- Familiarity with Cloud Native Buildpacks
An existing VMware tc Server
installation is not required to use the VMware tc Server Cloud Native Buildpack.
Detection
The tc Server CNB functionality has the ability to detect any of the following(source is the directory specified by --path
or the current working directory):
tc Runtime Instance Descriptor File (recommended)
If the source
directory contains a tc Runtime Instance Descriptor file then tc Server will attempt to create the instance specified in the tc Runtime Instance Descriptor file. The instance.directory
, runtimes.directory
, and java.home
properties will be ignored as these are provided by the buildpack.
The allowed filenames are as follows:
- instance-descriptor.properties
- instance-descriptor.yml
- instance-descriptor.yaml
tc Runtime Instance
If the source
directory is a tc Runtime instance it will be bundled into the container image. The tc Runtime version required by the tc Runtime Instance will be checked and tc Server will attempt to use that version. If that version can not be used because it isn’t found locally or access isn’t available via the tc Runtime Repository the buildpack will fail.
Webapp
If the source
directory contains a .war
or is an exploded war (must contain WEB-INF
directory) then tc Server will attempt to create an instance, deploy the detected files, and include them in the container image. The instance created will use all tc Server defaults.
This is provided for convenience and works similarly to the Paketo CNB Tomcat buildpack
and is not recommended for general use.
Build
The tc Server buildpack will create the following content:
- The tc Server layer. This contains the tc Server and tc Runtime.
/workspace
. This is either the original instance directory or the generated instance with “original-contents” directory created as a copy of the originalapp dir
provided to thepack
command. If the tc Server buildpack creates an instance it will always be namedworkspace
and created at/workspace
Downloading the VMware tc Server Cloud Native Buildpack
To download the VMware tc Server Cloud Native Buildpack
from Tanzu Network use your username
and password
for Tanzu Network when prompted
docker login registry.pivotal.io
docker image pull registry.pivotal.io/tc-server-4x-core/vmware-tcserver-buildpack:4.1.4.RELEASE
Java Requirements
The tc Server CNB does not build a layer with a JDK/JRE. This must be provided by using additional buildpacks or a stack which will include the JDK/JRE. The examples in this document use the google.java.runtime
provided by the gcr.io/buildpacks/builder
builder and gcr.io/paketo-buildpacks/bellsoft-liberica
provided by the gcr.io/paketo-buildpacks/builder:base
builders.
Usage Examples
Create sample instance descriptor file
Create an instance descriptor file in ~/workspace/demo-instance
mkdir -p ~/workspace/demo-instance
cat << EOF > ~/workspace/demo-instance/instance-descriptor.yaml
instance:
name: demo-instance
applications:
- https://tomcat.apache.org/tomcat-9.0-doc/appdev/sample/sample.war=ROOT.war
EOF
Using Paketo Builder
The following example will create a docker image named demo-instance
based on the data found in ~/workspace/demo-instance
using the Paketo
pack build demo-instance --path ~/workspace/demo-instance/ --builder gcr.io/paketo-buildpacks/builder:base --buildpack gcr.io/paketo-buildpacks/bellsoft-liberica,vmware-tcserver-buildpack:4.1.4.RELEASE
Using Google Builder (alternate)
Alternatively the Google Builder could be used. The following example will create a docker image named demo-instance
based on the data found in ~/workspace/demo-instance
using the Google Builder
pack build demo-instance --path ~/workspace/demo-instance/ --buildpack google.java.runtime,registry.pivotal.io/tc-server-4x-core/vmware-tcserver-buildpack:4.1.4.RELEASE --env "GOOGLE_RUNTIME=java"
Run the image
docker run -p 8080:8080 -it demo-instance
You should see output similar to the following:
Instance Name: workspace
CATALINA_BASE: /workspace
CATALINA_HOME: /layers/vmware-tcserver-buildpack/tcserver/runtimes/tomcat-9.0.36.B.RELEASE
JAVA_HOME: Unable to find JAVA_HOME in /workspace/bin/setenv.sh
tc Runtime Version: 9.0.38.B.RELEASE
tc Server Version: 4.1.4.RELEASE
tc Server Installation Directory: /layers/vmware-tcserver-buildpack/tcserver/vmware-tcserver
NOTE: Picked up JDK_JAVA_OPTIONS: --add-opens=java.base/java.lang=ALL-UNNAMED --add-opens=java.base/java.io=ALL-UNNAMED --add-opens=java.rmi/sun.rmi.transport=ALL-UNNAMED
Sep 28, 2020 1:00:53 PM org.apache.catalina.startup.Catalina load
INFO: Server initialization in [901] milliseconds
Sep 28, 2020 1:00:53 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in [543] milliseconds
Note: The Unable to find JAVA_HOME in /workspace/bin/setenv.sh
is expected.
Use curl
to verify the instance is running and the port mapping is working correctly.
curl http://localhost:8080/
The output should be html text from the Sample "Hello, World" Application