Files
replypier/deploy/local/init_env.py
T
WangShen007 54b949b392 chore(brand): rename the product to ReplyPier
The upstream project name is gone from code, assets, docs and build
output: brand strings, domains (replypier.site and its app/api/docs/help
subdomains), env prefixes, image and network names, the widget's public
JS API (window.ReplyPier, replypierId/BaseUrl/Config/Token), CSS tokens
(--rp-*), file and directory names, and the WordPress plugin package.

- widget loader is now webclient/replypier.min.js; both bundles rebuilt
  from source (backend/assets/widget.{js,css}, frontend/public/webclient)
- NOTICE, llms.txt, CONTRIBUTING, HELP_CENTER_INFRA and config.dev.js
  rewritten rather than string-swapped; the demo config no longer ships
  the previous vendor's Firebase/Razorpay/Google keys
- new migration replypier_ai_model_001 adds REPLYPIER to the managed
  AIModelType and rewrites pre-rename rows
- local compose project, database, role and volume renamed; LOCAL_DEPLOY
  documents carrying the old local data over
2026-10-26 00:51:03 +08:00

63 lines
2.3 KiB
Python

"""Create private configuration for the loopback-only local deployment."""
import base64
import json
import secrets
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
LOCAL = ROOT / "deploy" / "local"
STATE = LOCAL / ".state"
def write_new(filename: Path, text: str) -> None:
if filename.exists():
return
with filename.open("x", encoding="utf-8") as stream:
filename.chmod(0o600)
stream.write(text)
def main() -> None:
STATE.mkdir(parents=True, exist_ok=True)
STATE.chmod(0o700)
compose_env = LOCAL / ".env"
write_new(compose_env, f"POSTGRES_PASSWORD={secrets.token_hex(24)}\n")
password = compose_env.read_text().strip().split("=", 1)[1]
fernet_key = base64.b64encode(base64.urlsafe_b64encode(secrets.token_bytes(32))).decode()
settings = {
"DATABASE_URL": f"postgresql+psycopg://replypier:{password}@127.0.0.1:15432/replypier",
"REDIS_ENABLED": "true",
"REDIS_URL": "redis://127.0.0.1:16380/0",
"ENVIRONMENT": "production",
"JWT_SECRET_KEY": secrets.token_hex(32),
"CONVERSATION_SECRET_KEY": secrets.token_hex(32),
"ENCRYPTION_KEY": fernet_key,
"FRONTEND_URL": "http://127.0.0.1:3018",
"BACKEND_URL": "http://127.0.0.1:8018",
"VITE_WIDGET_URL": "http://127.0.0.1:8018",
"CORS_ORIGINS": json.dumps(["http://127.0.0.1:3018", "http://localhost:3018", "http://127.0.0.1:8018"]),
"WIDGET_ASSETS_DIR": str(STATE / "assets"),
"FASTEMBED_CACHE_PATH": str(STATE / "fastembed"),
"S3_FILE_STORAGE": "false",
"AWS_EC2_METADATA_DISABLED": "true",
"MCP_STDIO_ENABLED": "false",
"AGNO_TELEMETRY": "false",
"AGNO_MONITOR": "false",
"EMBEDDING_MAX_WORKERS": "1",
"KB_MAX_WORKERS": "1",
"OMP_NUM_THREADS": "1",
"POLL_INTERVAL": "30",
"SMTP_SERVER": "127.0.0.1",
"SMTP_PORT": "1025",
"SMTP_USERNAME": "",
"SMTP_PASSWORD": "",
}
write_new(ROOT / "backend" / ".env", "".join(f"{key}={value}\n" for key, value in settings.items()))
write_new(ROOT / "frontend" / ".env", "VITE_API_URL=http://127.0.0.1:8018/api/v1\nVITE_WS_URL=ws://127.0.0.1:8018\nVITE_WIDGET_URL=http://127.0.0.1:8018\n")
print("Local configuration is ready; existing files were not overwritten.")
if __name__ == "__main__":
main()