DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • Development of Custom Web Applications Within SAP Business Technology Platform
  • Leveraging Salesforce Using a Client Written In Angular
  • Building an Angular Bot With AWS Lex
  • How to Effortlessly Host Your Angular Website on GitHub Pages

Trending

  • A Deep Dive into Tracing Agentic Workflows (Part 1)
  • Mocking Kafka for Local Spring Development
  • Why AI-Generated Code Breaks Your Testing Assumptions
  • Retesting Best Practices for Agile Teams: A Quick Guide to Bug Fix Verification
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Deploying an Angular 6 Application to Cloud Foundry

Deploying an Angular 6 Application to Cloud Foundry

We go over two interesting open source technologies, Angular and Cloud Foundry, and show you how to deploy a web app to the cloud.

By 
Mohammed Sulthan user avatar
Mohammed Sulthan
·
Oct. 30, 18 · Tutorial
Likes (7)
Comment
Save
Tweet
Share
47.4K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

In this article, I'll go through the steps to deploy an Angular 6 application on Cloud Foundry. This article is for the developers who have knowledge of both Angular and Cloud Foundry.

Cloud Foundry

Cloud Foundry is an open-source Platform as a Service (PaaS) that provides you with a choice of clouds, developer frameworks, and application services. Cloud Foundry is designed to be configured, deployed, managed, scaled, and upgraded on any cloud IaaS provider.

Refer: https://docs.cloudfoundry.org/

Angular

Angular is a JavaScript UI framework. Angular code is mostly written in TypeScript. Angular helps us to combine UI templates, dependency injection, and end-to-end testing. Angular helps developers to develop single page web applications (SPAs) for both desktop and mobile.

Refer: https://angular.io/docs

Cloud Foundry CLI

Cloud Foundry uses the Cloud Foundry Command Line Interface (CF CLI) to deploy applications to the cloud. We will mention the application deployment parameters in our manifest.yml file. There are a few built-in build packs available in Cloud Foundry that we can use to deploy our applications. Build packs are nothing but the framework and the runtime support for the applications which we deploy.

Refer: https://docs.cloudfoundry.org/cf-cli/index.html

Deploying Angular Applications in Cloud Foundry

Before deploying Angular applications, we need to generate deployable files using the Angular CLI. For this, we need to run a command ng build --prod. --prod instructs the Angular CLI to create a production version of the deployable files.

Image title

After running the above commands, Angular CLI will create a ‘dist’ folder inside the project folder. This ‘dist’ will contain all the deployable files. Angular transpiles all the TypeScript code to JavaScript in order to create these files.

Image title

These files will only contain HTML, JavaScript, and CSS files. So, basically, these files are static files. i.e., these are all UI files and don’t need any backend code. So, we can use ‘staticfile_buildpack’ while deploying these to cloud.

We need to create the manifest.yml file to deploy to Cloud Foundry. And as we are using staticfile_buildpack to deploy our code, we also need a Staticfile file to configure Nginx (Cloud Foundry uses the Nginx web server to deploy static websites).

Image title

The manifest.yml file will contain the parameters required to deploy the application to Cloud Foundry. For example, memory to be allocated, build pack to be used, etc.

Image title

In this demo application, Staticfile is an empty text file. If we want, we can provide some configuration settings for the Nginx server inside Staticfile.

Refer: https://docs.cloudfoundry.org/buildpacks/staticfile/index.html

After this, move into the ‘dist’ folder and login to Cloud Foundry using the details provided by your cloud service providers. Now, run the ‘CF push’ command. In this tutorial, I am using Pivotal Cloud foundry as my Cloud Service Provider.

Image title

This will deploy your Angular application to Cloud Foundry.

Image title

While deploying, the Cloud Foundry CLI will provide the route to access our application. If not, use the CF apps command to get the route.

Image title

We can access the URL in our browser to access our web application.

Image title


If you enjoyed this article and want to learn more about Angular, check out our compendium of tutorials and articles from JS to 8.

Cloud Foundry Cloud mobile app AngularJS Command-line interface

Opinions expressed by DZone contributors are their own.

Related

  • Development of Custom Web Applications Within SAP Business Technology Platform
  • Leveraging Salesforce Using a Client Written In Angular
  • Building an Angular Bot With AWS Lex
  • How to Effortlessly Host Your Angular Website on GitHub Pages

Partner Resources

×

Comments

The likes didn't load as expected. Please refresh the page and try again.

  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook