8 SportsStore: deployment

 

This chapter covers

  • Prerendering the application
  • Adding progressive features
  • Preparing for deployment
  • Containerizing and running the deployed application

In this chapter, I prepare the SportsStore application for deployment by adding progressive features that will allow it to work while offline and show you how to prepare and deploy the application into a Docker container, which can be used on most hosting platforms.

8.1 Preparing the example application

No preparation is required for this chapter, which continues using the SportsStore project from chapter 6. To start the RESTful web service, open a command prompt and run the following command in the SportsStore folder:

npm run json

Open a second command prompt and run the following command in the SportsStore folder to start the development tools and HTTP server:

ng serve --open
Tip

You can download the example project for this chapter—and for all the other chapters in this book—from https://github.com/manningbooks/pro-angular-16. See chapter 1 for how to get help if you have problems running the examples.

8.2 Using pre-rendering

One problem with JavaScript applications is that browsers have to download some relatively large files. Not everyone has a fast and reliable network connection, and that can mean that the user is presented with an empty window while their browser gradually receives the JavaScript files that are required to start the application.

8.2.1 Installing the SSR packages

8.2.2 Creating the platform service

8.2.3 Changing the web service URL

8.2.4 Disabling elements

8.2.5 Prerendering the application

8.3 Adding progressive features

8.3.1 Installing the PWA Package

8.3.2 Caching the data URLs

8.3.3 Responding to connectivity changes

8.3.4 Testing the progressive features

8.4 Preparing the application for deployment

8.4.1 Creating the data file

8.4.2 Creating the server

8.4.3 Changing the web service URL in the repository class

8.5 Building and testing the application

8.6 Containerizing the SportsStore application

8.6.1 Installing Docker

8.6.2 Preparing the application

8.6.3 Creating the Docker container

8.6.4 Running the application

8.7 Summary