chore(deploy): 本地部署脚本、容器配置与运行说明
PostgreSQL/pgvector 与 Redis 独立容器,后端、worker、前端可一键启停;不覆盖既有密钥。
This commit is contained in:
1 parent
83a16ed07d
commit
5be5ca3376
18 files changed
+1796
No files matched your search
@@ -0,0 +1,62 @@
|
||||
"""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://chattermate:{password}@127.0.0.1:15432/chattermate",
|
||||
"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()
|
||||
Reference in new issue
Block a user