fix(infra): make Render setup bring-your-own-repo

This commit is contained in:
Shivam Sharma committed 2026-08-05 07:34:49 +05:30
1 parent 30262cdb1c
commit 35ebbc4026
4 files changed
+73 -52

No files matched your search

+39 -17
View File
@@ -14,37 +14,59 @@ The root [`render.yaml`](../../render.yaml) creates:
- a Docker web service containing T3 Code, Codex, Claude Code, Git, and the GitHub CLI;
- a persistent disk mounted at `/data` for T3 Code state, provider credentials, and workspaces;
- a health check against T3 Code's public environment descriptor; and
- a five-minute shutdown window so active agent processes have time to stop cleanly.
- a health check against T3 Code's public environment descriptor.
## Deploy
1. In the Render Dashboard, choose **New → Blueprint**.
2. Connect this repository and select the branch you want to deploy.
3. Provide `OPENAI_API_KEY` and `GH_TOKEN` when Render prompts for secret environment variables.
`GH_TOKEN` needs access to any private repositories the environment will clone and permission to
push branches or open pull requests for the demo repository.
4. Deploy the Blueprint and wait for the service health check to pass.
5. Open the service logs and copy the `Pair URL` printed during startup. Treat this URL like a
3. Deploy the Blueprint and wait for the service health check to pass.
4. Open the service logs and copy the `Pair URL` printed during startup. Treat this URL like a
password: it contains a one-time pairing credential.
6. Open the URL in a browser. T3 Code pairs the browser with the Render-hosted environment and opens
the repository configured by `T3CODE_PROJECT_REPO`.
5. Open the URL in a browser. The hosted T3 Code app pairs with the Render environment and saves it
under **Settings → Connections → Remote environments**.
6. Authenticate a provider and source control as described below.
7. Open the Command Palette, choose **Add Project**, and select the Render environment. Clone a
GitHub repository, another supported source-control repository, or any Git URL.
The default repository is T3 Code itself. Change `T3CODE_PROJECT_REPO`, and optionally
`T3CODE_PROJECT_BRANCH`, in the service environment settings to use another repository. The clone is
stored under `/data/workspace/project` and survives deploys.
Repositories are selected after pairing rather than baked into the Blueprint. Each clone is stored
under `/data/workspace` and survives deploys. This keeps the public deployment configuration generic
and lets each user bring repositories they already have access to.
The demo Blueprint is pinned to `feat/render-cloud-environment` so it can deploy before the draft
pull request is merged. Update the `branch` field in `render.yaml` if you rename or reuse the branch.
## Provider Authentication
When `OPENAI_API_KEY` is set, the startup script initializes Codex on the persistent disk before T3
Code starts. Claude Code is installed too; set `ANTHROPIC_API_KEY` in the Render Dashboard to use it.
The Blueprint does not ask for an OpenAI API key. To use a ChatGPT subscription, open a Render Shell
and run:
For subscription authentication instead of an API key, open a Render Shell and run the provider's
normal login command. `CODEX_HOME` and `CLAUDE_CONFIG_DIR` already point at the persistent disk, so
the resulting provider session survives service restarts.
```sh
codex login --device-auth
```
Follow the printed link and enter the device code. `CODEX_HOME` points at the persistent disk, so the
provider session survives service restarts. Claude Code is installed too; use its normal subscription
login flow from a Render Shell. `CLAUDE_CONFIG_DIR` is persisted as well.
## Source-control Authentication
Public repositories can be cloned by URL without authentication. For private GitHub repositories,
add a short-lived, repository-scoped `GH_TOKEN` secret in the Render service environment. Grant only
the access needed for the workflow: read access to clone, or repository contents and pull-request
write access to push branches and open pull requests. The startup script configures Git to use the
token when the service restarts.
Open **Settings → Source Control** and rescan to confirm that GitHub is authenticated. Then use
**Add Project → GitHub repository** to choose the repository. Never commit a token to the Blueprint
or paste one into a project URL.
## T3 Connect
T3 Connect is not required for this deployment. Render already gives the environment a public HTTPS
and WebSocket endpoint, so the Pair URL registers it as a direct remote environment. Use its existing
Connect and Disconnect controls under **Settings → Connections**. T3 Connect remains useful for
machines that need its managed tunnel or account-level environment discovery.
## Operations
+23
View File
@@ -0,0 +1,23 @@
const chunks = [];
for await (const chunk of process.stdin) {
chunks.push(chunk);
}
const issued = JSON.parse(Buffer.concat(chunks).toString("utf8"));
if (typeof issued.credential !== "string" || issued.credential.length === 0) {
throw new Error("Pairing output did not include a credential.");
}
const publicUrl = process.env.T3CODE_PUBLIC_URL?.trim();
if (!publicUrl) {
throw new Error("T3CODE_PUBLIC_URL is required.");
}
const hostedAppUrl = process.env.T3CODE_HOSTED_APP_URL?.trim() || "https://app.t3.codes";
const environmentLabel = process.env.T3CODE_ENVIRONMENT_LABEL?.trim() || "Render cloud agent";
const pairUrl = new URL("/pair", hostedAppUrl);
pairUrl.searchParams.set("host", new URL(publicUrl).origin);
pairUrl.searchParams.set("label", environmentLabel);
pairUrl.hash = new URLSearchParams([["token", issued.credential]]).toString();
process.stdout.write(`Pair URL: ${pairUrl.toString()}\n`);
+10 -28
View File
@@ -4,6 +4,7 @@ set -eu
script_dir="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)"
app_root="$(CDPATH= cd -- "$script_dir/../.." && pwd)"
t3_entry="$app_root/apps/server/dist/bin.mjs"
pair_url_entry="$script_dir/pair-url.mjs"
t3() {
node "$t3_entry" "$@"
@@ -12,7 +13,6 @@ t3() {
port="${PORT:-10000}"
t3_home="${T3CODE_HOME:-/data/t3}"
workspace_dir="${T3CODE_WORKSPACE_DIR:-/data/workspace}"
project_dir="${T3CODE_PROJECT_DIR:-$workspace_dir/project}"
codex_home="${CODEX_HOME:-/data/codex}"
claude_config_dir="${CLAUDE_CONFIG_DIR:-/data/claude}"
public_url="${T3CODE_PUBLIC_URL:-${RENDER_EXTERNAL_URL:-}}"
@@ -27,41 +27,23 @@ if [ -n "${GH_TOKEN:-}" ]; then
gh auth setup-git
fi
if [ -n "${OPENAI_API_KEY:-}" ]; then
printf '%s' "$OPENAI_API_KEY" | codex login --with-api-key
fi
working_dir="$workspace_dir"
if [ -n "${T3CODE_PROJECT_REPO:-}" ]; then
if [ ! -d "$project_dir/.git" ]; then
if [ -d "$project_dir" ] && [ -n "$(find "$project_dir" -mindepth 1 -maxdepth 1 -print -quit)" ]; then
echo "T3CODE_PROJECT_DIR exists and is not an empty Git repository: $project_dir" >&2
exit 1
fi
if [ -n "${T3CODE_PROJECT_BRANCH:-}" ]; then
git clone --branch "$T3CODE_PROJECT_BRANCH" --single-branch "$T3CODE_PROJECT_REPO" "$project_dir"
else
git clone "$T3CODE_PROJECT_REPO" "$project_dir"
fi
fi
working_dir="$project_dir"
fi
if [ -n "$public_url" ]; then
t3 auth pairing create \
pairing_json="$(t3 auth pairing create \
--base-dir "$t3_home" \
--base-url "$public_url" \
--label "Render startup" \
--ttl "$pairing_ttl"
--ttl "$pairing_ttl" \
--json)"
printf '%s' "$pairing_json" | \
T3CODE_PUBLIC_URL="$public_url" \
node "$pair_url_entry"
else
echo "Set T3CODE_PUBLIC_URL to print a public pairing link at startup." >&2
fi
cd "$workspace_dir"
exec node "$t3_entry" start \
--host 0.0.0.0 \
--port "$port" \
--base-dir "$t3_home" \
--no-browser \
--auto-bootstrap-project-from-cwd \
"$working_dir"
--no-browser
+1 -7
View File
@@ -3,22 +3,16 @@ services:
name: t3code-cloud-demo
runtime: docker
plan: starter
repo: https://github.com/pingdotgg/t3code.git
branch: feat/render-cloud-environment
autoDeployTrigger: commit
dockerfilePath: ./infra/render/Dockerfile
dockerContext: .
healthCheckPath: /.well-known/t3/environment
maxShutdownDelaySeconds: 300
disk:
name: t3code-data
mountPath: /data
sizeGB: 10
envVars:
- key: T3CODE_PROJECT_REPO
value: https://github.com/pingdotgg/t3code.git
- key: T3CODE_PAIRING_TTL
value: 24h
- key: OPENAI_API_KEY
sync: false
- key: GH_TOKEN
sync: false