Developing IBM Cloud applications from a local workstation
This unit covers the following topics:
Node.js introduction
Building an application by using the Cloud Foundry and IBM Cloud command-line interface
Building an application by using the IBM Eclipse Tools for IBM Cloud
3.1 What you should be able to do
After completing this unit, you should be able to:
Describe the role of Node.js for server-side scripting
Describe how to create an IBM SDK for Node.js application that runs on IBM Cloud
Describe the features in IBM Cloud that help you to set up a cooperative workstation environment
Explain how to manage your IBM Cloud account with the Cloud Foundry CLI and IBM Cloud CLI
Describe how to setup and use the IBM Cloud plug-in for Eclipse
3.2 References
The following publications are useful for further research on the topic presented in this unit:
The Eclipse project:
Most recent cf installer from the Git project:
Deploying your app with the command line interface documentation:
Developing with Eclipse tools documentation:
 
3.3 Node.js
Figure 3-1 Node.js
Notes:
Node.js is an open-source language that runs on V8. V8 is an open source engine that was developed by Google for the Google Chrome browser.
Developers use JavaScript for client-side functionality often. Node.js is the server component in the same language.
Although developers can still use JavaScript for browser functionality in frameworks, such as angularJS, Dojo, and jQuery, they can now use Node.js in the same components of the architecture where they use Java, Perl, C++, Python, and Ruby.
Node.js is used in production by companies, such as Uber, Yahoo!, LinkedIn, GoDaddy, eBay, and PayPal. It is event-driven and uses asynchronous, non-blocking I/O.
3.4 Options to develop and deploy your IBM Cloud app
Figure 3-2 Options to develop and deploy your IBM Cloud app
Notes:
The following options are available to develop and deploy your IBM Cloud application:
Eclipse
Command-line interface (CLI):
 – IBM Cloud CLI: The IBM Cloud CLI (bx CLI) provides the CLI to manage applications, containers, infrastructure, services, and other resources on IBM Cloud. It also bundles cf CLI in its installation to manage Cloud Foundry resources on IBM Cloud.
 – Cloud Foundry CLI: The Cloud Foundry command-line interface (cf CLI) is a client tool from the Cloud Foundry community. You can use this tool to manage Cloud Foundry applications and services on IBM Cloud.
Continuous delivery using DevOps practices
3.5 Overview of bx and cf command-line interfaces
Figure 3-3 Overview of bx and cf command-line interfaces
Notes:
Cloud Foundry is an open-source platform as a service (PaaS). Cloud Foundry provides an open-source CLI that is available for multiple platforms.
You can use bx CLI or to log in to IBM Cloud and deploy an application to IBM Cloud, and to manage resources. Alternatively, you can use cf cli to deploy Cloud Foundry applications and manage Cloud Foundry resources on IBM Cloud.
 
3.6 Why use command-line tools?
Figure 3-4 Why use command-line tools?
Notes:
IBM Cloud integrates into the Eclipse IDE. However, you might still want to use command-line tools in the following scenarios:
You need a tool that is quick to install and has a minimal footprint on your development workstation.
You want to automate the management and deployment process with shell scripts, or you want to use different tools for different projects to provide some project-level separation.
3.7 Reviewing the documentation
Figure 3-5 Reviewing the documentation
Notes:
You can review the documentation for the command-line tool from Getting Started in Application Details.
To work with IBM Cloud by using the CLI, you can use bx CLI or cf CLI.
 
Note: bx CLI enables you to manage applications, containers, infrastructures, services and other resources in IBM Cloud. It also bundles cf CLI, to manage Cloud Foundry resources on IBM Cloud. cf CLI allows you to manage only Cloud Foundry resources on IBM Cloud.
How to download and use the command-line interface to manage IBM Cloud applications is described next.
3.8 Using the IBM Cloud CLI
The following sections show you how to use the IBM Cloud CLI.
3.8.1 Step 1: Install the IBM Cloud CLI
Figure 3-6 Step 1: Install the IBM Cloud CLI
Notes:
The IBM Cloud CLI provides the command line interface to manage all resources on IBM Cloud.
Download the most recent IBM Cloud Command-line Interface installer from https://console.bluemix.net/docs/cli/reference/bluemix_cli/get_started.html, which includes a list of downloadable installers for Mac OS X, Linux, and Windows. After you download and install the installer to your local workstation, open a command prompt on your system and run the command bx --version to check if the tool works successfully in your environment.
More information about this process is included in the exercises for this unit.
3.8.2 Step 2: Connect to your IBM Cloud account
Figure 3-7 Step 2: Connect to your IBM Cloud account
Notes:
Log in to IBM Cloud by using the bx CLI. When you login by using bx, you also must specify the account. After you specify the account, you can specify the resource group or Cloud Foundry organization.
If you are using a federated ID, use bx login –sso. A URL is supplied for you. Open this URL in a browser; then, log in and paste your one-time passcode into the CLI to authenticate.
3.8.3 Step 3: Connect to your Cloud Foundry organization
Figure 3-8 Step 3: Connect to your Cloud Foundry organization
Notes:
The use of the bx target command allows you to select the cloud foundry organization and space on which you work.
3.8.4 Step 4: Deploy your application to IBM Cloud
Figure 3-9 Step 4: Deploy your application to IBM Cloud
Notes:
The use of the bx app push command uploads, deploys, and starts the application in your IBM Cloud space.
3.8.5 Step 5: Test your IBM Cloud application
Figure 3-10 Step 5: Test your IBM Cloud application
Notes:
After the command-line utility finishes pushing your application, browse to the route name you wrote down in the previous step to test whether the application is running.
 
 
 
 
 
 
 
 
3.9 Using the cf CLI
The following sections show you how to use the Cloud Foundry Command Line Interface (CLI).
3.9.1 Step 1: Install the CLI
Figure 3-11 Step 1: Install the cf CLI
Notes:
The cf CLI can be used to manage Cloud Foundry applications and services on IBM Cloud. Download the most recent cf installer from the Git project, which includes a list of installers and binaries downloadable for most systems. Generally, download an installer because they are faster and easier to use than the raw binaries.
After you download and run the installer, open a command prompt on your system and run the command line tool by entering cf --version.
 
Note: IBM Cloud CLI bundles cf CLI. All cf commands can be used with IBM Cloud CLI by using the following syntax:
bx cf <cf_command>
 
3.9.2 Step 2: Connect to your IBM Cloud account
Figure 3-12 Step 2: Connect to your IBM Cloud account
Notes:
Log in to IBM Cloud by using the CLI. The login command requires the following parameters:
Cloud Foundry API endpoint
Username
Password
Organization name
Space name
You can use the command-line client with other Cloud Foundry regions by pointing to other API endpoints; for example, api.eu-gb.bluemix.net for UK region.
You can use the flags (-a, -u, and so on) to specify the parameters at the command line. If you do not specify one of the parameters, the command-line utility prompts you to enter it later. In the example that is shown in Figure 3-12, the password was not entered; therefore, the command-line utility prompts the user to enter the password.
If you use a federated ID, use cf login –sso. A URL is provided for you. Open this URL in a browser; then, login and copy your one-time passcode and paste it in the CLI to authenticate.
3.9.3 Step 3: Deploy your application to IBM Cloud
Figure 3-13 Step 3: Deploy your application to IBM Cloud
Notes:
The use of the push command uploads, deploys, and starts the application in your IBM Cloud space.
When you are ready to deploy your application to IBM Cloud complete the following steps:
1. Browse to your application directory (the directory where manifest.yml is stored).
2. Run the cf push command.
”Pushing your app” is the terminology that is used to indicate that you are going to deploy the latest changes of your app to IBM Cloud.
Remember that when you push your application, it overwrites the current contents of your application in your IBM Cloud account.
Write down the application route. You can test your application with this entry point.
Figure 3-13 shows the command-line utility accessing a manifest file. You can control various aspects of the deployment, such as the amount of memory an application receives and the route of the application, by specifying them as flags in the command. However, you can also store these settings in a manifest.yml file to make the command you need shorter to enter in later iterations of your application.
 
3.10 IBM Cloud and Eclipse
Figure 3-14 IBM Cloud and Eclipse
Notes:
Eclipse is a popular open-source integrated development environment (IDE) that provides development tools in a desktop application. For more information about Eclipse, see the following website:
IBM Eclipse tools for IBM Cloud is an open-source plugin for interacting with IBM Cloud to manage and deploy your applications and services from within the Eclipse interface.
3.11 Using IBM Eclipse tools for IBM Cloud
The next sections show you how to use IBM Eclipse tools for IBM Cloud.
3.11.1 Step 1: Review the documentation
Figure 3-15 Step 1: Review the documentation
Notes:
For more information about the documentation that is related to developing IBM Cloud Applications by using Eclipse tools, see the following website:
To start developing with the IBM Eclipse Tools for IBM Cloud plugin, the Java Development Kit, and Eclipse for Java EE Developers (any version after Neon) must be installed.
3.11.2 Step 2: Install the latest version of JDK and Eclipse
Figure 3-16 Step 2: Install the latest version of JDK and Eclipse
Notes:
As of time of this writing, Eclipse version Oxygen and JDK 8 were used. Any newer version will be also compatible.
3.11.3 Step 3: Install Eclipse tools for IBM Cloud
Figure 3-17 Step 3: Install Eclipse tools for IBM Cloud
Notes:
The simplest way to install the IBM Eclipse Tools for IBM Cloud is to drag the Install button from the documentation on top of your Eclipse toolbar, as shown in Figure 3-17.
You can also install IBM Eclipse Tools for IBM Cloud by completing the following steps:
1. Start Eclipse on your workstation and click Help  Eclipse Marketplace. Then, search for Bluemix.
2. Select IBM Eclipse Tools for Bluemix and then, click Install.
3. Some features are selected for you by default. Click Confirm.
4. Accept the license agreement and click Finish.
3.11.4 Step 4: Connect to your IBM Cloud account
Figure 3-18 Step 4: Connect to your IBM Cloud account
Notes:
After you successfully install the IBM Cloud tools for Eclipse plugin, you can add your IBM Cloud account as a remote server in Eclipse. Complete the following steps:
1. Open Java EE perspective in Eclipse.
2. Click the Servers tab.
3. Click the link that is shown in Figure 3-18 to create a server.
4. Click IBM Bluemix.
5. Click Next and enter your user IBM ID and password to log in to your IBM Cloud account. Click Next.
6. Choose the organization and space. Click Finish.
3.11.5 Step 5: Create a Node.js application project
Figure 3-19 Step 5: Create a Node.js application project
Notes:
You can deploy only projects for server runtime environments that IBM Cloud supports. For example, you must mark your Eclipse project as a Node.js application to deploy it for the IBM SDK for Node.js runtime. You “mark” your project by using Eclipse project facets.
To view or modify the facets for your project, complete the following steps:
1. Right-click the project and select Properties.
2. Select Project Facets.
3. Click Convert to faceted form.
4. Select Node.js Application.
After the Node.js facet is added to your application, it shows in Eclipse as an item that you can deploy to IBM Cloud.
To deploy an application to IBM Cloud, right-click the IBM Cloud server and click Add and Remove. Then, add the application to the server. Alternatively, you can drop the application to the server.
3.12 Unit summary
Figure 3-20 Unit summary
 
 
 
 
 
 
3.13 Checkpoint questions
Figure 3-21 Checkpoint questions
 
3.14 Checkpoint answers
Figure 3-22 Checkpoint answers
 
 
 
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.248.211