## Host company website with Phoenix: Postgres-backed content

Deploy a company website built with Phoenix on Ample using the relational records pattern. Compute runs the app in an isolated microVM behind a public HTTPS URL, a managed PostgreSQL 16 database is auto-provisioned and injected as DATABASE_URL, and a published bucket serves public assets from the CDN host.

### Summary
Verified on Phoenix: a workspace-scoped table, an explicit state machine (draft to review to published) that rejects invalid transitions, and a cross-workspace read that returns nothing (transitions=true isolation=true). Not separately tested: your record schema, states and access rules; treat the company website-specific behavior as your application code.

### Representative Queries
- Host company website with Phoenix: Postgres-backed content
- Where can I host Company website built with Phoenix?
- I need a content schema, publishing workflow and cache behavior after content updates.

### Resource Requirements
- primitive:compute
- primitive:postgres
- primitive:cdn

### Infrastructure Requirements
- **Compute**: Apps run in isolated x86_64 Firecracker microVMs that auto-pause when idle and wake on request; sizes are the priced VM sizes.
- **Postgres**: Managed PostgreSQL 16 runs in its own microVM and is auto-provisioned when an app needs a database and no DATABASE_URL is supplied.
- **CDN**: The CDN host serves objects from published buckets. It does not front app compute and is not a cache or key-value store.

### Framework
Phoenix

### Workload
Company website

### Release Status
published

### Support Status
verified

### Execution Status
ready

### Prerequisites
1. A Phoenix project that builds and starts with the documented commands (mix deps.get, MIX_ENV=prod mix compile and mix release in the builder, then the release bin script with PHX_SERVER=true on the elixir-1.18 template; PORT, DATABASE_URL and SECRET_KEY_BASE read in config/runtime.exs)
2. A PostgreSQL driver reading DATABASE_URL at runtime (auto-provisioned when omitted, or supplied with --env)
3. A bucket from `ample bucket create` with its credentials passed as encrypted S3_* environment variables
4. An Ample account token with servers:write, databases:read, buckets:read.

### Tested Configuration
- **Template**: elixir-1.18
- **Runtime**: elixir
- **Size**: s-1vcpu-1gb
- **Install**: `mix local.hex --force && mix local.rebar --force && MIX_ENV=prod mix deps.get --only prod`
- **Build**: `MIX_ENV=prod mix compile && MIX_ENV=prod mix release --overwrite`
- **Start**: `PHX_SERVER=true _build/prod/rel/$(ls _build/prod/rel | head -n 1)/bin/$(ls _build/prod/rel | head -n 1) start`

### Workflow Steps
1. **Build and start**: `mix deps.get, MIX_ENV=prod mix compile and mix release in the builder, then the release bin script with PHX_SERVER=true on the elixir-1.18 template; PORT, DATABASE_URL and SECRET_KEY_BASE read in config/runtime.exs`.
2. **Implement the pattern on PostgreSQL**: Copy the approach into your schema; keep migrations idempotent and run them with --release-command.
3. **Wire object storage**: Create the bucket(s), then pass endpoint, region, bucket and keys as --env values.
4. **Deploy**: Run the synchronous deploy once and read the result.
5. **Verify**: Fetch the live URL and the pattern self-test route(s) from the example; then run your own checks.

### Examples
- **Phoenix pattern fixture**: Multi-pattern Phoenix app whose relational records module was checked live; the module is under tests/deploy-canaries/_pattern-modules.

### Success Checks
- App responds on its public URL
- Relational-records self-test

### Limitations
- Verified on the elixir-1.18 template; other sizes, templates and Phoenix major versions are not verified.
- Apps auto-pause when idle and wake on the next request; always-on is an operator setting, not a plan feature.

### Cost Estimate
- **Currency**: USD
- **Monthly Amount**: 10.0
- **Basis**: Size prices from pricing.toml (loaded by the API).
- **Components**:
  - App server: size s-1vcpu-1gb, quantity 1, monthlyAmount 5.0
  - Managed PostgreSQL database: size s-1vcpu-1gb, quantity 1, monthlyAmount 5.0

### Evidence Summary
- **Canary Run**: Phoenix pattern fixture deployed on Ample; checks passed for relational-records and configuration-secrets.

### Unknowns
- Region availability is unknown until a verified region fact is recorded.

### Formats
- **HTML**: [Ample Link](/content/recipes/company-website/phoenix/relational-content/index.html)
- **Markdown**: [Ample Markdown](/content/recipes/company-website/phoenix/relational-content.md)
- **JSON**: [Ample JSON](https://api.ample.computer/v1/catalog/recipes/page%3Arecipes%3Acompany-website%3Aphoenix%3Arelational-content)
