- How to read the variables definition
- Values based on previous values
- Adding new variables
- CookieCutter variables
- project_title
- repo_name
- thorgate
- live_domain_name
- test_host
- admin_email
- include_celery
- docker_base_image
- python_version
- node_version
- postgres_version
- django_admin_path
- django_health_check_path
- django_folder_name
- default_django_app
- django_media_engine
- gitlab_repo_url
- frontend_style
- webapp_include_storybook
- x_frame_options
- content_security_policy
- use_mypy
- use_cypress
- build_in_ci
- use_auto_deploy
In cookiecutter.json we define all the variables used in the project.
Values in cookiecutter.json are rendered using jinja2 templates. This means that you can use previous values in the definition of the next one.
For example:
{
"project_title": "My Project",
"repo_name": "{{ cookiecutter.project_title | slugify }}",
}
When adding new variables to the project template cookiecutter.json
make sure to also add them to CookiecutterVariables.adoc
file.
Wrap them in a _ tag::my_cool_variable[]
blocks, so you can automatically include the variable definition in the reference documentation.
This allows to show the default value thh documentation without having to hard-code it there.
Tip
|
Don’t be afraid to add new variables, even if you’re using an existing variable in the project, just define a new variable based on the same value with a _ prefix and use it. This will allow future developers to extend the logic based on that value that use much easier. |
Public title of the project.
This is used in docs, emails navbars, etc. Anywhere the project name is shown to the public this is used.
{
link:cookiecutter.json[role=include]
}
Tip
|
If you’re using repo_name or project_title in a new place in the projects where you’re using it as a string and have the ability to import django.conf.settings, import the value from there instead of using this variable, so the code is the same for all generated projects.
|
Preferably lowercase codename, used for the directory structure and Python modules.
Used as the root for a lot of things. Including folder names and the core project name on servers.
{
link:cookiecutter.json[role=include]
}
Are you from thorgate? Exclude common config present for Thorgate.
{
link:cookiecutter.json[role=include]
}
Production domain name of the site (e.g. example.com). NOTE: should be lowercase and valid FQDN.
{
link:cookiecutter.json[role=include]
}
Hostname for test server. Used to generate the first ansible host.
{
link:cookiecutter.json[role=include]
}
Project email. Used for any data requiring email, django admin and certbot expiration notifications.
{
link:cookiecutter.json[role=include]
}
Include Celery with Redis as the broker.
{
link:cookiecutter.json[role=include]
}
Django Admin panel URL path.
NOTE: Should not start or end with /
.
Defaults to adminpanel
.
{
link:cookiecutter.json[role=include]
}
Django health check URL path.
NOTE: Should not start or end with /
.
Defaults to _health
.
{
link:cookiecutter.json[role=include]
}
Directory name for the Django codebase.
{
link:cookiecutter.json[role=include]
}
Name of the core Django app for the project
{
link:cookiecutter.json[role=include]
}
Django remote media storage engine to use.
{
link:cookiecutter.json[role=include]
}
[Optional] Gitlab repo url in format: https://gitlab.com/your-group/project-name.
This is used for deriving the Gitlab repository url to use when deploying or the default Docker registry url used for the project. Additionally the CI badges in the README file are created based on this value.
Note
|
If this is not defined during the project creation/upgrade then one needs to manually update the
repository variable inside ansible/group_vars/all/vars.yml file of the resulting project to the correct
git repository url (SSH). Additionally, when build_in_ci is set to yes then the image urls in environemnt
file need to be updated to correct values too.
|
Warning
|
If you’re using a nested group, then you should use the git@ format for the repo url. see this test case. |
{
link:cookiecutter.json[role=include]
}
Webapp only: Include storybook configuration?
{
link:cookiecutter.json[role=include]
}
Set X-Frame-Options header for nginx config.
You should choose SAMEORIGIN
when you want to display current page in a frame on another page, but only within the
current domain.
{
link:cookiecutter.json[role=include]
}
This variable affects Content Security Policy (CSP) (https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) settings.
{
link:cookiecutter.json[role=include]
}
Do you want to build docker images in CI for deployment?
Note
|
Requires a docker registry. |
{
link:cookiecutter.json[role=include]
}