-
Notifications
You must be signed in to change notification settings - Fork 170
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Docker COPY ignoring .env file #384
Comments
Hey @ArgentEnergy, that's normal. The DotEnv file doesn't need to be copied into any of the containers. Docker looks for and loads a DotEnv file when it brings up the containers. Any variables in the file will be loaded as environment variables inside the containers. The configuration options you see in base.py that reference an environment variable will pull those values. So the values are set inside the DotEnv file but the file doesn't need to be in the container. Docker loads the DotEnv file, sets the environment variables inside the container, Django checks for the variables in the container, and then Django pulls the value there. You can see this happen in the Docker yml files. For example, in production.yml you can see this line for the Django container:
The values inside the curl braces are environment variables. If Docker finds |
If I understand correctly, then I think my mistake was that I created in base.py CUSTOM_VAR = env('CUSTOM_VAR') but I didn't update the Docker yaml files with those custom environment variables. I was under the assumption that just updating the .env file under the GW root directory with my custom environment variables would work. That is why I then went the route of having the .env file being copied into the container which made the deploy work with my custom environment variables. |
Ahh, that makes sense. Yes, you are correct. If you customize the files under
|
@chrismaddalena Thanks for the clarification. I reverted my changes in the dockerignore file and followed your steps and it worked. Is this documented anywhere for other people to know? |
It may be, but I'll add it to the list of documentation to add to the wiki. |
In the config/settings/base.py file, there was mention of a .env file that can be used to add environment variables for configuration in Ghostwriter. I noticed that the current code doesn't allow .env files to be used as the Docker COPY command will not copy over the .env to the container in order to find the environment variables in the file.
I had to remove the entry **/.env in .dockerignore to allow the .env file to be copied to the container to allow custom environment variables outside the code.
The text was updated successfully, but these errors were encountered: