good default django settings for deployments
current docker deployment was not taking in account deployment with DOMAIN - domain is enforced, localhost by default - .env.example proposed (right now only with DOMAIN)
This commit is contained in:
parent
2ed33270ed
commit
765b017ac2
1
.env.example
Normal file
1
.env.example
Normal file
|
@ -0,0 +1 @@
|
||||||
|
DOMAIN=localhost
|
|
@ -27,10 +27,17 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||||
SECRET_KEY = "django-insecure-1p8rs@qf$$l^!vsbetagojw23kw@1ez(qi8^(s0t!wyh!l3"
|
SECRET_KEY = "django-insecure-1p8rs@qf$$l^!vsbetagojw23kw@1ez(qi8^(s0t!wyh!l3"
|
||||||
|
|
||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = True
|
DEBUG = config('DEBUG', default=False, cast=bool)
|
||||||
|
|
||||||
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default='[]', cast=Csv())
|
DOMAIN = config("DOMAIN")
|
||||||
|
assert DOMAIN not in [None, ''], "DOMAIN var is MANDATORY"
|
||||||
|
# this var is very important, we print it
|
||||||
|
print("DOMAIN: " + DOMAIN)
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = config('ALLOWED_HOSTS', default=DOMAIN, cast=Csv())
|
||||||
|
assert DOMAIN in ALLOWED_HOSTS, "DOMAIN is not ALLOWED_HOST"
|
||||||
|
|
||||||
|
CSRF_TRUSTED_ORIGINS = config('CSRF_TRUSTED_ORIGINS', default=f'https://{DOMAIN}', cast=Csv())
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ services:
|
||||||
dockerfile: docker/devicehub-django.Dockerfile
|
dockerfile: docker/devicehub-django.Dockerfile
|
||||||
environment:
|
environment:
|
||||||
- DEBUG=true
|
- DEBUG=true
|
||||||
- ALLOWED_HOSTS=*
|
- DOMAIN=${DOMAIN:-localhost}
|
||||||
volumes:
|
volumes:
|
||||||
- .:/opt/devicehub-django
|
- .:/opt/devicehub-django
|
||||||
ports:
|
ports:
|
||||||
|
|
Loading…
Reference in a new issue