Spaces:
Running
Running
File size: 928 Bytes
8f1b6ce | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #!/usr/bin/env python3
"""Create local secrets without dependencies. Never overwrite an existing environment file."""
import base64
import secrets
from pathlib import Path
root = Path(__file__).resolve().parents[1]
path = root / ".env"
if path.exists():
raise SystemExit(".env already exists; kept unchanged.")
key = base64.urlsafe_b64encode(secrets.token_bytes(32)).decode()
password = secrets.token_urlsafe(32)
path.write_text(f"""# Keep this file private. Back up ENCRYPTION_KEYS with your database.
ENVIRONMENT=development
ENCRYPTION_KEYS={key}
ALLOWED_ORIGINS=["http://localhost:7860"]
COOKIE_SECURE=false
ALLOW_REGISTRATION=true
REGISTRATION_CODE=
POSTGRES_PASSWORD={password}
REDIS_PASSWORD={secrets.token_urlsafe(32)}
MAX_RETRIES=2
REQUESTS_PER_MINUTE=60
STATIC_DIR=frontend/out
""")
path.chmod(0o600)
print(
"Created .env with fresh secrets. Run docker compose up --build, then open http://localhost:7860."
)
|