In this series, we are working through building an application to support the needs of DIY bands. We’ll start out solving some basic problems and move into more complex ground, eventually transforming the application into a platform that others can use and build upon.

🖥 To see the code for this step, here is commit/diff in the code repository. This will show you the changes from the last episode to this one.

Previously on Let’s build a band app!

In the previous episode, we got to know the Swagger explorer that comes for free with LoopBack. It is an interface that allows us to see and interact with our APIs. We are able to make requests through the UI and see how our API endpoints respond. Now that we have seen our API in action, let’s deploy it so that we can begin to interact with it over the web rather than just within our local development environment.

In this episode

In this episode, we will deploy our application to the cloud. A LoopBack app is simply a Node.js app. For our purposes, we will deploy our code to Bluemix, IBM’s PaaS (platform as a service), but we could deploy it wherever Node.js is supported. Wherever we decide to deploy our Node application, we need to make sure the tools were in place to keep our app running and able to handle any sort of load it may need to withstand. Fortunately, Bluemix handles all of that for us. And we can use their Cloud Foundry tools to configure and manage the deployment.

Create Node.js Cloud Foundry app:

In this step, we will to go into the Bluemix catalog and from the Cloud Foundry section we will choose to create a Node.js Runtime App:

Create the Node.js app

Choosing the SDK for Node.js takes us to a page where we can name our application as well as choose the Bluemix route to access our app:

Note: we could do this step through the command line, but choosing the name may result in a failure. By initializing the Cloud Foundry app through the Bluemix UI, we are able to get immediate feedback as to whether the name and the route we choose is available on the Bluemix platform.

Note: Take notice of the org and space you created this app in on Bluemix. It is likely you only have one of each, but it is not uncommon to have more than one of one or the other. Which org/space you are currently in is where the app will be created.

The next page presented to us after creating our Node.js app shows the app starting up. On this page, we will also see some instructions for using a sample app and getting started. We are going to skip that in favor of the following steps:

Prepare our app and local environment

We can now switch back to the terminal and our editor to get our local environment prepped and our application set up.

Create our manifest.yml file

Let’s go into the root of our LoopBack application and create a manifest.yml file and add the following information, changing “name” to the name we chose when creating the Cloud Foundry app.

It should look something like so:

name:Band-Appmemory:256M

Get Cloud Foundry

At this point, we are going to begin using the Cloud Foundry cli, so we’ll need to get that installed before going further.

The most common way of installing Cloud Foundry on a Mac is to use Homebrew:

At this point, we now have our application in the cloud. We can access it from any connected device and we can start to imagine our application being live in the real world. There are a few more steps before we can start showing our friends how awesome we are, but we are getting closer!

What’s Next?

If we go to our Band App on Bluemix, we will see the status output that is the default for a LoopBack app. And if we view the LoopBack Explorer for our API (/explorer), we should see the familiar Swagger interface. (Again, these links point to my deployed application. Your URL will be different.) From here we can interact with our API endpoints just like we did in the previous episode. If we connected our application to a persisted datasource, we could start adding data through the explorer. This is something we will do in the next episode!