The best way to control Claude Code, Codex and more from any computer or phone

main
mdx 138 lines 4.2 KB
Raw
1 ---
2 title: Websites
3 description: Deploy Vite, Astro, Next.js, Nuxt, SvelteKit, TanStack Start, React Router, SolidStart, Waku, vinext, Octane, Vocs, or any static build to Cloud Run with GCP.Website.
4 sidebar:
5 label: Overview
6 order: 1
7 ---
8
9 import PackageManagers from "../../../../components/PackageManagers.astro";
10
11 export const devDeps = "@alchemy.run/frontend-frameworks";
12
13 `GCP.Website` deploys a frontend to Cloud Run. Each resource runs your
14 framework's build, bakes the server and the static files into one Node
15 image, and serves it from a public Cloud Run service. There is no
16 Dockerfile and no adapter to install. Your framework's own config file
17 loads as-is.
18
19 ```typescript
20 // alchemy.run.ts
21 import * as Alchemy from "alchemy";
22 import * as GCP from "@alchemy.run/gcp";
23 import * as Effect from "effect/Effect";
24
25 export default Alchemy.Stack(
26 "MySite",
27 { providers: GCP.providers(), state: GCP.state() },
28 Effect.gen(function* () {
29 const site = yield* GCP.Website.Astro("Website");
30 return { url: site.url };
31 }),
32 );
33 ```
34
35 `site.url` is the service's `https://….run.app` URL.
36
37 ## Install
38
39 The build integration ships separately. It only runs at deploy time,
40 so a dev dependency is enough:
41
42 <PackageManagers dev={devDeps} />
43
44 Docker has to be running when you deploy. The image is built on your
45 machine.
46
47 ## Pick your framework
48
49 | Framework | Resource | Guide |
50 | --- | --- | --- |
51 | React / Vite SPA | `Vite` | [React SPA](/gcp/frontend/vite-spa) |
52 | Vue | `Vite` | [Vue](/gcp/frontend/vue) |
53 | Any Vite app | `Vite` | [Vite](/gcp/frontend/vite) |
54 | Foldkit | `Foldkit` | [Foldkit](/gcp/frontend/foldkit) |
55 | Astro | `Astro` | [Astro](/gcp/frontend/astro) |
56 | Next.js | `Nextjs` | [Next.js](/gcp/frontend/nextjs) |
57 | vinext | `Vinext` | [vinext](/gcp/frontend/vinext) |
58 | Nuxt | `Nuxt` | [Nuxt](/gcp/frontend/nuxt) |
59 | SvelteKit | `SvelteKit` | [SvelteKit](/gcp/frontend/sveltekit) |
60 | TanStack Start | `TanStackStart` | [TanStack Start](/gcp/frontend/tanstack-start) |
61 | React Router | `ReactRouter` | [React Router](/gcp/frontend/react-router) |
62 | SolidStart | `SolidStart` | [SolidStart](/gcp/frontend/solidstart) |
63 | Waku | `Waku` | [Waku](/gcp/frontend/waku) |
64 | Octane | `Octane` | [Octane](/gcp/frontend/octane) |
65 | Vocs | `Vocs` | [Vocs](/gcp/frontend/vocs) |
66 | Hugo, Zola, any static generator | `StaticSite` | [Static sites](/gcp/frontend/static-site) |
67
68 Use the resource named after your framework. Use `Vite` for a
69 client-only app. Use `StaticSite` for any build command that writes a
70 directory of files.
71
72 ## Pass environment variables
73
74 `env` sets the server's environment. Values can be Outputs from other
75 resources:
76
77 ```typescript
78 const site = yield* GCP.Website.Nuxt("Website", {
79 env: {
80 GREETING: "Hello from Cloud Run!",
81 API_URL: api.uri,
82 },
83 });
84 ```
85
86 Server code reads them from `process.env`.
87
88 ## Tune Cloud Run
89
90 Every site takes the same Cloud Run settings:
91
92 ```typescript
93 const site = yield* GCP.Website.Nextjs("Website", {
94 scaling: { minInstanceCount: 1 },
95 resources: { limits: { cpu: "1", memory: "1Gi" } },
96 timeout: "60s",
97 });
98 ```
99
100 `minInstanceCount: 1` keeps one instance warm, so the first visitor
101 never waits for a cold start.
102
103 ## Make it private
104
105 Sites are public by default. Set `public: false` to require a Google
106 identity token, for an internal tool behind
107 [IAP](https://cloud.google.com/iap) or a load balancer:
108
109 ```typescript
110 const site = yield* GCP.Website.Vite("Admin", { public: false });
111 ```
112
113 ## Skip unchanged builds
114
115 Alchemy hashes your project's files and skips the build and the image
116 push when nothing changed. Limit the hash to the files that matter:
117
118 ```typescript
119 const site = yield* GCP.Website.Astro("Website", {
120 memo: {
121 include: ["src/**", "public/**", "package.json", "astro.config.ts"],
122 },
123 });
124 ```
125
126 ## Local development
127
128 `alchemy dev` runs your framework's own dev server with hot reload and
129 creates nothing in the cloud. `site.url` is the local address. Wrap the
130 site in `Alchemy.remote()` to deploy it for real during dev.
131
132 ## Where next
133
134 - [Astro](/gcp/frontend/astro) and [Next.js](/gcp/frontend/nextjs) —
135 both have runnable examples.
136 - [Static sites](/gcp/frontend/static-site) — a build command, or a
137 public Cloud Storage bucket.
138 - [Website reference](/providers/gcp/website) — every prop.