Deploy the App

Page last updated:

Page last updated:

In this step you will deploy the app to Swisscom Application Cloud.

Before you can push it, you need to compile and build the app using Gradle. To do so, run

$ gradle build

...

:compileJava
:processResources UP-TO-DATE
:classes
:jar
:assemble
:compileTestJava UP-TO-DATE
:processTestResources UP-TO-DATE
:testClasses UP-TO-DATE
:test UP-TO-DATE
:check UP-TO-DATE
:build

BUILD SUCCESSFUL

Total time: 6.78 secs

Gradle will build a Java archive (JAR) file of your app. It is located under build/libs/cf-sample-app-java-1.0.0.jar. The Java archive contains all dependencies needed by your app.

Replace “my-random-hostname” with your own hostname and “scapp.io” with an available shared domain (cf domains or “Domains” in the portal under your organization) or your own domain. This is the URL your app will be reached at and therefore has to be unique in this Application Cloud.

Now push your app to the cloud by executing the following command:

$ cf push my-java-app -p build/libs/cf-sample-app-java-1.0.0.jar -n my-random-hostname -d mydomain.com
Creating app my-java-app in org MyOrg / space MySpace as user@mydomain.com...
OK

Creating route my-random-hostname.mydomain.com...
OK

Binding my-random-hostname.mydomain.com to my-java-app...
OK

Uploading my-java-app...
Uploading app files from: ...
Uploading 7M, 1733 files
Done uploading
OK

...

requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: my-random-hostname.mydomain.com
last uploaded: Sun May 29 15:22:58 UTC 2016
stack: unknown
buildpack: java_buildpack

The -p build/libs/cf-sample-app-java-1.0.0.jar tells Cloud Foundry where to find the compiled application to push to the cloud.

The application is now deployed. Ensure that the app is running:

$ cf app my-java-app
Showing health and status for app my-java-app in org MyOrg / space MySpace as user@mydomain.com...
OK

requested state: started
instances: 1/1
usage: 1G x 1 instances
urls: my-random-hostname.mydomain.com
last uploaded: Sun May 29 15:22:58 UTC 2016
stack: cflinuxfs2
buildpack: java_buildpack

     state     since                    cpu    memory       disk          details
#0   running   2016-05-29 03:26:08 PM   0.1%   326M of 1G   132.2M of 1G

Now visit the app at the URL. You can find the URL in the urls property of the statement above.

I have deployed my App
View the source for this page in GitHub