55 lines
1.8 KiB
Python
55 lines
1.8 KiB
Python
#!/usr/bin/env python3
|
|
"""Create a local .env for the synthetic stand. Existing files are left untouched."""
|
|
import secrets
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
TARGET = ROOT / ".env"
|
|
|
|
|
|
def main() -> None:
|
|
if TARGET.exists():
|
|
print("local env already exists")
|
|
return
|
|
database_password = secrets.token_hex(16)
|
|
object_password = secrets.token_hex(16)
|
|
broker_password = secrets.token_hex(16)
|
|
operator = secrets.token_hex(16)
|
|
lines = [
|
|
"POSTGRES_USER=messenger",
|
|
"POSTGRES_PASSWORD=" + database_password,
|
|
"POSTGRES_DB=messenger",
|
|
"MINIO_ROOT_USER=labminio",
|
|
"MINIO_ROOT_PASSWORD=" + object_password,
|
|
"S3_ACCESS_KEY_ID=labminio",
|
|
"S3_SECRET_ACCESS_KEY=" + object_password,
|
|
"S3_ENDPOINT=http://minio:9000",
|
|
"S3_REGION=us-east-1",
|
|
"S3_BUCKET=messenger-attachments",
|
|
"RABBITMQ_DEFAULT_USER=messenger",
|
|
"RABBITMQ_DEFAULT_PASS=" + broker_password,
|
|
"DATABASE_URL=postgresql://messenger:" + database_password + "@postgres:5432/messenger",
|
|
"BROKER_URL=amqp://messenger:" + broker_password + "@rabbitmq:5672/",
|
|
"SESSION_TTL_SECONDS=3600",
|
|
"IDEMPOTENCY_TTL_SECONDS=86400",
|
|
"MAX_UPLOAD_BYTES=10485760",
|
|
"MAX_IMAGE_PIXELS=40000000",
|
|
"WORKER_CONCURRENCY=2",
|
|
"JOB_MAX_ATTEMPTS=5",
|
|
"JOB_TIMEOUT_SECONDS=60",
|
|
"JOB_BACKOFF_BASE_SECONDS=0.4",
|
|
"JOB_BACKOFF_CAP_SECONDS=8",
|
|
"STAGING_RETENTION_SECONDS=86400",
|
|
"MAX_QUEUED_JOBS=500",
|
|
"OPERATOR_TOKEN=" + operator,
|
|
"APP_HOST=0.0.0.0",
|
|
"APP_PORT=8080",
|
|
"",
|
|
]
|
|
TARGET.write_text("\n".join(lines), encoding="utf-8", newline="\n")
|
|
print("wrote local env")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|