# DFIRe 1.9.0 environment contract
#
# Copy this file to .env, select one database overlay, and replace every
# CHANGE_ME value. The lean installer generates these values automatically.
# Keep .env mode 0600 and include it in encrypted backups. Do not commit it.

# -----------------------------------------------------------------------------
# Docker Compose deployment settings
# These values are consumed by Docker Compose, not by the application.
# -----------------------------------------------------------------------------

# Required | Stable deployment identity
# Keep this value unchanged during upgrades so Compose reuses named volumes.
COMPOSE_PROJECT_NAME=dfire

# Required | Character separating the files listed in COMPOSE_FILE.
# Compose defaults this to ';' on Windows and ':' elsewhere. Setting it
# explicitly keeps one COMPOSE_FILE value working on every platform.
COMPOSE_PATH_SEPARATOR=:

# Required | Choose exactly one database overlay.
# Professional deployment:
COMPOSE_FILE=compose.yaml:compose.external-db.yaml
# Evaluation with bundled PostgreSQL:
# COMPOSE_FILE=compose.yaml:compose.internal-db.yaml

# Required | Docker port mapping for the frontend container.
# Use 127.0.0.1:8080:80 for a reverse proxy on the same host, or
# 0.0.0.0:8080:80 for a separate proxy or direct evaluation access.
FRONTEND_BIND=127.0.0.1:8080:80

# -----------------------------------------------------------------------------
# Database
# DATABASE_URL and DFIRE_DIRECT_DATABASE_URL are consumed by backend,
# qcluster, and slack-socket. POSTGRES_* is consumed only by the optional
# bundled PostgreSQL service.
# -----------------------------------------------------------------------------

# Required with compose.external-db.yaml | Secret
# PostgreSQL URL used by normal application traffic. Percent-encode special
# characters in the username or password. sslmode=require is recommended.
DATABASE_URL=CHANGE_ME

# Conditionally required | Secret
# Direct PostgreSQL URL for migrations, backups, and restores. Leave empty
# when DATABASE_URL is already direct. Required when DATABASE_URL points to
# PgBouncer, RDS Proxy, or another transaction-pooling endpoint.
DFIRE_DIRECT_DATABASE_URL=

# Required with compose.internal-db.yaml
POSTGRES_DB=dfire
POSTGRES_USER=dfire

# Required with compose.internal-db.yaml | Secret
# Use URL-safe characters because this value is also placed in DATABASE_URL.
POSTGRES_PASSWORD=CHANGE_ME

# -----------------------------------------------------------------------------
# Redis
# Consumed by backend, qcluster, and slack-socket. Compose supplies redis:6379;
# platforms such as ECS must supply the correct service address themselves.
# -----------------------------------------------------------------------------

# Required
REDIS_HOST=redis
REDIS_PORT=6379

# Optional | Secret
# Empty disables Redis authentication in the bundled Redis service.
REDIS_PASSWORD=

# -----------------------------------------------------------------------------
# Persistent application secrets
# Consumed by backend, qcluster, and slack-socket.
# -----------------------------------------------------------------------------

# Required | Secret | Never change after installation
# Generate with: openssl rand -hex 32
SECRET_KEY=CHANGE_ME

# Required | Secret | Never change after installation
# Changing this makes stored encrypted credentials and backups unreadable.
# Generate with: openssl rand -base64 32 | tr '+/' '-_'
CREDENTIAL_ENCRYPTION_KEY=CHANGE_ME

# -----------------------------------------------------------------------------
# Web and proxy configuration
# Consumed by backend.
# -----------------------------------------------------------------------------

# Required | Comma-separated hostnames accepted by Django.
ALLOWED_HOSTS=dfire.example.com,localhost

# Required | Comma-separated origins, including scheme and any nonstandard port.
CORS_ALLOWED_ORIGINS=https://dfire.example.com
CSRF_TRUSTED_ORIGINS=https://dfire.example.com

# Required | True only for an external-proxy deployment where the frontend is
# not publicly reachable and the outer proxy overwrites X-Forwarded-Proto.
# Use false for direct HTTP because clients can supply forwarding headers.
TRUST_PROXY_HEADERS=true

# Required | Set False only for an HTTP evaluation deployment.
AUTH_COOKIE_SECURE=True

# -----------------------------------------------------------------------------
# Runtime settings
# Compose supplies these values. Other platforms must set them for each
# backend-derived process unless their platform definition provides defaults.
# -----------------------------------------------------------------------------

DEBUG=false
DFIRE_ENVIRONMENT=production

# Backend web process only | Optional
GUNICORN_WORKERS=2

# qcluster only | Supplied by compose.yaml
# DFIRE_DB_STATEMENT_TIMEOUT_MS=0

# -----------------------------------------------------------------------------
# Initial administrator
# Consumed by backend only. These values are used only when creating the first
# administrator. Remove the password from .env after the account exists.
# -----------------------------------------------------------------------------

DJANGO_SUPERUSER_EMAIL=
DJANGO_SUPERUSER_USERNAME=
DJANGO_SUPERUSER_PASSWORD=
