How do you deal with dotenv files on production servers?

Obviously .env the file is not meant to be published to version control. Suppose I have this file with my SECRET_KEY=some-random-chars.

This I’m doing this to load all the env vars in the file.

func init() {
	err := godotenv.Load()
	if err != nil {
		log.Fatalf("Error loading .env file")
	}
}

Then using os.Getenv("SECRET_KEY") whenever needed.

This would work fine on local setup where I have the .env file. But I am afraid what will happen if I make a docker image and try to run it?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.