Vapor how to control environment variables for different environments

I'm pretty knew to Vapor (and server-side development as a whole) and was curious about the best practices / options there are for utilizing environment variables in testing?

Currently I use a .env file which allows me to use Environment.get("My_Key"), as well as a docker-compose file to dynamically load them using environment: My_Key: ${value}.

From my understanding this by default loads from the .env file. How can I have it load from different files for different environments such as .env.dev or .env.test? Or is there another (better) practice for handling secrets?

For more context these secrets are for Azure hosted services such as Azure Blob Containers and Azure Database for PostgreSQL.

I believe the documentation answers all your questions: Vapor: Basics → Environment

1 Like

Ah I missed the section talking about the dotenv naming :man_facepalming: Thank you for the quick response.