DEV Community

Mrinalini Sugosh (Mrina) for IBM Developer

Posted on

Deploy a containerized app to IBM Cloud Foundry

Welcome to back to THINK Days!

In this hands-on tutorial, you will deploy a "Hello world" Node.js application to IBM Cloud using Cloud Foundry. Things you will be able to learn after completing this tutorial:

  • Run an application using Cloud Foundry on IBM Cloud
  • Launch the IBM Cloud Shell on https://www.cloud.ibm.com
  • Discover IBM Cloud CLI to deploy applications to Cloud Foundry

What is Cloud Foundry?

Cloud Foundry is provided as a PaaS(Platform as a Service) that enables developers to build, deploy, test, and scale applications without having to manually configure and manage servers.

Pre-requisites:

An IBM Cloud account – (sign up for a free account)
A basic, foundational knowledge of NodeJS

Let's get started!

Launch the IBM Cloud Shell

To start this tutorial, we'll be using the IBM Cloud Shell, which is available by clicking on the terminal icon on the top right:
image

Once loaded, you'll be presented with an embedded web terminal that has the ibmcloud CLI and other tools available.

image

Clone the NodeJS Starter App from IBM Repo

After setting up our CLI, the second thing we'll do is clone the code repository that has the source code for the Cloud Essentials app we want to deploy in our IBM Cloud Shell. Copy the following command into the terminal we opened up previously:

git clone https://github.com/IBM/node-hello-world
Enter fullscreen mode Exit fullscreen mode

Go into the directory of the cloned repository with this command:

cd node-hello-world
Enter fullscreen mode Exit fullscreen mode

image

Deploy the app to IBM Cloud Foundry

Next, to deploy the application with Cloud Foundry we first we need to target a Cloud Foundry API endpoint. To do this, run the following interactive command.

ibmcloud target --cf
Enter fullscreen mode Exit fullscreen mode

You should see output like the example below:

image

NOTE:

If you run into a No organizations found or No space targeted error please create a new Cloud Foundry organization and space by running the following commands:

ibmcloud account org-create <your-ibm-cloud-email-address>
Enter fullscreen mode Exit fullscreen mode

and then

ibmcloud account space-create dev_space -o <your-ibm-cloud-email-address>
Enter fullscreen mode Exit fullscreen mode

and re-run the command to fix errors

ibmcloud target --cf
Enter fullscreen mode Exit fullscreen mode

Finally to deploy the application, we do a simple cf push as such:

ibmcloud cf push
Enter fullscreen mode Exit fullscreen mode

Access the deployed app

Navigate to the URL that is show in the routes value, for example:

https://node-hello-world-example-surprised-kudu-ec.mybluemix.net
Enter fullscreen mode Exit fullscreen mode

If all goes well - you should see Hello World at the top-left corner of your screen.

Deleting the app and stopping service

Now while we love to explore no one wants to get charged for the apps in Cloud Foundry. So to stop or delete the service we can either go to our resource list and delete it or we can use the CLI to delete the deployment as such:

ibmcloud cf delete node-hello-world-example -f -r
Enter fullscreen mode Exit fullscreen mode

Oila! You have successfully deployed a NodeJS app onto IBM Cloud Foundry using the IBM Cloud Shell.

Thank you for following along this THINK Day's Tutorial and be sure to look out for my next post, where I will continue sharing my Journey with IBM Cloud Services!!!

==== Follow me on Social Media(@mrinasugosh) ====
Dev.to: @mrinasugosh
Github: @mrinasugosh
Twitter: @mrinasugosh
LinkedIn: @mrinasugosh

Top comments (2)

Collapse
 
mrinasugosh profile image
Mrinalini Sugosh (Mrina) • Edited

So you should be able to deploy a Java project onto a cloud Foundry app with the following setting:

Collapse
 
mrinasugosh profile image
Mrinalini Sugosh (Mrina)

As for costs, the lite instance is free for one instance but if you need to scale the project there is an opportunity for you to Estimate Cost when you provision an instance of Cloud Foundry: