mirror of
https://github.com/narrrl/holy-flavor-rater.git
synced 2026-11-03 16:41:27 +01:00
simplified .env configuration with DOMAIN-based defaults and improved docker-compose orchestration
This commit is contained in:
1 parent
2da6c8e240
commit
8d3e8ebf18
3 files changed
+32
-22
No files matched your search
+12
-12
@@ -1,4 +1,7 @@
|
|||||||
# --- Application Security ---
|
# --- Essential Site Configuration ---
|
||||||
|
# Your primary domain (e.g., holy.narl.io). Used to derive ALLOWED_HOSTS, CORS, and CSRF settings.
|
||||||
|
DOMAIN="localhost"
|
||||||
|
|
||||||
# Set to a long, random string in production (e.g. 50+ chars)
|
# Set to a long, random string in production (e.g. 50+ chars)
|
||||||
SECRET_KEY="django-insecure-replace-this-in-production"
|
SECRET_KEY="django-insecure-replace-this-in-production"
|
||||||
|
|
||||||
@@ -8,15 +11,12 @@ DEBUG=true
|
|||||||
# Custom URL for the Django Admin interface (e.g., my-secret-admin/)
|
# Custom URL for the Django Admin interface (e.g., my-secret-admin/)
|
||||||
ADMIN_URL="admin"
|
ADMIN_URL="admin"
|
||||||
|
|
||||||
# --- Hosting & Networking ---
|
# --- Advanced Networking (Optional, derived from DOMAIN if unset) ---
|
||||||
# The primary domain where your app is hosted (e.g., holy.narl.io)
|
# ALLOWED_HOSTS=holy.narl.io,another-domain.com
|
||||||
ALLOWED_HOSTS=localhost,127.0.0.1,backend,holy.narl.io
|
# CSRF_TRUSTED_ORIGINS=https://holy.narl.io
|
||||||
|
# CORS_ALLOWED_ORIGINS=https://holy.narl.io
|
||||||
# CSRF protection: Comma-separated list of trusted origins (MUST start with https:// in production)
|
# FRONTEND_URL=https://holy.narl.io
|
||||||
CSRF_TRUSTED_ORIGINS=https://holy.narl.io
|
# VITE_API_URL=https://holy.narl.io/api/
|
||||||
|
|
||||||
# CORS protection: Comma-separated list of allowed origins
|
|
||||||
CORS_ALLOWED_ORIGINS=https://holy.narl.io
|
|
||||||
|
|
||||||
# --- SMTP Configuration (Required for Email Verification) ---
|
# --- SMTP Configuration (Required for Email Verification) ---
|
||||||
# For development, if EMAIL_HOST is empty, emails are printed to the console.
|
# For development, if EMAIL_HOST is empty, emails are printed to the console.
|
||||||
@@ -32,8 +32,8 @@ EMAIL_HOST_PASSWORD="your-password"
|
|||||||
EMAIL_SKIP_CERT_VERIFICATION=false
|
EMAIL_SKIP_CERT_VERIFICATION=false
|
||||||
|
|
||||||
# --- Frontend Configuration ---
|
# --- Frontend Configuration ---
|
||||||
# The base URL of the backend API (MUST end with /api/)
|
# Optional: defaults to ${DOMAIN}/api/ if not set
|
||||||
VITE_API_URL=https://holy.narl.io/api/
|
# VITE_API_URL=https://holy.narl.io/api/
|
||||||
VITE_ALLOWED_HOSTS=localhost,holy.narl.io
|
VITE_ALLOWED_HOSTS=localhost,holy.narl.io
|
||||||
|
|
||||||
# --- Impressum / Contact Details (Required for German Law § 5 TMG) ---
|
# --- Impressum / Contact Details (Required for German Law § 5 TMG) ---
|
||||||
|
|||||||
@@ -26,8 +26,17 @@ SECRET_KEY = os.environ.get('SECRET_KEY', 'django-insecure-zos99ue2a89!4jrv4g@_b
|
|||||||
# SECURITY WARNING: don't run with debug turned on in production!
|
# SECURITY WARNING: don't run with debug turned on in production!
|
||||||
DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'
|
DEBUG = os.environ.get('DEBUG', 'false').lower() == 'true'
|
||||||
|
|
||||||
ALLOWED_HOSTS_STRING = os.environ.get('ALLOWED_HOSTS', 'localhost,127.0.0.1,backend,holy.narl.io')
|
# Simplification: Use a single DOMAIN variable to derive multiple settings
|
||||||
ALLOWED_HOSTS = [host.strip() for host in ALLOWED_HOSTS_STRING.split(',')]
|
DOMAIN = os.environ.get('DOMAIN', 'holy.narl.io')
|
||||||
|
|
||||||
|
# Helper to build lists from env or defaults
|
||||||
|
def get_env_list(var_name, default_list):
|
||||||
|
val = os.environ.get(var_name)
|
||||||
|
if val:
|
||||||
|
return [item.strip() for item in val.split(',')]
|
||||||
|
return default_list
|
||||||
|
|
||||||
|
ALLOWED_HOSTS = get_env_list('ALLOWED_HOSTS', ['localhost', '127.0.0.1', 'backend', 'worker', DOMAIN])
|
||||||
|
|
||||||
|
|
||||||
# Application definition
|
# Application definition
|
||||||
@@ -166,8 +175,7 @@ if not DEBUG:
|
|||||||
SECURE_HSTS_PRELOAD = True
|
SECURE_HSTS_PRELOAD = True
|
||||||
|
|
||||||
# Read CSRF trusted origins from environment variable
|
# Read CSRF trusted origins from environment variable
|
||||||
CSRF_TRUSTED_ORIGINS_STRING = os.environ.get('CSRF_TRUSTED_ORIGINS', 'https://holy.narl.io,http://localhost:5173')
|
CSRF_TRUSTED_ORIGINS = get_env_list('CSRF_TRUSTED_ORIGINS', [f'https://{DOMAIN}', 'http://localhost:5173'])
|
||||||
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in CSRF_TRUSTED_ORIGINS_STRING.split(',')]
|
|
||||||
|
|
||||||
# Custom User Model
|
# Custom User Model
|
||||||
AUTH_USER_MODEL = 'api.User'
|
AUTH_USER_MODEL = 'api.User'
|
||||||
@@ -188,10 +196,9 @@ REST_FRAMEWORK = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# CORS
|
# CORS
|
||||||
CORS_ALLOWED_ORIGINS_STRING = os.environ.get('CORS_ALLOWED_ORIGINS', 'https://holy.narl.io,http://localhost:5173,http://127.0.0.1:5173')
|
CORS_ALLOWED_ORIGINS = get_env_list('CORS_ALLOWED_ORIGINS', [f'https://{DOMAIN}', 'http://localhost:5173', 'http://127.0.0.1:5173'])
|
||||||
CORS_ALLOWED_ORIGINS = [origin.strip() for origin in CORS_ALLOWED_ORIGINS_STRING.split(',')]
|
|
||||||
|
|
||||||
FRONTEND_URL = os.environ.get('FRONTEND_URL', 'https://holy.narl.io').rstrip('/')
|
FRONTEND_URL = os.environ.get('FRONTEND_URL', f'https://{DOMAIN}').rstrip('/')
|
||||||
|
|
||||||
import os
|
import os
|
||||||
# ... (near top of file)
|
# ... (near top of file)
|
||||||
|
|||||||
+6
-3
@@ -14,6 +14,7 @@ services:
|
|||||||
- ./legacy:/app/legacy
|
- ./legacy:/app/legacy
|
||||||
environment:
|
environment:
|
||||||
- PYTHONUNBUFFERED=1
|
- PYTHONUNBUFFERED=1
|
||||||
|
- DOMAIN=${DOMAIN:-holy.narl.io}
|
||||||
dns:
|
dns:
|
||||||
- 8.8.8.8
|
- 8.8.8.8
|
||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
@@ -22,7 +23,7 @@ services:
|
|||||||
- "traefik.docker.network=narl"
|
- "traefik.docker.network=narl"
|
||||||
# Ultra-clean rule for maximum Traefik compatibility
|
# Ultra-clean rule for maximum Traefik compatibility
|
||||||
- "traefik.http.routers.holy-energy-backend.priority=100"
|
- "traefik.http.routers.holy-energy-backend.priority=100"
|
||||||
- "traefik.http.routers.holy-energy-backend.rule=Host(`holy.narl.io`) && (PathPrefix(`/api`) || PathPrefix(`/admin/`) || PathPrefix(`/static`) || PathPrefix(`/media`))"
|
- "traefik.http.routers.holy-energy-backend.rule=Host(`${DOMAIN:-holy.narl.io}`) && (PathPrefix(`/api`) || PathPrefix(`/admin/`) || PathPrefix(`/static`) || PathPrefix(`/media`))"
|
||||||
- "traefik.http.routers.holy-energy-backend.entrypoints=websecure"
|
- "traefik.http.routers.holy-energy-backend.entrypoints=websecure"
|
||||||
- "traefik.http.routers.holy-energy-backend.tls.certresolver=https_resolver"
|
- "traefik.http.routers.holy-energy-backend.tls.certresolver=https_resolver"
|
||||||
- "traefik.http.services.holy-energy-backend.loadbalancer.server.port=8000"
|
- "traefik.http.services.holy-energy-backend.loadbalancer.server.port=8000"
|
||||||
@@ -46,6 +47,8 @@ services:
|
|||||||
- 1.1.1.1
|
- 1.1.1.1
|
||||||
env_file:
|
env_file:
|
||||||
- .env
|
- .env
|
||||||
|
environment:
|
||||||
|
- DOMAIN=${DOMAIN:-holy.narl.io}
|
||||||
volumes:
|
volumes:
|
||||||
- ./backend:/app
|
- ./backend:/app
|
||||||
- ./legacy:/app/legacy
|
- ./legacy:/app/legacy
|
||||||
@@ -57,7 +60,7 @@ services:
|
|||||||
build:
|
build:
|
||||||
context: ./frontend
|
context: ./frontend
|
||||||
args:
|
args:
|
||||||
- VITE_API_URL=https://holy.narl.io/api/
|
- VITE_API_URL=https://${DOMAIN:-holy.narl.io}/api/
|
||||||
- VITE_IMPRESSUM_NAME=${VITE_IMPRESSUM_NAME}
|
- VITE_IMPRESSUM_NAME=${VITE_IMPRESSUM_NAME}
|
||||||
- VITE_IMPRESSUM_STREET=${VITE_IMPRESSUM_STREET}
|
- VITE_IMPRESSUM_STREET=${VITE_IMPRESSUM_STREET}
|
||||||
- VITE_IMPRESSUM_CITY=${VITE_IMPRESSUM_CITY}
|
- VITE_IMPRESSUM_CITY=${VITE_IMPRESSUM_CITY}
|
||||||
@@ -76,7 +79,7 @@ services:
|
|||||||
- "traefik.enable=true"
|
- "traefik.enable=true"
|
||||||
- "traefik.docker.network=narl"
|
- "traefik.docker.network=narl"
|
||||||
- "traefik.http.routers.holy-energy-frontend.priority=10"
|
- "traefik.http.routers.holy-energy-frontend.priority=10"
|
||||||
- "traefik.http.routers.holy-energy-frontend.rule=Host(`holy.narl.io`)"
|
- "traefik.http.routers.holy-energy-frontend.rule=Host(`${DOMAIN:-holy.narl.io}`)"
|
||||||
- "traefik.http.routers.holy-energy-frontend.entrypoints=websecure"
|
- "traefik.http.routers.holy-energy-frontend.entrypoints=websecure"
|
||||||
- "traefik.http.routers.holy-energy-frontend.tls.certresolver=https_resolver"
|
- "traefik.http.routers.holy-energy-frontend.tls.certresolver=https_resolver"
|
||||||
- "traefik.http.services.holy-energy-frontend.loadbalancer.server.port=80"
|
- "traefik.http.services.holy-energy-frontend.loadbalancer.server.port=80"
|
||||||
|
|||||||
Reference in new issue
Block a user