-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Description
We have 5 different environments local dev, testing environment, a deployed development environment, an acceptance environment and a production environment, each environment take it's own set of environment. We try to keep everything within it's own environment, so acceptance only talks with acceptance apps etc.
We use dotenv to load in our .env files, an important one is ofcourse our database URL's. We use .env as a fallback for variables that are okay to set in all environments.
let path;
switch (process.env.NODE_ENV) {
case "test":
path = ".env.test";
break;
case "production":
path = ".env.production";
break;
case "acceptance":
path = ".env.acceptance";
break;
default:
path = ".env.development";
}
// set variables will not be overridden / updated by second config call
// load .env.{NODE_ENV}
dotenv.config({ path });
// load .env for defaults
dotenv.config();
The latest switch to a seperate .env file for prisma makes it harder to use this since we can't use the dotenv package to switch between env variables, we have to set our postgres url global during build to not break pipelines, same thing for deployements, we set a global system url instead of using the /prisma/.env file because it doesn't make any sense to maintain multiple environments files next to the 5 we already have.