Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

2
  • 1
    There's the quite reasonable idea from "The 12 Factor App" that configuration should be provided by the "environment". Somehow this led to dotenv being created as an awful config file format. At least, the dotenv JS module points out that your shouldn't commit dotenv files and shouldn't have dev/prod dotenv files. Instead, have a local file that makes sense on your system, and a file on your prod system (maybe created during your deployment process). In your case I'd also configure a logging target, not a name like "dev". Commented Nov 11, 2023 at 8:41
  • 1
    If you're using docker then I would avoid .env files and put environment-specific configuration inside a more suitable format such as YAML or JSON instead. docker run or docker-compose can simply pass the name of the environment when creating a container. e.g. docker run -e ENVIRONMENT='development' -- you could name the yaml/json files based on this too - e.g. development.yaml, test.yaml, staging.yaml, production.yaml, etc. Commented Nov 12, 2023 at 9:52