Toggling the application environment
The SportsStore application will be deployed in a Docker container, which will be configured to set the application environment to production
. It is helpful to be able to switch to the production environment outside of the container in order to prepare the application for deployment. One way to do this is to set an environment variable named NODE_ENV
using the command prompt used to start Node.js, but that can be difficult to do consistently when there are multiple developers, each with their own command prompt or shell preferences, each of which deals with environment variables in its own way. A more reliable way is to rely on the dotenv
package, which reads environment variables from files.
Add a file named overrides.env
to the sportsstore
folder, with the content shown in Listing 21.7. This is a temporary file, just to confirm that the application behaves as it should before it is prepared for deployment.
Listing 21.7: The contents...