Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Modern web applications on OpenShift: Part 3 -- Openshift as a development environment

<p>&nbsp;</p> <quillbot-extension-portal></quillbot-extension-portal>

January 17, 2019
Lucas Holmquist
Related topics:
KubernetesNode.js
Related products:
Red Hat OpenShift Container Platform

    Welcome back to the final part of this multipart series about deploying modern web applications on Red Hat OpenShift. In the first post, we took a look at how to deploy a modern web application using the fewest commands.

    In the second part, we took a deeper look into how the new source-to-image (S2I) web app builder works and how to use it as part of a chained build.

    This third and final part will take a look at how you can run your app's "development workflow" on OpenShift.

    Development workflow

    As mentioned in the first post, a common development workflow for modern web applications is to run a "development server" that watches your local files for changes. When a change occurs, the application's build is run and the browser is refreshed with your updated app.

    Most of the modern frameworks have this "development server" built into their respective CLI tools.

    A local example

    Let's first start with running our application locally, so we can see how this workflow is supposed to work. We are going to continue with the React example that we saw in the previous articles. Even though we are using React as an example here, the workflow concepts are very similar for all the other modern frameworks.

    For this React example, to start the "development server" we run the following:

    $ npm run start
    

    We should see something like this in our terminal:

    Starting the development server

    And our application should open in our default browser:


    Application running in a browser

    Now, if we make a change to a file, we should see the application running in the browser refresh with the latest changes.

    As I said before, this is a common workflow for local development, but how can we get this workflow onto OpenShift?

    Development server on OpenShift

    In the previous article, we took a look at the run phase of the S2I image. We saw that the default way of serving our web app is with the serve module.

    However, if we look closely at that run script, we can see that we can specify an environment variable, $NPM_RUN, which gives us the ability to execute a custom command.

    For example, using the nodeshift module, the command to deploy our application might look something like this:

    $ npx nodeshift --deploy.env NPM_RUN="yarn start" --dockerImage=nodeshift/ubi8-s2i-web-app
    

    Note: The above example has been shortened to show an idea.

    Here we are adding the NPM_RUN environment variable to our deployment. This will tell our run phase to run yarn start, which starts the React development server inside our OpenShift pod.

    If you took a look at the log of the running pod, you might see something like this running:

    Log of the running pod

    Of course, this doesn't really matter unless we can sync our local code with the code that is being watched on our remote cluster.

    Remote and local sync

    Luckily, we can use nodeshift again to help us out. We can use the watch command.

    After we run the command to deploy our application's development server, we can then run this command:

    $ npx nodeshift watch
    

    This will connect to the running pod we just created and sync our local files with our remote cluster, while also watching our local system for changes.

    So if you were to update the src/App.js file, that change will be detected and copied to the remote cluster, and the running development server will then refresh the browser.

    For completeness, here are the full commands:

    $ npx nodeshift --strictSSL=false --dockerImage=nodeshift/ubi8-s2i-web-app --build.env YARN_ENABLED=true --expose --deploy.env NPM_RUN="yarn start" --deploy.port 3000
    
    $ npx nodeshift watch --strictSSL=false
    

    The watch command is an abstraction on top of the oc rsync command. To learn more about how that works, check it out here.

    Even though the example we saw was using React, this technique also works with other frameworks. You just need to change the NPM_RUN environment variable.

    Conclusion

    In this 3 part series, we saw how to deploy modern web applications to OpenShift in a few ways.

    In part one, we saw how to get started quickly with the new Web App S2I Image.

    Part 2 dove a little deeper into how the S2I image worked and how to use chained builds.

    This last part was a brief overview of how you can run a development server on OpenShift, and the next talks about OpenShift Pipelines and how this tool can be used as an alternative to a chained build.

    Additional resources

    • Deploying to OpenShift: a guide for impatient developers (free ebook)
    • Building Container-Native Node.js Applications with Red Hat OpenShift Application Runtimes and Istio
    • How to Debug Your Node.js Application on OpenShift with Chrome DevTools
    • Zero to Express on OpenShift in Three Commands
    • Announcing: Node.js General Availability in Red Hat OpenShift Application Runtimes
    • Monitoring Node.js Applications on OpenShift with Prometheus
    • Other articles on OpenShift and Kubernetes
    Last updated: January 12, 2024

    Recent Posts

    • Tekton joins the CNCF as an incubating project

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    • Introducing virtualization platform autopilot

    • Integrate zero trust workload identity manager with Red Hat OpenShift GitOps

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.