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:
Once loaded, you'll be presented with an embedded web terminal that has the ibmcloud CLI
and other tools available.
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
Go into the directory of the cloned repository with this command:
cd node-hello-world
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
You should see output like the example below:
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>
and then
ibmcloud account space-create dev_space -o <your-ibm-cloud-email-address>
and re-run the command to fix errors
ibmcloud target --cf
Finally to deploy the application, we do a simple cf push as such:
ibmcloud cf push
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
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
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)
So you should be able to deploy a Java project onto a cloud Foundry app with the following setting:
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: