Making the app production-ready
As our production infrastructure will run containers, we need to containerize our app. To do so, we’ll need to decide how to serve the frontend and backend, and how to build the container image.
Serving the frontend
So far in development, we’ve used npm run start
to run a server that serves the frontend code. This is called server-side rendering (SSR), and we could continue to do this in production. However, it is much easier to utilize client-side rendering (CSR), as this does not require a dedicated frontend server. CSR works by building a bundle of frontend files that can be served by any server (rather than a dedicated frontend server), and we’ll use the backend server.
To build the frontend bundle, we can use the npm run build
command. This command creates a single HTML file (frontend/build/index.html) and multiple static files (css
, js
, and media
) in the following structure:
tozo └── frontend...