Skip to content

Commit d9ac5ae

Browse files
committed
feat(examples): multitenant using remote builds
1 parent 08742e2 commit d9ac5ae

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

examples/multitenant-deploys/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ WORKDIR /app
44

55
# Install rivet CLI
66
RUN apk add --no-cache curl unzip
7-
RUN curl -fsSL https://get.rivet.gg/install.sh | sh
7+
RUN curl -fsSL https://releases.rivet.gg/rivet/latest/install.sh | sh
88

99
# Copy package files and install dependencies
1010
COPY package.json yarn.lock ./

examples/multitenant-deploys/README.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ A simple Node.js service for handling multi-tenant deployments with Rivet.
2626
You'll need to set the following environment variables:
2727

2828
```bash
29-
RIVET_CLOUD_TOKEN=your_rivet_cloud_token
30-
RIVET_PROJECT=your_project_id
31-
RIVET_ENVIRONMENT=your_environment_name
29+
RIVET_CLOUD_TOKEN=cloud.eyJ0eXAiOiJKV1QiLCJhbGciOiJFZERTQSJ9.CIOBxo3tMxCDqYHQ9zIaEgoQ6gQI0z2ARCSOKxa7MqkbeyIWOhQKEgoQi6dWe3XyTdmwezSMlI-y6g.mMyza7OdZov2cjeRYxBc76XUC_NONzKAXd-hnXnfuScDQz3VQ5k5N9I_FA_xu7VEbwDpyFzrRbLaMCrEsQj5DA
30+
RIVET_PROJECT=abc-actor-te-j0k
31+
RIVET_ENVIRONMENT=staging
3232
PORT=3000 # Optional, defaults to 3000
3333
```
3434

@@ -65,7 +65,8 @@ yarn test
6565
{
6666
"success": true,
6767
"appId": "your-app-id",
68-
"endpoint": "https://your-app-id.example.com"
68+
"endpoint": "https://your-app-id.example.com",
69+
"buildOutput": "..." // Output logs from build command
6970
}
7071
```
7172

examples/multitenant-deploys/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
},
99
"dependencies": {
1010
"@hono/node-server": "^1.7.0",
11-
"@rivet-gg/api-full": "workspace:*",
1211
"axios": "^1.6.7",
1312
"hono": "^4.0.5",
1413
"temp": "^0.9.4"

examples/multitenant-deploys/src/app.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { promisify } from "node:util";
44
import * as fs from "node:fs/promises";
55
import * as path from "node:path";
66
import temp from "temp";
7-
import { RivetClient } from "@rivet-gg/api-full";
7+
// import { RivetClient } from "@rivet-gg/api-full";
88

99
const execAsync = promisify(exec);
1010

@@ -22,7 +22,7 @@ if (!RIVET_CLOUD_TOKEN || !RIVET_PROJECT || !RIVET_ENVIRONMENT) {
2222
);
2323
}
2424

25-
export const rivet = new RivetClient({ token: RIVET_CLOUD_TOKEN });
25+
// export const rivet = new RivetClient({ token: RIVET_CLOUD_TOKEN });
2626

2727
export const app = new Hono();
2828

@@ -102,7 +102,10 @@ app.post("/deploy/:appId", async (c) => {
102102
functions: {
103103
[functionName]: {
104104
build_path: "./project/",
105-
dockerfile: "./project/Dockerfile",
105+
dockerfile: "./Dockerfile",
106+
unstable: {
107+
build_method: "remote"
108+
},
106109
build_args: {
107110
// See MY_ENV_VAR build args in Dockerfile
108111
MY_ENV_VAR: "custom env var",
@@ -127,7 +130,7 @@ app.post("/deploy/:appId", async (c) => {
127130

128131
// Run the deploy command
129132
const deployResult = await execAsync(
130-
`rivet deploy --environment ${RIVET_ENVIRONMENT} --non-interactive`,
133+
`~/code/rivet/rivet/target/debug/rivet deploy --environment ${RIVET_ENVIRONMENT} --non-interactive`,
131134
{
132135
cwd: tempDir,
133136
},
@@ -137,7 +140,7 @@ app.post("/deploy/:appId", async (c) => {
137140

138141
// Get the function endpoint
139142
const endpointResult = await execAsync(
140-
`rivet function endpoint --environment prod ${functionName}`,
143+
`~/code/rivet/rivet/target/debug/rivet function endpoint --environment ${RIVET_ENVIRONMENT} ${functionName}`,
141144
{
142145
cwd: tempDir,
143146
},
@@ -151,5 +154,6 @@ app.post("/deploy/:appId", async (c) => {
151154
success: true,
152155
appId,
153156
endpoint: endpointUrl,
157+
buildLog: deployResult.stdout,
154158
});
155159
});

0 commit comments

Comments
 (0)