The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 06:00 UTC
| 1 | --- |
| 2 | title: Foldkit |
| 3 | description: Deploy a Foldkit app to Cloud Run with GCP.Website.Foldkit — a Vite build with deep links that boot the app. |
| 4 | sidebar: |
| 5 | order: 6 |
| 6 | --- |
| 7 | |
| 8 | import PackageManagers from "../../../../components/PackageManagers.astro"; |
| 9 | |
| 10 | export const devDeps = "@alchemy.run/frontend-frameworks"; |
| 11 | |
| 12 | `GCP.Website.Foldkit` deploys a [Foldkit](https://foldkit.dev) app to |
| 13 | Cloud Run. It is [`Vite`](/gcp/frontend/vite) with single-page routing |
| 14 | turned on, so a deep link loads `index.html` and boots the app. |
| 15 | |
| 16 | ## Install |
| 17 | |
| 18 | The build integration ships separately. It only runs at deploy time, |
| 19 | so a dev dependency is enough: |
| 20 | |
| 21 | <PackageManagers dev={devDeps} /> |
| 22 | |
| 23 | Docker has to be running when you deploy. The image is built on your |
| 24 | machine. |
| 25 | |
| 26 | ## Deploy the site |
| 27 | |
| 28 | ```typescript |
| 29 | // alchemy.run.ts |
| 30 | import * as Alchemy from "alchemy"; |
| 31 | import * as GCP from "@alchemy.run/gcp"; |
| 32 | import * as Effect from "effect/Effect"; |
| 33 | |
| 34 | export const Website = GCP.Website.Foldkit("Website"); |
| 35 | |
| 36 | export default Alchemy.Stack( |
| 37 | "MySite", |
| 38 | { providers: GCP.providers(), state: GCP.state() }, |
| 39 | Effect.gen(function* () { |
| 40 | const site = yield* Website; |
| 41 | return { url: site.url }; |
| 42 | }), |
| 43 | ); |
| 44 | ``` |
| 45 | |
| 46 | Run `alchemy deploy`. `site.url` is the Cloud Run service URL. |
| 47 | |
| 48 | ## Project in a subdirectory |
| 49 | |
| 50 | ```typescript |
| 51 | export const Website = GCP.Website.Foldkit("Website", { |
| 52 | rootDir: "applications/web", |
| 53 | }); |
| 54 | ``` |
| 55 | |
| 56 | ## Serve a real 404 page |
| 57 | |
| 58 | ```typescript |
| 59 | export const Website = GCP.Website.Foldkit("Website", { |
| 60 | assets: { notFoundHandling: "404-page" }, |
| 61 | }); |
| 62 | ``` |
| 63 | |
| 64 | ## Tune Cloud Run |
| 65 | |
| 66 | ```typescript |
| 67 | export const Website = GCP.Website.Foldkit("Website", { |
| 68 | scaling: { minInstanceCount: 1 }, |
| 69 | resources: { limits: { cpu: "1", memory: "1Gi" } }, |
| 70 | }); |
| 71 | ``` |
| 72 | |
| 73 | One warm instance means no cold start for the first visitor. See |
| 74 | [Websites](/gcp/frontend/websites#tune-cloud-run) for the other |
| 75 | settings. |
| 76 | |
| 77 | ## Local development |
| 78 | |
| 79 | `alchemy dev` runs the framework's dev server with hot reload and |
| 80 | creates nothing in the cloud. Wrap the site in `Alchemy.remote()` to |
| 81 | deploy it for real during dev. |
| 82 | |
| 83 | ## Where next |
| 84 | |
| 85 | - [Websites](/gcp/frontend/websites) — the settings every site shares. |
| 86 | - [Website reference](/providers/gcp/website#foldkit) — every prop. |