What is dotenv?

What is this

What do you do when dealing with confidential information? I will summarize things like.

Summary

--Do not save confidential information in the code as it is --It is put together in .env, but when saving it in git, it is often set to .env.sample except for confidential information. --There are packages that handle .env in many languages

What is an env file?

There is confidential information in the application that you do not want to show to a third party, such as "DB information", "server information", and "external API linkage information". Confidential information stores information as an environment variable separately from the code.

There are multiple projects locally, and I want to handle different environment variables for each project. Also, I would like to put together an environment variable configuration file for new members.

Therefore, create a file that summarizes confidential information as a .env file and manage the information. If you put the .env file as it is on git, confidential information will be put on git, so you often add the .env file to .gitignore and put a sample file called .env.sample.

About environment variables

A simple summary of how to add / view / delete environment variables.

#Setting environment variables
$ export GERU="mew" #Put the value "mew" in the environment variable named GERU
#Checking environment variables
$ echo $GERU #View the contents of an environment variable named GERU
mew
#Check the set environment variables
$ printenv #Check all the set environment variables
...
GERU=mew
...
#Delete the set environment variable
$ unset GERU #Delete the set environment variable
$ echo $GERU #Since the setting has been deleted, it is not displayed even if it is output

-To set environment variables -To define or delete shell variables

About .env

Packages that handle environment variables in .env have been developed and used in various languages.

Ruby[dotenv]

Javascript[dotenv]

Python[python-dotenv]

Summary

--Do not save confidential information in the code as it is --It is put together in .env, but when saving it in git, it is often set to .env.sample except for confidential information. --There are packages that handle .env in many languages

References

―― What is an env file?

Recommended Posts

What is dotenv?
What is namespace
What is copy.copy ()
What is Django? .. ..
What is POSIX?
What is Linux
What is klass?
What is SALOME?
What is Linux?
What is python
What is hyperopt?
What is Linux
What is pyvenv
What is __call__
What is Linux
What is Python
What is a distribution?
What is Piotroski's F-Score?
What is Raspberry Pi?
[Python] What is Pipeline ...
What is Calmar Ratio?
What is a terminal?
[PyTorch Tutorial ①] What is PyTorch?
What is hyperparameter tuning?
What is a hacker?
What is JSON? .. [Note]
What is Linux for?
What is a pointer?
What is ensemble learning?
What is TCP / IP?
What is Python's __init__.py?
What is an iterator?
What is UNIT-V Linux?
[Python] What is virtualenv
What is machine learning?
What is Minisum or Minimax?
What is Linux? [Command list]
What is the activation function?
What is the Linux kernel?
What is an instance variable?
What is a decision tree?
What is a Context Switch?
What is Google Cloud Dataflow?
[DL] What is weight decay?
[Python] Python and security-① What is Python?
What is a super user?
Competitive programming is what (bonus)
[Python] * args ** What is kwrgs?
What is a system call
[Definition] What is a framework?
What is the interface for ...
What is Project Euler 3 Acceleration?
What is a callback function?
What is the Callback function?
What is a python map?
What is your "Tanimoto coefficient"?
Python Basic Course (1 What is Python)
What is Python? What is it used for?
[Python] What is a zip function?
[Python] What is a with statement?
What is labeling in financial forecasting?