|
1 |
| -# How to Run and Deploy the Node MySQL Upload App # |
| 1 | +# Overview of the App # |
| 2 | + |
| 3 | +This is a Node.js app that uses the following cloud services: |
| 4 | + |
| 5 | +- MySQL Database |
| 6 | + |
| 7 | +This app demonstrates how to connect to a MySQL database on IBM BlueMix from a Node.js app. |
| 8 | +Simply upload a line-separated file of text (e.g. tweets), and it will add each line to MySQL. |
| 9 | + |
| 10 | +Give it a try! Click the button below to fork into IBM DevOps Services and deploy your own copy of this application on Bluemix. |
| 11 | + |
| 12 | +[](https://hub.jazz.net/code/cfui/bluemix/deploy.html?Repository=https://github.com/ibmjstart/bluemix-node-mysql-uploader.git) |
| 13 | + |
| 14 | +Enjoy! (note, it may take minute or so for the app to start) |
| 15 | + |
| 16 | +___ |
| 17 | + |
| 18 | +### [Alternative] Deploying the App Via the Command-Line ### |
2 | 19 |
|
3 |
| -## Overview of the app ## |
4 |
| - |
5 |
| -This is a NodeJS app that uses the following cloud services: |
6 |
| - |
7 |
| -- MySQL Database |
8 |
| - |
9 |
| -This app demonstrates how to connect to a MySQL database on codename: BlueMix from a NodeJS app. |
10 |
| -Simply upload a line-separated file of text (e.g. tweets), and it will add each line to MySQL. |
11 |
| - |
12 |
| -## Deploying the App and Binding the MySQL Service ## |
13 |
| -Multiple methods exist for interacting with the BlueMix platform. Outlined below are two of those methods: |
14 |
| - |
15 |
| -1. [Command-Line](#method-command-line) |
16 |
| -2. [IBM JazzHub](#method-ibm-jazzhub) |
17 |
| - |
18 |
| -### Method: Command-Line ### |
19 | 20 | #### Prerequisites ####
|
20 | 21 |
|
21 | 22 | Before we begin, we first need to install the [**cf**](https://github.com/cloudfoundry/cli/releases) command line tool that will be used to upload and manage your application. If you've previously installed an older version of the cf tool, make sure you are now using v6 of cf by passing it the -v flag:
|
22 | 23 |
|
23 | 24 | cf -v
|
24 | 25 |
|
25 | 26 | #### Steps ####
|
26 |
| -In the terminal, go into the directory named **app**, and follow these steps. |
| 27 | +In the terminal, go into the root directory, and follow these steps. |
27 | 28 |
|
28 | 29 | 1. Login to Bluemix.
|
29 | 30 |
|
30 | 31 | | *usage:* | `$ cf login [-a API_URL] [-o ORG] [-s SPACE]`|
|
31 | 32 | |------------|----------------------------------------------|
|
32 | 33 | | *example:* | `$ cf login -a https://api.ng.bluemix.net` |
|
33 | 34 |
|
34 |
| -2. Create an instance of the mySQL service, giving it a unique name in the last arguement. |
| 35 | +2. Create an instance of the mySQL service, giving it the name "mysql-database" in the last arguement. Note, if a different name is desired, then the manifest.yml file needs to be changed accordingly. |
35 | 36 |
|
36 | 37 | | *usage:* | `$ cf create-service SERVICE PLAN SERVICE_INSTANCE`|
|
37 | 38 | |------------|----------------------------------------------------|
|
38 |
| - | *example:* | `$ cf create-service mysql 100 mysql_NMU` | |
| 39 | + | *example:* | `$ cf create-service mysql 100 mysql-database` | |
39 | 40 |
|
40 |
| -3. **From the directory that houses the _app.js_ file** (not from the root directory that contains this *README.md* file), push the app with the --no-start option so we can bind our required service before starting. Pass the -c flag to specify the start command that should be used by CloudFoundry to run your app. Be sure to give your app a unique app name to be used for its hostname; for instance the example below would result in http://myupload-<username>.ng.bluemix.net. |
| 41 | +3. From the root directory that contains this *README.md* file, push the app like below. Be sure to give your app a unique APP_NAME to be used for its hostname. For instance the example below would result in http://myupload-<username>.ng.bluemix.net. |
41 | 42 |
|
42 |
| - | *usage:* | `$ cf push APP [--no-manifest] [--no-start] [-c COMMAND]` | |
43 |
| - |------------|--------------------------------------------------------------------------| |
44 |
| - | *example:* | `$ cf push myupload-<username> --no-manifest --no-start -c "node app.js"` | |
45 |
| - |
46 |
| -4. Bind the MySQL service instance to the new app |
47 |
| - |
48 |
| - | *usage:* | `$ cf bind-service APP SERVICE_INSTANCE`| |
49 |
| - |------------|-----------------------------------------| |
50 |
| - | *example:* | `$ cf bind-service myupload-<username> mysql_NMU` | |
51 |
| - |
52 |
| -5. Start the app |
53 |
| - |
54 |
| - | *usage:* | `$ cf start APP` | |
| 43 | + | *usage:* | `$ cf push APP_NAME` | |
55 | 44 | |------------|----------------------------------|
|
56 |
| - | *example:* | `$ cf start myupload-<username>` | |
57 |
| - |
58 |
| - |
59 |
| -### Method: IBM JazzHub ### |
60 |
| -1. Browse to the JazzHub project repository located [here](https://hub.jazz.net/project/jstart/MySQL%20Upload%20App%20(Node)/overview). Click on **Edit Code** for the project. |
61 |
| -2. Click on "Fork". This will provide you with a personal copy of the code within your JazzHub project space. |
62 |
| - |
63 |
| -  |
64 |
| - |
65 |
| -3. Located in the **app** directory of the project, rename **manifest.yml.v5** to **manifest.yml** |
66 |
| - |
67 |
| -  |
68 |
| - |
69 |
| -4. Next, click on "Deploy". This will use information within the **manifest.yml** to deploy the sample application directly into the codename: BlueMix platform. |
70 |
| - |
71 |
| -  |
72 |
| - |
73 |
| - You may continue to deploy changes to your BlueMix application directly from JazzHub using the "Deploy" and "Deploy As" buttons. |
74 |
| - |
75 |
| -5. Next, click on the Root Project Name and scroll to the **Manual Deployment Information** section. |
76 |
| - |
77 |
| -  |
78 |
| - |
79 |
| - You can check the status of the app using this section. If a green filled circle is visible, you may click the Application Name shown within the section and interact with the running application. However, if a red filled circle is displayed, you may click **Manage** and directly interact with the BlueMix User interface for further investigation and debugging. |
| 45 | + | *example:* | `$ cf push myupload-<username>` | |
80 | 46 |
|
| 47 | +Congratulations, the app should be running on Bluemix. |
| 48 | + |
| 49 | +___ |
81 | 50 |
|
82 |
| -## License ## |
| 51 | +### License ### |
83 | 52 | Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
84 | 53 |
|
85 | 54 | http://www.apache.org/licenses/LICENSE-2.0
|
|
0 commit comments