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
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

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
  • 50+ Top Angular Interview Questions and Answers

Trending

  • Building Custom Tools With Model Context Protocol
  • Cloud Security and Privacy: Best Practices to Mitigate the Risks
  • Debugging With Confidence in the Age of Observability-First Systems
  • The Cypress Edge: Next-Level Testing Strategies for React Developers
  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.0K 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
  • 50+ Top Angular Interview Questions and Answers

Partner Resources

×

Comments
Oops! Something Went Wrong

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

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

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 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!