Red Hat OpenShift is a unified platform to build, modernize, and deploy applications at scale. Red Hat OpenShift offers a great developer experience in shipping your applications to the cloud.
In this series of articles, we are putting together a step-by-step guide that will enable you to be up and running with your applications on OpenShift. We expect you to have some familiarity with Angular and Red Hat OpenShift. Just in can case you need a quick recap, checkout Red Hat OpenShift, Developer Sandbox for Red Hat OpenShift and AngularJS Website.
Steps to deploy Angular on OpenShift
The Developer Sandbox for Red Hat OpenShift is a free OpenShift instance for you to experiment with OpenShift for your use cases. The development of dynamic and responsive web applications has evolved into a fundamental requirement. Node.js and Angular stand out as formidable technologies capable of crafting these applications with finesse. Our workflow involves the creation and deployment of applications directly from GitHub onto an OpenShift sandbox environment.
Follow these steps to start your sandbox instance and deploy your Angular app:
- Create a Developer Sandbox account.
- Once you log into your account, click Add in the left side menu.
- Select Import from Git.
- Specify your Git repo URL. For the sake of this tutorial, we use: https://github.com/redhat-developer-demos/Angular-openshift-example.git. But, you can choose any AngularJS repo.
- Add a Containerfile to your repo. The Containerfile helps developers specify the environment needed for running applications. In case you do not have a Containerfile on your project, you can add one to your repo by referring to: https://github.com/redhat-developer-demos/Angular-openshift-example/blob/main/Containerfile.
- OpenShift will detect the Containerfile from the Git repository. In case the Containerfile is in a subdirectory, you need to provide the path of the Containerfile. [NOTE: If the containerfile is not detected, click Import Edit Strategy. Select as Dockerfile, define the path as Containerfile.]
- Choose a Resource Type field. Choose either Deployment or Serverless Deployment (default option), depending on your preference.
- Under advanced options, select Target Port to define the port 8080 that will receive the container's traffic.
- Click on Create.
- You will now be directed to the Topology view, and the application will commence deployment. Please allow some time for the build and deployment process to complete. While it is in progress, you will have the opportunity to monitor the logs.
- Once it’s done deploying, you can click on the ↗ OpenURL icon to see the webpage of your Angular application running on OpenShift.
Add a continuous deployment pipeline
Continuous deployment (CD) is a strategy in software development where code changes to an application are released automatically into the production environment. It speeds up time to market by eliminating the lag between coding and customer value. OpenShift enables developers to configure this using a few simple UI-based steps.
Now, let’s begin adding CD to the application we just created:
- From the Topology view, select the application.
- Click on Actions dropdown.
- Select Edit <application name>.
- Check the Add pipeline checkbox. You can see the pipeline visualization if you’d like to understand the steps.
- Click save.
Trigger the CD pipeline
An application updated in the Git repository triggers a pipeline of applications.
- Create your application and add on the remote Git repository or copy the previous repository.
- The source files should be modified, committed, and pushed.
- Log in to the Developer Sandbox.
- Access your application in the topology view.
- Select the pipeline option from the left menu.
- Check out live build and deploy process.
- You can see your changes being deployed automatically.
In this tutorial, you learned how to deploy an Angular application on Red Hat OpenShift. OpenShift has powerful features that make it easy to manage and scale your Angular application in production.