Setting many environment variables is time-consuming. We can simplify this using configuration files, which we will explore further at the end of this chapter. However, configuration files can't be used in cases where the crates or dependencies use environment variables.
To make this process simple, we can use the dotenv crate. This is used to set environment variables from a file. This practice appeared as part of The Twelve-Factor App methodology (https://12factor.net/).
The Twelve-Factor App approach is a methodology for building Software as a Service (SaaS) applications to fulfill the following three objectives:
- Configurations in declarative formats
- Maximum portability with operating systems and clouds
- Continuous deployment and scaling
This methodology encourages you to use environment variables to configure the application. The Twelve-Factor App approach doesn't require disk space for configuration and it is extremely portable, meaning that all operating systems support the environment variables.