1# GCP Website: Astro
2
3Deploys an [Astro](https://astro.build) site to Google Cloud with
4`GCP.Website.Astro`. You don't need an `astro.config.*` adapter or a
5Dockerfile. Alchemy builds the site with Astro's Node target and bakes the
6server plus the client assets into a Node image. It pushes the image to
7Artifact Registry and runs it on a public Cloud Run service.
8
9- `src/pages/index.astro` is server-rendered in the Cloud Run container on
10 every request and reads the `GREETING` environment value declared in
11 `alchemy.run.ts`.
12- `src/pages/about.astro` opts into prerendering
13 (`export const prerender = true`) and is served as a static file.
14- Everything under `public/` is served as static assets.
15
16The integration package must be installed in the project (it is loaded
17dynamically at deploy time):
18
19```sh
20bun add -d @alchemy.run/frontend-frameworks
21```
22
23## Deploy
24
25Credentials come from your alchemy profile: run `alchemy profile` once and
26pick GCP (*Service account JSON* for a key file, or *Stored* for an access
27token or key kept in `~/.alchemy/credentials`, plus a default region), then
28deploy with `--profile <name>`. The service runs in the profile's region.
29
30Docker must be running, because the image is built locally.
31
32From the repository root:
33
34```sh
35pnpm install
36cd examples/gcp-website-astro
37pnpm deploy --profile <name>
38```
39
40The `url` output is the Cloud Run service URL
41(`https://….run.app`). Unchanged sources skip the Astro build and the
42image push on later deploys, because the input files are content-hashed
43(scoped by `memo.include`).
44
45## Local development
46
47```sh
48pnpm dev --profile <name>
49```
50
51`alchemy dev` runs Astro's own dev server with hot reload. It creates no
52Cloud Run service or image.
53
54## Live test
55
56```sh
57ALCHEMY_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
61server-rendered home page, the prerendered page, the Tailwind build, and a
62file from `public/`. At the end it destroys the stack.
63
64## Destroy
65
66```sh
67pnpm destroy --profile <name>
68```
69
70This deletes the Cloud Run service, its Artifact Registry image repository,
71and the service account Alchemy minted for it.