Skip to content
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

Feat: Unattended superuser creation #1778

Merged
merged 3 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ python manage.py migrate
# check DJANGO_ADMIN = true, default to false if empty or unset

if [[ ${DJANGO_ADMIN:-false} = true ]]; then
python manage.py createsuperuser
python manage.py createsuperuser --no-input
else
echo "superuser: Django not configured for Admin access"
fi
Expand Down
36 changes: 36 additions & 0 deletions docs/configuration/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,42 @@ By default the application sends logs to `stdout`.

Django's primary secret, keep this safe!

### `DJANGO_SUPERUSER_EMAIL`

!!! warning "Deployment configuration"

You may change this setting when deploying the app to a non-localhost domain

!!! danger "Required configuration"

This setting is required when `DJANGO_ADMIN` is `true`

The email address of the Django Admin superuser created during initialization.

### `DJANGO_SUPERUSER_PASSWORD`

!!! warning "Deployment configuration"

You may change this setting when deploying the app to a non-localhost domain

!!! danger "Required configuration"

This setting is required when `DJANGO_ADMIN` is `true`

The password of the Django Admin superuser created during initialization.

### `DJANGO_SUPERUSER_USERNAME`

!!! warning "Deployment configuration"

You may change this setting when deploying the app to a non-localhost domain

!!! danger "Required configuration"

This setting is required when `DJANGO_ADMIN` is `true`

The username of the Django Admin superuser created during initialization.

### `DJANGO_TRUSTED_ORIGINS`

!!! warning "Deployment configuration"
Expand Down
15 changes: 9 additions & 6 deletions terraform/app_service.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,15 @@ resource "azurerm_linux_web_app" "main" {
"REQUESTS_READ_TIMEOUT" = "${local.secret_prefix}requests-read-timeout)",

# Django settings
"DJANGO_ADMIN" = (local.is_prod || local.is_test) ? null : "${local.secret_prefix}django-admin)",
"DJANGO_ALLOWED_HOSTS" = "${local.secret_prefix}django-allowed-hosts)",
"DJANGO_DB_DIR" = "${local.secret_prefix}django-db-dir)",
"DJANGO_DB_RESET" = "${local.secret_prefix}django-db-reset)",
"DJANGO_DEBUG" = local.is_prod ? null : "${local.secret_prefix}django-debug)",
"DJANGO_LOG_LEVEL" = "${local.secret_prefix}django-log-level)",
"DJANGO_ADMIN" = "${local.secret_prefix}django-admin)",
"DJANGO_ALLOWED_HOSTS" = "${local.secret_prefix}django-allowed-hosts)",
"DJANGO_DB_DIR" = "${local.secret_prefix}django-db-dir)",
"DJANGO_DB_RESET" = "${local.secret_prefix}django-db-reset)",
"DJANGO_DEBUG" = local.is_prod ? null : "${local.secret_prefix}django-debug)",
"DJANGO_LOG_LEVEL" = "${local.secret_prefix}django-log-level)",
"DJANGO_SUPERUSER_EMAIL" = "${local.secret_prefix}django-superuser-email)",
"DJANGO_SUPERUSER_PASSWORD" = "${local.secret_prefix}django-superuser-password)",
"DJANGO_SUPERUSER_USERNAME" = "${local.secret_prefix}django-superuser-username)",

"DJANGO_RECAPTCHA_SECRET_KEY" = local.is_dev ? null : "${local.secret_prefix}django-recaptcha-secret-key)",
"DJANGO_RECAPTCHA_SITE_KEY" = local.is_dev ? null : "${local.secret_prefix}django-recaptcha-site-key)",
Expand Down