Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions apps/docs/content/docs/cli/service.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ Promotion rebuilds the version with production environment variables, so configu

## service domain

Use `service domain` commands to manage custom domains for a service. All commands take a `<hostname>` argument plus the usual service and project selectors and a `--branch <name>` scope. Domains target the production branch by default. See [Domains](/compute/domains) for details.
Use `service domain` commands to manage custom domains for a service. All commands take a `<hostname>` argument plus the usual service and project selectors and a `--branch <name>` scope. Without `--branch`, they pick a branch the same way as other `service` commands; see [How the CLI picks a branch](/compute/branching#how-the-cli-picks-a-branch). See [Domains](/compute/domains) for details.

| Command | Description |
| ---------------------------------- | --------------------------------------------------------------- |
| `service domain add <hostname>` | Add a custom domain to the service and print the DNS records to publish. Succeeds before DNS is set up |
| `service domain show <hostname>` | Show the domain's state, the DNS records still to publish, and certificate details |
| `service domain wait <hostname>` | Wait until the domain's state is `active`, or stop at once when its certificate failed or its service was deleted (`--timeout <duration>`, default 15m) |
| `service domain retry <hostname>` | Check the domain's DNS again and retry a failed certificate |
| `service domain show <hostname>` | Show the custom domain's state, the DNS records still to publish, and certificate details |
| `service domain wait <hostname>` | Wait until the custom domain's state is `active`, or stop at once when its certificate failed or its service was deleted (`--timeout <duration>`, default 15m) |
| `service domain retry <hostname>` | Check the custom domain's DNS again and retry a failed certificate |
| `service domain delete <hostname>` | Permanently delete a custom domain from the service (`--confirm <hostname>` skips the prompt) |
2 changes: 1 addition & 1 deletion apps/docs/content/docs/composer/deploying.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default module('shop', ({ environment, provision }) => {
- `target`: the raw HTTP interface the service exposes, here `web.http`, declared as `expose: { http: rawHttpContract }` with `rawHttpContract` from `@prisma/composer/http`. An RPC interface fails the type check.
- `url`: which hostname serves the service. It is required. `publicUrl.prismaBuild()` serves the service at the `prisma.build` hostname the platform gives every service. `publicUrl.hostname('shop.com')`, or the bare string `'shop.com'`, attaches that hostname to the service as a custom domain. `url` can be a value from `resolve()`, so each environment can get its own hostname.

Before the deploy can attach a named hostname, two DNS records must be published: a TXT record at `_prisma-verification.<hostname>` with your workspace's verification value, and a CNAME record that points the hostname at the platform. Without them the deploy fails with the platform's error, such as `domain-ownership-required`. In Composer 0.37, a named hostname works only in production; use `publicUrl.prismaBuild()` in every other environment.
Before the deploy can attach a named hostname, two DNS records must be published: a TXT record at `_prisma-verification.<hostname>` with your workspace's verification value, and a CNAME record that points the hostname at the platform. Without them the deploy fails with the platform's error, such as `domain-ownership-required`.

`prisma dev` ignores named hostnames and serves every service on its local URL. Today the platform still gives every service a `prisma.build` hostname, so a service with no public URL is reachable there too; declare a public URL for each service the internet should reach, so your code does not change when that hostname becomes opt-in.

Expand Down
1 change: 0 additions & 1 deletion apps/docs/content/docs/composer/limitations.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ This page lists what Prisma Composer does not do yet, so you can plan around a g
- **The control API needs a service token.** `prisma deploy` on your machine uses your `auth login` session, but the in-process operations in `@prisma/composer/control` (including `destroy`) do not read it: export `PRISMA_SERVICE_TOKEN` and `PRISMA_WORKSPACE_ID` first. See [Credentials](/composer/deploying#credentials).
- **Deploys do not build.** `deploy` assembles your built output; the build is always yours to run first.
- **One `effect` version per app.** `@prisma/composer` pins the `effect` version its deploy engine needs, so you do not pin it yourself. If your app or another dependency brings in a different `effect`, the CLI cannot evaluate `prisma.config.ts`; see [When prisma.config.ts fails on an effect version conflict](/composer/deploying#when-prismaconfigts-fails-on-an-effect-version-conflict).
- **A named hostname works only in production.** In every other environment, serve a [public URL](/composer/deploying#make-a-service-public) with `publicUrl.prismaBuild()`.

## Platforms

Expand Down
44 changes: 23 additions & 21 deletions apps/docs/content/docs/compute/alchemy.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10,40 +10,40 @@ toc: true

Use [Alchemy](https://alchemy.run/) to create Prisma Postgres databases and deploy applications to Prisma Compute from one `alchemy.run.ts` file.

[Alchemy docs](https://alchemy.run/prisma/) · [GitHub](https://github.com/alchemy-run/alchemy) · [Provider source](https://github.com/alchemy-run/alchemy/tree/main/packages/alchemy/src/Prisma) · [TanStack Start example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-tanstack-start) · [npm](https://www.npmjs.com/package/alchemy)
[Alchemy docs](https://alchemy.run/prisma/) · [GitHub](https://github.com/alchemy-run/alchemy) · [Provider source](https://github.com/alchemy-run/alchemy/tree/main/packages/prisma/src) · [TanStack Start example](https://github.com/alchemy-run/alchemy/tree/main/examples/prisma-tanstack-start) · [npm](https://www.npmjs.com/package/@alchemy.run/prisma)

## Deploy Postgres and Compute

### 1. Install and authenticate

```npm title="Terminal"
npm install alchemy@next effect@beta @effect/platform-bun@beta @effect/platform-node@beta
npm install alchemy @alchemy.run/prisma effect @effect/platform-bun @effect/platform-node
printf '\n.alchemy/\n' >> .gitignore
```

Create a Prisma [service token](/rest-api/authentication#service-tokens), then choose how Alchemy should read it.
The second line keeps Alchemy's local state, which can contain database credentials, out of Git. The Prisma provider for Alchemy is the `@alchemy.run/prisma` package.

To store the token in your local Alchemy profile:
Create a Prisma [service token](/rest-api/authentication#service-tokens), then save it in your Alchemy profile, the local store of credentials that Alchemy reads on every run:

```npm title="Terminal"
npx alchemy login --configure
npx alchemy profile edit --add Prisma
```

Choose **Service Token** for Prisma and paste the token when prompted. Alchemy stores it under `~/.alchemy/credentials/<profile>/`.
Paste the token when prompted, and Alchemy stores it under `~/.alchemy/credentials/`.

For CI or an ephemeral shell, choose **Environment Variable** and export the token before running Alchemy:
For CI or an ephemeral shell, export the token before running Alchemy instead:

```bash title="Terminal"
export PRISMA_SERVICE_TOKEN="<your-service-token>"
```

If the profile uses **Environment Variable**, `alchemy login` only verifies that the variable is available. Run `alchemy login --configure` to switch the profile to a stored token.
When `PRISMA_SERVICE_TOKEN` is set, Alchemy uses it in place of the token stored in your profile. In CI (`CI=true`), Alchemy reads the token only from the environment.

### 2. Create the stack

```ts title="alchemy.run.ts"
import * as Alchemy from "alchemy";
import * as Prisma from "alchemy/Prisma";
import * as Prisma from "@alchemy.run/prisma";
import * as Effect from "effect/Effect";

export default Alchemy.Stack(
Expand Down Expand Up @@ -79,7 +79,7 @@ export default Alchemy.Stack(
);
```

`build: "auto"` detects and builds Bun, Next.js, Nuxt, Astro, TanStack Start, and NestJS applications from the current directory. It expects deployable server output: Next.js needs standalone output, Astro needs the Node adapter in standalone mode, and TanStack Start needs its Nitro deployment adapter (`bunx @tanstack/cli@latest add nitro`). Plain Bun servers must listen on `process.env.PORT` and bind to `0.0.0.0`.
`build: "auto"` detects and builds Bun, Next.js, Nuxt, Astro, TanStack Start, Vite, and NestJS applications from the current directory. A plain Vite project deploys as a static single-page app. The other frameworks need deployable server output: Next.js needs standalone output, Astro needs the Node adapter in standalone mode, and TanStack Start needs its Nitro deployment adapter (`bunx @tanstack/cli@latest add nitro`). Plain Bun servers must listen on `process.env.PORT` and bind to `0.0.0.0`.

Alchemy provisions the database but does not infer or run production schema migrations. For Prisma ORM 7, pass `connection.directConnectionString` to the migration process as `DIRECT_URL` and read it from `prisma.config.ts`:

Expand Down Expand Up @@ -213,7 +213,9 @@ return {
};
```

Your application must return a successful response from the configured health-check path before promotion. Add the returned `dnsRecords` at your DNS provider to activate the custom domain. Custom domains can only attach to applications on the project's default branch.
Your application must return a successful response from the configured health-check path before Compute sends traffic to the new deployment. Add the `dnsRecords` the stack prints at your DNS provider to activate the custom domain.

A custom domain can attach to an application on any [branch](/compute/branching) of the Prisma project, not only production. `Prisma.Compute` deploys to the project's default branch, which serves production. To deploy to another branch, and give it its own domain, set `branchGitName` to that branch's name, such as `branchGitName: "staging"`.

## CI and cleanup

Expand All @@ -232,13 +234,13 @@ Destroying the stack deletes the Prisma project and everything inside it, includ

## API reference

- [`Prisma.Project`](https://alchemy.run/providers/prisma/project/)
- [`Prisma.Branch`](https://alchemy.run/providers/prisma/branch/)
- [`Prisma.Database` and `Prisma.Postgres`](https://alchemy.run/providers/prisma/database/)
- [`Prisma.Connection`](https://alchemy.run/providers/prisma/connection/)
- [`Prisma.Compute`](https://alchemy.run/providers/prisma/compute/)
- [`Prisma.App`](https://alchemy.run/providers/prisma/app/)
- [`Prisma.Deployment`](https://alchemy.run/providers/prisma/deployment/)
- [`Prisma.CustomDomain`](https://alchemy.run/providers/prisma/customdomain/)
- [`Prisma.EnvironmentVariable`](https://alchemy.run/providers/prisma/environmentvariable/)
- [`Prisma.SourceRepository`](https://alchemy.run/providers/prisma/sourcerepository/)
- [`Prisma.Project`](https://alchemy.run/providers/prisma/reference/project/#project)
- [`Prisma.Branch`](https://alchemy.run/providers/prisma/reference/project/#branch)
- [`Prisma.Database` and `Prisma.Postgres`](https://alchemy.run/providers/prisma/reference/postgres/#database)
- [`Prisma.Connection`](https://alchemy.run/providers/prisma/reference/postgres/#connection)
- [`Prisma.Compute`](https://alchemy.run/providers/prisma/reference/compute/#compute)
- [`Prisma.App`](https://alchemy.run/providers/prisma/reference/compute/#app)
- [`Prisma.Deployment`](https://alchemy.run/providers/prisma/reference/compute/#deployment)
- [`Prisma.CustomDomain`](https://alchemy.run/providers/prisma/reference/compute/#customdomain)
- [`Prisma.EnvironmentVariable`](https://alchemy.run/providers/prisma/reference/compute/#environmentvariable)
- [`Prisma.SourceRepository`](https://alchemy.run/providers/prisma/reference/compute/#sourcerepository)
12 changes: 4 additions & 8 deletions apps/docs/content/docs/compute/branching.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,16 @@ With [deploy on push](/compute/deploy-on-push) set up, a staging environment is
| **What a push does** | Deploys or updates that branch's preview | Updates the same environment in place | Deploys production |
| **Database** | For databases declared in the [Prisma Composer](/composer) module, its own new database; production data is not copied | Same as a preview | The production database |
| **Variables** | Preview-scoped values | Preview-scoped values plus branch overrides (`--branch staging`) | Production values |
| **URL** | Generated, printed in the deploy report | Generated, printed in the deploy report | Generated; custom domains attach here only |
| **URL** | Generated, printed in the deploy report | Generated, printed in the deploy report | Generated |
| **Teardown** | Deleting the Git branch removes it | Deleting the Git branch removes it | Automated cleanup never touches it |

A [custom domain](/compute/domains#a-custom-domain-on-another-branch) can point at a service in any of the three.

If the app reads `DATABASE_URL`, a preview or staging environment is only as separate as that value. Without GitHub, `npx prisma deploy --environment staging` creates a staging environment from your terminal or another CI system; see [Deploying](/composer/deploying#environments).

## How the CLI picks a branch

Commands that take a branch resolve it in this order:

1. `--branch <name>`, if you pass it.
2. Your active Git branch.
3. `main`.

Inside a Git repo, running `service list` from `feature/search` targets the `feature/search` branch automatically. To target a branch explicitly:
Pass `--branch <name>` to choose a branch. Without it, `service` commands use the project's default branch. They never read your current Git branch:

```npm
npx prisma service list --branch feature/search
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/compute/deploy-on-push.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This guide sets that up for a [Prisma Composer](/composer) app that you deploy t

When the workflow from this guide runs, each Git branch you push, other than the default one, becomes its own environment next to production. The preview gets the following, separate from production:

- **Its own deployment and URL.** The deploy action deploys the branch as a preview named after it, and the workflow run prints the preview's URL in its deploy report. Custom domains attach to production only, so a preview is reached at its generated URL.
- **Its own deployment and URL.** The deploy action deploys the branch as a preview named after it, and the workflow run prints the preview's URL in its deploy report.
- **The whole app, not only the frontend.** Every service your module declares, such as a frontend and an API, runs in the preview as its own service. The services, databases and buckets your module declares are separate from production; anything the app reaches through an environment variable, such as a database at `DATABASE_URL` or an API at `API_BASE_URL`, is only as separate as that variable's preview-scoped value, so check those values too.
- **Preview environment variables.** Every preview reads the preview-scoped values, and a branch override changes a value for one branch; production values are used only by production. See [Environment variables](/compute/environment-variables).
- **Its own databases.** Each Prisma Postgres database your module declares is created for the branch, so what you write in the preview stays out of the production database. Production data is not copied into it; [What a preview database starts with](#what-a-preview-database-starts-with) lists what is in it. If the app reads its connection string from a variable such as `DATABASE_URL` instead, the preview is only as separate as that value, so set a preview-scoped `DATABASE_URL` that points at a non-production database.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/compute/deployments.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ This permanently deletes the service from the branch you target with `--branch`.

- [Environment variables](/compute/environment-variables): persist config across deploys.
- [Deploy on push](/compute/deploy-on-push): the push-to-deploy flow in detail.
- [Domains](/compute/domains): point a custom domain at production.
- [Domains](/compute/domains): point a custom domain at a service.
- [Prisma Composer](/composer): declare the app the `deploy` command deploys.
Loading
Loading