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

main
md 71 lines 2.23 KB
Rendered Raw
1 # GCP Website: Next.js
2
3 Deploys a [Next.js](https://nextjs.org) app to Google Cloud with
4 `GCP.Website.Nextjs`. There is no OpenNext and no Dockerfile. Alchemy runs
5 `next build`, then bakes `.next/`, `public/`, `next.config.mjs`, and a
6 small `next({ dev: false })` server into a Node image, with `next`,
7 `react`, and `react-dom` installed into it. It pushes the image to Artifact
8 Registry and runs it on a public Cloud Run service.
9
10 - `app/page.jsx` is `force-dynamic`, so it is server-rendered in the Cloud
11 Run container on every request and reads the `GREETING` environment
12 value declared in `alchemy.run.ts`.
13 - `app/api/hello/route.ts` is an App Router route handler.
14 - Everything under `public/` is served as static assets. Tailwind compiles
15 through the project's own `postcss.config.mjs`.
16
17 The integration package must be installed in the project (it is loaded
18 dynamically at deploy time):
19
20 ```sh
21 bun add -d @alchemy.run/frontend-frameworks
22 ```
23
24 ## Deploy
25
26 Credentials come from your alchemy profile: run `alchemy profile` once and
27 pick GCP (*Service account JSON* for a key file, or *Stored* for an access
28 token or key kept in `~/.alchemy/credentials`, plus a default region), then
29 deploy with `--profile <name>`. The service runs in the profile's region.
30
31 Docker must be running, because the image is built locally.
32
33 From the repository root:
34
35 ```sh
36 pnpm install
37 cd examples/gcp-website-nextjs
38 pnpm deploy --profile <name>
39 ```
40
41 The `url` output is the Cloud Run service URL (`https://….run.app`).
42 Unchanged sources skip `next build` and the image push on later deploys,
43 because the input files are content-hashed (scoped by `memo.include`).
44
45 ## Local development
46
47 ```sh
48 pnpm dev --profile <name>
49 ```
50
51 `alchemy dev` runs `next dev` with hot reload. It creates no Cloud Run
52 service or image.
53
54 ## Live test
55
56 ```sh
57 ALCHEMY_PROFILE=<name> bun test test/integ.test.ts --timeout 1200000
58 ```
59
60 [The test](./test/integ.test.ts) deploys the stack and checks the
61 server-rendered home page, the API route, the compiled Tailwind stylesheet,
62 and a file from `public/`. At the end it destroys the stack.
63
64 ## Destroy
65
66 ```sh
67 pnpm destroy --profile <name>
68 ```
69
70 This deletes the Cloud Run service, its Artifact Registry image repository,
71 and the service account Alchemy minted for it.