-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Introduce a single source of truth for project domain name #1082
Comments
I think the situation has improved slightly with changes from #1801 We might be able to simplify this a bit further, but not by much: https://github.com/pydanny/cookiecutter-django/search?q=DOMAIN_NAME&unscoped_q=DOMAIN_NAME What do you think @webyneter? Is it still an issue? |
Here is where it's used at the moment:
|
As of now, project domain name is determined at the initial, scaffolding stage only, for it to then be hard-coded into numerous files, -- it might take quite some time to accurately update all the occurrences once required.
Since the domain name is used across multiple file types, --
-- introducing an environment variable representing the domain name might be the single feasible solution, IMO. As for the variable name, it might be
DOMAIN_NAME
.To ensure the variable is accessible project-wide, -- and, given the fact that
.env
file comprising other variables is for production use only, -- I suggest that we create a separate, say,common.env
file with the variable definition, referencing it throughenv_file
setting in bothdev.yml
anddocker-compose.yml
like that:(Elaborating on that even further, my other suggestion would be to contain 'orphan' variables scattered all around
dev.yml
in a separatedev.env
file which can be stored in VCS likewise the development-specific variables it defines are.)Yet, only a single
.env
file must be available at production, so we'd need to concatenatecommon.env
and.env
in an automatic manner (incorporating this functionality in, say,./compose/django/create-env.sh
, called upon indjango
service'scommand
indocker-compose.yml
before./compose/django/gunicorn.sh
is called should suffice).To handle that, special treatment would be required for various kinds of files:
DOMAIN_NAME
through the corresponding view's context;./compose/nginx/start.sh
is the only place the domain name is utilized, and happily it's the only place where the problem is solved already (there, the use ofnginx
service-providedMY_DOMAIN_NAME
variable is made, but referencingcommon.env
in thenginx
service'senv_file
would be one further enhancement).I'm in huge appreciation of any critics and suggestions to follow; that would also be a pleasure for me to provide a PR ones we reach consensus on the issue.
The text was updated successfully, but these errors were encountered: