chore: add env example and env config
All checks were successful
Build and Push Docker Image / build (push) Successful in 25s
All checks were successful
Build and Push Docker Image / build (push) Successful in 25s
This commit is contained in:
16
.env.example
Normal file
16
.env.example
Normal file
@@ -0,0 +1,16 @@
|
||||
SECRET_KEY=replace-me
|
||||
DEBUG=false
|
||||
ALLOWED_HOSTS=example.com,www.example.com
|
||||
SITE_NAME=SantehRay
|
||||
LOGIN_URL=/users/login/
|
||||
LOGIN_REDIRECT_URL=/users/profile/
|
||||
LOGOUT_REDIRECT_URL=/users/login/
|
||||
EMAIL_BACKEND=django.core.mail.backends.smtp.EmailBackend
|
||||
EMAIL_HOST=smtp.example.com
|
||||
EMAIL_PORT=587
|
||||
EMAIL_HOST_USER=
|
||||
EMAIL_HOST_PASSWORD=
|
||||
EMAIL_USE_TLS=true
|
||||
EMAIL_USE_SSL=false
|
||||
DEFAULT_FROM_EMAIL=no-reply@example.com
|
||||
ADMINISTRATOR_EMAIL=admin@example.com
|
||||
3
.gitignore
vendored
3
.gitignore
vendored
@@ -45,4 +45,5 @@ dist/
|
||||
*.egg-info/
|
||||
.eggs/
|
||||
|
||||
.env*
|
||||
.env*
|
||||
!.env.example
|
||||
|
||||
@@ -34,22 +34,32 @@ def load_env_file(path: Path):
|
||||
os.environ[key] = value
|
||||
|
||||
|
||||
ENV_FILE = Path(os.getenv("DJANGO_ENV_FILE", BASE_DIR / ".env.test"))
|
||||
def env_bool(name: str, default: bool = False) -> bool:
|
||||
return os.getenv(name, str(default)).lower() in {"1", "true", "yes", "on"}
|
||||
|
||||
|
||||
def env_list(name: str, default: list[str]) -> list[str]:
|
||||
value = os.getenv(name)
|
||||
if value is None:
|
||||
return default
|
||||
return [item.strip() for item in value.split(",") if item.strip()]
|
||||
|
||||
|
||||
ENV_FILE = Path(os.getenv("DJANGO_ENV_FILE", BASE_DIR / ".env"))
|
||||
load_env_file(ENV_FILE)
|
||||
if not ENV_FILE.exists():
|
||||
load_env_file(BASE_DIR / ".env.test")
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/5.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-*%u*i415=%@ny05mbd-j3802bcl!(0nwa3#^yxnor)7nd(w7%q'
|
||||
SECRET_KEY = os.getenv("SECRET_KEY", "django-insecure-*%u*i415=%@ny05mbd-j3802bcl!(0nwa3#^yxnor)7nd(w7%q")
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = True
|
||||
DEBUG = env_bool("DEBUG", True)
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
"127.0.0.1",
|
||||
"preview-1.azimkin.dev",
|
||||
]
|
||||
ALLOWED_HOSTS = env_list("ALLOWED_HOSTS", ["127.0.0.1", "preview-1.azimkin.dev"])
|
||||
|
||||
# Application definition
|
||||
|
||||
@@ -169,18 +179,18 @@ STORAGES = {
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
||||
SITE_NAME = 'SantehRay'
|
||||
SITE_NAME = os.getenv("SITE_NAME", "SantehRay")
|
||||
|
||||
LOGIN_URL = '/users/login/'
|
||||
LOGIN_REDIRECT_URL = '/users/profile/'
|
||||
LOGOUT_REDIRECT_URL = '/users/login/'
|
||||
LOGIN_URL = os.getenv("LOGIN_URL", "/users/login/")
|
||||
LOGIN_REDIRECT_URL = os.getenv("LOGIN_REDIRECT_URL", "/users/profile/")
|
||||
LOGOUT_REDIRECT_URL = os.getenv("LOGOUT_REDIRECT_URL", "/users/login/")
|
||||
|
||||
EMAIL_BACKEND = os.getenv('EMAIL_BACKEND', 'django.core.mail.backends.console.EmailBackend')
|
||||
EMAIL_HOST = os.getenv('EMAIL_HOST', 'localhost')
|
||||
EMAIL_PORT = int(os.getenv('EMAIL_PORT', '25'))
|
||||
EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', '')
|
||||
EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', '')
|
||||
EMAIL_USE_TLS = os.getenv('EMAIL_USE_TLS', 'false').lower() in {'1', 'true', 'yes', 'on'}
|
||||
EMAIL_USE_SSL = os.getenv('EMAIL_USE_SSL', 'false').lower() in {'1', 'true', 'yes', 'on'}
|
||||
EMAIL_USE_TLS = env_bool('EMAIL_USE_TLS', False)
|
||||
EMAIL_USE_SSL = env_bool('EMAIL_USE_SSL', False)
|
||||
DEFAULT_FROM_EMAIL = os.getenv('DEFAULT_FROM_EMAIL', 'no-reply@santehray.local')
|
||||
ADMINISTRATOR_EMAIL = os.getenv('ADMINISTRATOR_EMAIL', 'info@santehray.by')
|
||||
|
||||
Reference in New Issue
Block a user