Skip to content

Commit 24c8baa

Browse files
committed
deploy proxies with pulumi
1 parent 6ac6777 commit 24c8baa

File tree

7 files changed

+467
-18
lines changed

7 files changed

+467
-18
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,5 @@ rlog
5555
qlog.zst
5656
rlog.zst
5757
build
58-
user-content/
58+
user-content/
59+
.env

bun.lock

Lines changed: 400 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

infra/Pulumi.prod.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
encryptionsalt: v1:J3UB8fjbyNQ=:v1:KyaeCMJV7KuyU3lR:CYhKg5G3uz4x0rjolHQX+Ay/A17X0A==
2+
config:
3+
cloudflare:apiKey:
4+
secure: v1:hA/5FY74pHl9BMx9:78l3m77aaDqLpy3kJFZWU2OuFyr80MLnJsDIhvFgyj80YlzFNHVQANP4JGlSuP/hG7VOwOo=
5+
cloudflare:email: nagelkarel@gmail.com

infra/Pulumi.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
name: asius
2+
description: Asius
3+
backend:
4+
url: s3://asius-pulumi?endpoint=558df022e422781a34f239d7de72c8ae.r2.cloudflarestorage.com
5+
runtime:
6+
name: nodejs
7+
options:
8+
packagemanager: bun
9+
config:
10+
pulumi:tags:
11+
value:
12+
pulumi:template: typescript

infra/index.ts

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import * as cloudflare from '@pulumi/cloudflare'
2+
3+
const ACCOUNT_ID = '558df022e422781a34f239d7de72c8ae'
4+
const ZONE_ID = '9dbe2445beeb3c44e991656fada0231c'
5+
6+
const PROXIES = [
7+
{ original: 'api.konik.ai', proxy: 'konik-proxy.new-connect.dev' },
8+
{ original: 'athena.comma.ai', proxy: 'athena-proxy.new-connect.dev' },
9+
{ original: 'billing.comma.ai', proxy: 'billing-proxy.new-connect.dev' },
10+
]
11+
12+
for (const { original, proxy } of PROXIES) {
13+
const name = proxy.replaceAll('.new-connect.dev', '')
14+
const konikProxy = new cloudflare.WorkersScript(name, {
15+
accountId: ACCOUNT_ID,
16+
scriptName: name,
17+
mainModule: 'index.js',
18+
content: `
19+
export default {
20+
fetch: async (request) => {
21+
if (request.method === 'OPTIONS') return new Response(null, { status: 204, headers: HEADERS })
22+
23+
const url = new URL(request.url)
24+
const response = await fetch(new Request('https://${original}' + url.pathname + url.search, request))
25+
const res = new Response(response.body, response)
26+
res.headers.set('Access-Control-Allow-Origin', '*')
27+
res.headers.set('Access-Control-Allow-Methods', '*')
28+
res.headers.set('Access-Control-Allow-Headers', 'Content-Type, User-Agent, Authorization')
29+
res.headers.set('Access-Control-Max-Age', '86400')
30+
return res
31+
},
32+
}`,
33+
})
34+
35+
new cloudflare.WorkersCustomDomain(`${name}-domain`, {
36+
accountId: ACCOUNT_ID,
37+
hostname: proxy,
38+
service: konikProxy.scriptName,
39+
zoneId: ZONE_ID,
40+
})
41+
}
42+
43+
export const projects = {}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@
4949
"@ffmpeg/ffmpeg": "^0.12.15",
5050
"@ffmpeg/util": "^0.12.2",
5151
"@mapbox/polyline": "^1.2.1",
52+
"@pulumi/cloudflare": "^6.12.0",
53+
"@pulumi/hcloud": "^1.29.0",
54+
"@pulumi/pulumi": "^3.213.0",
5255
"@remotion/cli": "4.0.373",
5356
"@remotion/player": "4.0.373",
5457
"@remotion/tailwind": "4.0.373",

src/utils/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import { z } from 'zod'
33
const zString = (def?: string) => (def ? z.string().default(def) : z.string())
44

55
export const Environment = z.object({
6-
ATHENA_URL: zString('https://athena.new-connect.dev'), // Needed cause athena.comma.ai restricts CORS
6+
ATHENA_URL: zString('https://athena-proxy.new-connect.dev'), // Needed cause athena.comma.ai restricts CORS
77
API_URL: zString('https://api.comma.ai'),
88
AUTH_URL: zString('https://api.comma.ai'),
9-
BILLING_URL: zString('https://billing.new-connect.dev'), // Needed cause billing.comma.ai restricts CORS
9+
BILLING_URL: zString('https://billing-proxy.new-connect.dev'), // Needed cause billing.comma.ai restricts CORS
1010
USERADMIN_URL: zString('https://useradmin.comma.ai'),
1111
RENDERER_URL: zString('https://renderer.new-connect.dev'),
1212
TEMPLATES_URL: zString('https://templates.new-connect.dev'),

0 commit comments

Comments
 (0)