summaryrefslogtreecommitdiffhomepage
path: root/infra
diff options
context:
space:
mode:
authorDax Raad <[email protected]>2025-09-02 03:14:56 -0400
committerDax Raad <[email protected]>2025-09-02 03:18:30 -0400
commit810c9cff1db91f10158cc002dc70b89871762e1e (patch)
tree108ea81a51856003bad4d376a6a0fa79e5964216 /infra
parent47d4c87bdd358f69be5a5612868b5127de1922a3 (diff)
downloadopencode-810c9cff1db91f10158cc002dc70b89871762e1e.tar.gz
opencode-810c9cff1db91f10158cc002dc70b89871762e1e.zip
wip: cloud
Diffstat (limited to 'infra')
-rw-r--r--infra/cloud.ts41
1 files changed, 33 insertions, 8 deletions
diff --git a/infra/cloud.ts b/infra/cloud.ts
index 8181ae0e0..9dbfcd2cc 100644
--- a/infra/cloud.ts
+++ b/infra/cloud.ts
@@ -5,15 +5,40 @@ import { domain } from "./stage"
// DATABASE
////////////////
-const DATABASE_USERNAME = new sst.Secret("DATABASE_USERNAME")
-const DATABASE_PASSWORD = new sst.Secret("DATABASE_PASSWORD")
+const cluster = planetscale.getDatabaseOutput({
+ name: "opencode",
+ organization: "sst",
+})
+
+const branch =
+ $app.stage === "production"
+ ? planetscale.getBranchOutput({
+ name: "production",
+ organization: cluster.organization,
+ database: cluster.name,
+ })
+ : new planetscale.Branch("DatabaseBranch", {
+ database: cluster.name,
+ organization: cluster.organization,
+ name: $app.stage,
+ parentBranch: "production",
+ })
+const password = new planetscale.Password("DatabasePassword", {
+ name: $app.stage,
+ database: cluster.name,
+ organization: cluster.organization,
+ branch: branch.name,
+})
+
+password.accessHostUrl.apply(console.log)
+
export const database = new sst.Linkable("Database", {
properties: {
- host: `aws-us-east-2-${$app.stage === "thdxr" ? "2" : "1"}.pg.psdb.cloud`,
- database: "postgres",
- username: DATABASE_USERNAME.value,
- password: DATABASE_PASSWORD.value,
- port: 6432,
+ host: password.accessHostUrl,
+ database: cluster.name,
+ username: password.username,
+ password: password.plaintext,
+ port: 3306,
},
})
@@ -105,7 +130,7 @@ export const gateway = new sst.cloudflare.Worker("GatewayApi", {
// CONSOLE
////////////////
-export const console = new sst.cloudflare.x.SolidStart("Console", {
+new sst.cloudflare.x.SolidStart("Console", {
domain: `console.${domain}`,
path: "cloud/app",
link: [