3. Deploy an application from a project by using the Bluemix command line tool
Now that you have an introduction to the Bluemix CLI, it is time to use it to deploy a sample application to Bluemix. The application is written in Node.js and uses the Express web application framework.
- Download the application zip file from https://github.com/ibmecod/watson-parrot-nodejs/archive/master.zip. Unpack the zip file into a folder on your workstation.
- Start a command terminal and change the current directory to the folder of the application. Examine the files in the top level of the directory. Two important files are
package.jsonfile outlines the dependencies needed for the application and also specifies the command to start the application.
manifest.ymldefines the resource allocations and the application name in Bluemix and the host name for the deployed application.
- Before deploying, change the host for the application because each application must have a unique name in Bluemix. The host name must be a legal Internet host name, so you can use only letters (upper- or lowercase and the hyphen (-) character in the name.
- Open the
manifest.ymlfile in your favorite text editor and change the application name and add a matching host name for the deployment. One way to make the host name unique is to add your initials and the current date.
- Change random-route to false to disable adding extra text to the application name on deployment.
- After you update the file, save it. Use the application name to replace
<your-app-name>in the rest of the lab.
- Open the
- Log in to Bluemix and select the space where you want to deploy the application by using commands you learned in the previous section.
- Issue the
bx app pushcommand and follow the messages in the terminal as the application is deployed and started in Bluemix.
After a few minutes, the application will finish starting, and the status will be shown as running and show the URL for the application.
There are two ways to check on applications within a space. There is a high-level status list for all apps in the space from the
bx app listcommand. To get details on health and status of a specific app, use the
bx app show <your-app-name>command.
- Use the
bx app logscommand to view event messages stored in the buffer with the
--recentcommand or use the command without the option to follow events in real time. Turn on logging in the terminal with this command:
bx app logs <your-app-name>
- Open the URL that was shown for your application in a web browser. Enter a sentence into the text box and click the Send button and observe the display.
You will also see messages from both the Bluemix components and also from the express request logger. Any other output to stdout from the application is also displayed to the log stream. When you are done checking out the application, you can end the log stream by pressing Ctrl-C.