Deploying your Angular app to IBM Cloud

Nishu Goel
The Startup
Published in
5 min readOct 24, 2019

--

I will be writing about how to deploy an angular application on to the public IBM cloud platform and be able to access the application.

So, to put it briefly here about what this blog post will include, we will create an angular application using the CLI, make our application deploy-ready, build the application, create and access the IBM Cloud, create delivery chains, API keys and finally put in the build and deploy script to be able to deploy the application on the cloud. Clumsy? Let’s break this down and handle it!

To start with, lets do what we are good at and have done a lot! Let us create an angular application from the CLI. I assume the readers have node, npm, angular CLI installed in their systems.

To create an Angular application, we use the command:

ng new <project-name>

As we know, we get a default template view when we compile the basic code generated on creating a new application.

After making whatever changes you want in the first go, the next step is to make your application deploy-ready! To do that, we create a file known as manifest.yml

This file needs the information for the cloud to understand the application structure for deployment purposes.

manifest.yml file to deploy an application

Any other parameters can be included too in here as per the requirement. Create a git repository because you’ll deploy the app through the repository.

https://github.com/NishuGoel/ng-ibm-cloud-deploy

Let us set up the IBM Cloud account now!

  • Hop to cloud.ibm.com and choose to create an IBM Cloud account if you do not already own one. Since my email is already associated with an IBM id, I will be using a different email ID for demo purposes.

Once you are done, confirm the account from your email and log in to your account.

Proceed to the hamburger menu and choose DevOps from there which takes you to create your toolchain.

Create the toolchain and give it a name. When you toolchain is ready, click on add a tool, and select Delivery Pipeline.

Give a pipeline name, and create integration. You will a warning related to service requirements, to do that, add the service.

After this add another tool, Github to be able to integrate your repo with the cloud. Authorize your github account with the IBM cloud.

Choose Existing repository and give the repo URL:

And create integration. You can check the track deployment of code changes option if wish to do so. The pipline should look like this now:

Go to the delivery pipeline now and Add a Stage:

The first stage will be a build stage so rename it to Build Stage and choose the branch and trigger stage as per your requirement. let us say on every commit that is push or manually.

Now, under the jobs section, add a job, i.e., Build job.

Choose the builder type as npm and the script as follows:

The script will install the node version you suggested your application will need, installs the dependencies, and completes a build for our application.

Replace the node version with the version of your node. Add the build archive directory as ‘dist/app-name’. In our case,
‘dist/angular-cloud-deployment’.

NOTE: At this point, do make sure that the dist folder is pushed too to the git repo and not ignore due to being placed in the gitignore file.

Time to add another stage now, i.e., the Deploy stage.
Rename the stage to Deploy and make sure that the input type is set to Build artifacts and the stage as Build.

Under the Jobs section, add the Deploy job and set the deployer type as Cloud Foundry and the location as per your location and space. Choose the cloud foundry type as IBM Public Cloud. Next you’d need to create an API key and authenticate with that.

Once you have authenticated with the API key, change your deploy script as :

Change the host name as per your requirement here and finally click save.

Trigger the build stage and once it is completed, it starts the deploy stage. If any of the stage fails, it will show up in red and you can check the logs from there.

Once both the stages are completed, you can run your application on the URL by click on the Visit App URL option and you are good to go!

There is a variety of issues that you can run into in the process. You can put them in the comment section, if you face any!

Thank you for reading the blog post. :)

--

--

Nishu Goel
The Startup

Engineering stuff @epilotGmbH; Web Google Developer Expert; Microsoft MVP;