As part of the partnership between Pivotal and IBM we have created the WebSphere Application Server Liberty Buildpack, which enables Cloud Foundry users to easily deploy apps on Liberty profile.
The Liberty buildpack supports deploying (or pushing) the following types of resources to Liberty profile on Cloud Foundry:
- Web applications packaged as WAR files.
- Liberty server directories, e.g.
- Packaged servers, containing shared directories and additional resources.
Before you start
- Download ServletSample.jar, which is a sample application containing a servlet that displays a message when called. Follow the instructions on its download page.
- Set up a working Cloud Foundry environment on your local machine or on virtual machine.
- Run the following commands in your favorite command line tool:
cf target api.<Cloud Controller HostName>
This connects you to the Cloud Foundry instance installed on your machine.
This logs you into the target. You will be prompted to enter the e-mail address and password that you specified for your Cloud Foundry environment.
cf create-org <organization name>
It is necessary to create an organization, the topmost meta object level in the Cloud Foundry infrastructure, in order to create a structured environment. The structure is similar to a database; both the organization and the space represent tables. The organization contains references to each of the spaces and the applications are the entities in the spaces table.
cf create-space <Space name>
This command will create a space to which your applications will be deployed, this is the meta object the domain associates with.
cf switch-space <space name>
After creating a space, the Cloud Foundry command line interface doesn’t automatically switch into it, you have to manually switch into the space you want to deploy to.
- Change to your server directory, if you aren’t there already; e.g.
- Create a file called
manifest.ymland paste the following snippet into it.
--- applications: - name: test env: IBM_JVM_LICENSE: <
jvm license code> IBM_LIBERTY_LICENSE: <
liberty license code>
cf push --buildpack https://github.com/cloudfoundry/ibm-websphere-liberty-buildpack.git
Here you will be prompted to set multiple properties but, for simple applications like the ServletApp.war, the default settings are fine.These are the properties you can set:
- Name - The name you want to give the application e.g.: ServletApp
- Instance - The number of instances you would like to create.
- Memory Limit – The memory limit you want to set. Since this is a very simple application the default 256MB is more than enough.
- Subdomain and Domain – Together they build the URL (
<subdomain>.<domain>) with which the application can be accessed.
- Services - If you want to create and bind any services.
- Configuration file – This will create a file called
manifest.ymlcontaining all of the configuration choices you made.
That’s it! Once your configuration has been processed, you can instantly access the URL (from Step 4, above) and interact with your application. If you pushed the ServletApp.war, append
/ServletApp to the URL to access the application.