You may have noticed the new Apps widget on the IBM Cloud dashboard—but is your widget sadly underpopulated?
Are you interested in knowing more about apps? Let's explain more as we create a cloud-native Node.js app from scratch.
Apps are a logical way to group all the cloud resources that make up a deployed instance. Apps can include source code (either downloaded or linked from a git repo), services (and corresponding credentials), deployments (Cloud Foundry, Kubernetes, or Virtual Server), and DevOps toolchains (including continuous delivery pipelines and service/tool integrations used to continuously deliver code).
Creating an app
To understand a bit more about apps, let's create one now. Click Create an app from the App widget in the IBM Cloud dashboard.
On the Create App screen, fill in App name and Resource group. Tags are optional. Now we are presented with a big decision—Bring your own code (BYOC) or Create a new app. We will be going through the BYOC flow next time, so click Create new app, which will generate a simple application structure and all of the necessary support/deployment files.
After selecting Create a new app, a few different options are enabled. For this example, select Node.js as the Platform. We'll skip the OpenAPI document for now, but know that you can add your own swagger definition here and IBM will generate the API scaffolding in our starter code for you. Click Create and, in a few moments, we will be on the App details screen.
Add a service
With the app itself is created, go ahead and add a database before deploying. From the App details screen, click Create new under the Services section. In the pop-up modal, you can choose from a variety of services: Web and Application, Databases, Analytics, Developer Tools, Security, AI, and more.
For our case, select Databases, click Next, and choose Cloudant. Once you fill in all the details for Cloudant, go ahead and click Create. The database will be provisioned in the background, and you'll be able to link directly to the database instance or view database credentials when complete.
Setting up continuous delivery
Now that the app has been created and the database has been bound, let's set up automated deployment using continuous delivery. In the App details screen again, click Configure continuous delivery in the Deploy your app section.
Here, you are presented with several deployment targets. For simplicity's sake, select the second option—Deploy to Cloud Foundry. Leave all the options as defaulted, but specify a Region, Org, and Space to deploy into.
With your deployment target set, click Next and configure the toolchain that will deploy this application. A toolchain is a set of tool integrations that support development, deployment, and operations tasks. This will make more sense once you see the toolchain we are about to create. Rename the toolchain as you see fit and specify a valid Region and Resource group for the toolchain. Normally, the toolchain is created in the same Region and Resource group as the app itself (see previous step), but feel free to put it somewhere else. The final step is to click Create to kick off the deployment.
As part of this initial toolchain creation, a pipeline was created and a build kicked off (more on this later). Click View toolchain and see the set of tools added—a Gitlab repo for code and issue tracking (pre-populated with a simple app in the language you chose earlier), the Orion web IDE for editing files online, and a delivery pipeline.
A pipeline is a sequence of stages that retrieve input and run jobs, such as builds, tests, and deployments. Click the Delivery Pipeline card to see the pipeline stages. As mentioned earlier, this pipeline run was kicked off with the initial create and can be triggered again either manually or by commits to the git repository.
Depending on how long you waited to get to view this page, the pipeline is either still running or already completed, ideally with all stages showing STAGE PASSED.
Looking at the code
While the deploy is (possibly) still running, take a look at the code that was just deployed. On the Delivery Pipeline page, click the browser’s back button so that you’re back on the Toolchain page, and then click on the Eclipse Orion Web IDE link. The Orion Web IDE we configured as part of the DevOps toolchain will be launched, showing the contents of your application’s git repository. You’ll find a basic application backbone that is easily extensible, plus deployment assets for both Cloud Foundry and Kubernetes environments. All of this code can be modified in any way you choose. In just a few minutes, you have created a cloud-native application, deployed it, and have it running on IBM Cloud for the world to see.
Verify the deployment
As a final step, assuming the pipeline has completed, let’s verify that the app is running and publicly accessible. Find the Deploy Stage in the Delivery Pipeline page. Click the View logs and history link and scroll to the bottom. Near the very end of the log, you will see routes: and your app URL. Cut and paste this endpoint into a new browser window and you will be presented with a congratulations page.
Piece of cake, right? We've examined the flow to create a simple app, but there's so much more you can do. Starter kits on IBM Cloud can help you rapidly generate frontend or backend applications, mobile apps, apps that use specific services (e.g., Watson), frameworks or patterns, low-code apps, and much more. Check out all of the starter kits to rapidly onboard your solutions to IBM Cloud, and don't miss our next post, where we'll examine the flow to bring your existing apps onto IBM Cloud.