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 Shellon https://www.cloud.ibm.com
- Discover IBM Cloud CLI to deploy applications to 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.
An IBM Cloud account – (sign up for a free account)
A basic, foundational knowledge of NodeJS
Let's get started!
Once loaded, you'll be presented with an embedded web terminal that has the
ibmcloud CLI and other tools available.
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:
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:
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>
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
Navigate to the URL that is show in the routes value, for example:
If all goes well - you should see Hello World at the top-left corner of your screen.
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!!!