refactor(cloud): keep relay infra config unprefixed

Co-authored-by: codex <[email protected]>
This commit is contained in:
Julius Marmingeandcodex committed 2026-06-03 23:48:05 -07:00
1 parent cc24a99047
commit c48c560457
9 files changed
+78 -28

No files matched your search

+3 -3
View File
@@ -29,9 +29,9 @@ jobs:
PLANETSCALE_ORGANIZATION: ${{ vars.PLANETSCALE_ORGANIZATION }}
AXIOM_TOKEN: ${{ secrets.AXIOM_TOKEN }}
AXIOM_ORG_ID: ${{ vars.AXIOM_ORG_ID }}
T3CODE_RELAY_DOMAIN: ${{ vars.T3CODE_RELAY_DOMAIN }}
T3CODE_RELAY_ZONE_NAME: ${{ vars.T3CODE_RELAY_ZONE_NAME }}
T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }}
RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
RELAY_ZONE_NAME: ${{ vars.RELAY_ZONE_NAME }}
CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
APNS_ENVIRONMENT: ${{ vars.APNS_ENVIRONMENT }}
APNS_TEAM_ID: ${{ vars.APNS_TEAM_ID }}
+6 -6
View File
@@ -178,8 +178,8 @@ jobs:
clerk_publishable_key: ${{ steps.public_config.outputs.clerk_publishable_key }}
relay_url: ${{ steps.public_config.outputs.relay_url }}
env:
T3CODE_RELAY_DOMAIN: ${{ vars.T3CODE_RELAY_DOMAIN }}
T3CODE_CLERK_PUBLISHABLE_KEY: ${{ vars.T3CODE_CLERK_PUBLISHABLE_KEY }}
RELAY_DOMAIN: ${{ vars.RELAY_DOMAIN }}
CLERK_PUBLISHABLE_KEY: ${{ vars.CLERK_PUBLISHABLE_KEY }}
steps:
- id: public_config
name: Resolve production relay public config
@@ -188,8 +188,8 @@ jobs:
set -euo pipefail
required=(
T3CODE_RELAY_DOMAIN
T3CODE_CLERK_PUBLISHABLE_KEY
RELAY_DOMAIN
CLERK_PUBLISHABLE_KEY
)
missing=()
for name in "${required[@]}"; do
@@ -202,8 +202,8 @@ jobs:
exit 1
fi
echo "clerk_publishable_key=$T3CODE_CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
echo "relay_url=https://$T3CODE_RELAY_DOMAIN" >> "$GITHUB_OUTPUT"
echo "clerk_publishable_key=$CLERK_PUBLISHABLE_KEY" >> "$GITHUB_OUTPUT"
echo "relay_url=https://$RELAY_DOMAIN" >> "$GITHUB_OUTPUT"
build:
name: Build ${{ matrix.label }}
+4 -4
View File
@@ -56,10 +56,10 @@ Required repository secrets shared by relay deployments:
Required `production` environment variables:
- `T3CODE_RELAY_DOMAIN`
- `T3CODE_RELAY_ZONE_NAME`
- `T3CODE_CLERK_PUBLISHABLE_KEY`
- `T3CODE_CLERK_CLI_OAUTH_CLIENT_ID`
- `RELAY_DOMAIN`
- `RELAY_ZONE_NAME`
- `CLERK_PUBLISHABLE_KEY`
- `CLERK_CLI_OAUTH_CLIENT_ID`
- `APNS_ENVIRONMENT`
- `APNS_TEAM_ID`
- `APNS_KEY_ID`
+4 -4
View File
@@ -34,11 +34,11 @@ client-facing values in their EAS environment.
When either public value is absent, cloud UI is omitted.
For a hosted relay deployment, copy `infra/relay/.env.example` to `infra/relay/.env`. The relay
deployment reads `T3CODE_RELAY_DOMAIN`, `T3CODE_RELAY_ZONE_NAME`, and
`T3CODE_CLERK_PUBLISHABLE_KEY` through Effect `Config`. There are no checked-in deployment defaults.
deployment reads `RELAY_DOMAIN`, `RELAY_ZONE_NAME`, and `CLERK_PUBLISHABLE_KEY` through Effect
`Config`. There are no checked-in deployment defaults.
`bun --cwd infra/relay run deploy` invokes Alchemy from the relay directory, so Alchemy loads
`infra/relay/.env`. After a successful deployment, the wrapper updates the repository-root `.env`
with the HTTPS relay URL derived from `T3CODE_RELAY_DOMAIN`. The relay still requires
with the HTTPS relay URL derived from `RELAY_DOMAIN`. The relay still requires
`CLERK_SECRET_KEY` as an Alchemy secret. Never put `CLERK_SECRET_KEY` in a client application
environment or commit it to the repository.
@@ -56,7 +56,7 @@ In **Clerk Dashboard > JWT templates**, create a template with:
| Claims | `{ "aud": "https://relay.example.com" }` |
The `aud` value must be the deployed relay public URL, with no trailing slash. It must match the
client-facing `T3CODE_RELAY_URL` and the HTTPS URL derived from the deployment's `T3CODE_RELAY_DOMAIN`. If
client-facing `T3CODE_RELAY_URL` and the HTTPS URL derived from the deployment's `RELAY_DOMAIN`. If
the relay domain changes, update both values and the JWT template.
## Desktop OAuth Redirect Allowlist
+3 -3
View File
@@ -1,15 +1,15 @@
# Required: Relay domain
# Use the DNS zone managed in your Cloudflare account. Production deploys use
# relay.<zone>; personal stages use relay-<stage>.<zone>.
T3CODE_RELAY_ZONE_NAME=example.com
RELAY_ZONE_NAME=example.com
# Optional: Relay domain override
# Set this only when the derived relay hostname should not be used.
# T3CODE_RELAY_DOMAIN=relay.example.com
# RELAY_DOMAIN=relay.example.com
# Required: Clerk
# Get both values from the Clerk Dashboard under API keys.
T3CODE_CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_PUBLISHABLE_KEY=pk_test_...
CLERK_SECRET_KEY=sk_test_...
# Required: Apple Push Notification service
+5 -5
View File
@@ -100,8 +100,8 @@ bun --cwd infra/relay run deploy -- --env-file .env.local
Alchemy defaults personal deployments to the `dev_$USER` stage. Relay custom domains apply the same
DNS-safe sanitization as Alchemy physical resource names, so `prod` uses
`relay.<T3CODE_RELAY_ZONE_NAME>` and `dev_julius` uses `relay-dev-julius.<T3CODE_RELAY_ZONE_NAME>`.
`T3CODE_RELAY_DOMAIN` remains available as an explicit override.
`relay.<RELAY_ZONE_NAME>` and `dev_julius` uses `relay-dev-julius.<RELAY_ZONE_NAME>`.
`RELAY_DOMAIN` remains available as an explicit override.
After a successful deploy, the wrapper updates the repository-root `.env` file with the derived relay
URL. That makes subsequent source builds point at the relay that was just deployed without copying
@@ -130,9 +130,9 @@ The repository must define these Actions secrets shared by relay deployments:
The `production` GitHub environment must define these Actions variables:
- `T3CODE_RELAY_ZONE_NAME`
- `T3CODE_RELAY_DOMAIN` if overriding the derived production relay domain
- `T3CODE_CLERK_PUBLISHABLE_KEY`
- `RELAY_ZONE_NAME`
- `RELAY_DOMAIN` if overriding the derived production relay domain
- `CLERK_PUBLISHABLE_KEY`
- `APNS_ENVIRONMENT`
- `APNS_TEAM_ID`
- `APNS_KEY_ID`
+1 -1
View File
@@ -129,7 +129,7 @@ export default class Api extends Cloudflare.Worker<Api>()(
const axiomTracesEndpoint = yield* observability.traces.otelTracesEndpoint;
const clerkSecretKey = yield* Config.redacted("CLERK_SECRET_KEY");
const clerkPublishableKey = yield* Config.string("T3CODE_CLERK_PUBLISHABLE_KEY");
const clerkPublishableKey = yield* Config.string("CLERK_PUBLISHABLE_KEY");
const cloudMintPrivateKey = yield* cloudMintKeyPair.privateKey;
const cloudMintPublicKey = yield* cloudMintKeyPair.publicKey;
+50
View File
@@ -0,0 +1,50 @@
import * as Alchemy from "alchemy";
import * as ConfigProvider from "effect/ConfigProvider";
import * as Effect from "effect/Effect";
import * as Layer from "effect/Layer";
import { describe, expect, it } from "vitest";
import { RelayDeploymentConfig } from "./zone.ts";
function resolveRelayDeploymentConfig(env: Record<string, string>, stage = "prod") {
return Effect.runPromise(
RelayDeploymentConfig.pipe(
Effect.provide(
Layer.mergeAll(
Layer.succeed(Alchemy.Stage, stage),
ConfigProvider.layer(ConfigProvider.fromEnv({ env })),
),
),
),
);
}
describe("RelayDeploymentConfig", () => {
it("derives the relay domain from the unprefixed zone name", async () => {
await expect(resolveRelayDeploymentConfig({ RELAY_ZONE_NAME: "example.com" })).resolves.toEqual(
{
stage: "prod",
relayPublicDomain: "relay.example.com",
relayPublicOrigin: "https://relay.example.com",
managedEndpointZoneName: "example.com",
},
);
});
it("uses the unprefixed relay domain override", async () => {
await expect(
resolveRelayDeploymentConfig(
{
RELAY_ZONE_NAME: "example.com",
RELAY_DOMAIN: "relay.custom.example",
},
"dev_julius",
),
).resolves.toEqual({
stage: "dev_julius",
relayPublicDomain: "relay.custom.example",
relayPublicOrigin: "https://relay.custom.example",
managedEndpointZoneName: "example.com",
});
});
});
+2 -2
View File
@@ -9,8 +9,8 @@ import { relayPublicDomainForStage } from "./deploymentConfig.ts";
export const RelayDeploymentConfig = Effect.gen(function* () {
const stage = yield* Alchemy.Stage;
const managedEndpointZoneName = yield* Config.nonEmptyString("T3CODE_RELAY_ZONE_NAME");
const relayPublicDomainOverride = yield* Config.nonEmptyString("T3CODE_RELAY_DOMAIN").pipe(
const managedEndpointZoneName = yield* Config.nonEmptyString("RELAY_ZONE_NAME");
const relayPublicDomainOverride = yield* Config.nonEmptyString("RELAY_DOMAIN").pipe(
Config.option,
);
const relayPublicDomain = Option.getOrElse(relayPublicDomainOverride, () =>