> Index of every page on this site: [llms.txt](https://docs.a-line.cloud/llms.txt)

# Recipes

> Complete examples for common setups.

Each recipe is a full set of files that you can copy into a repository and
adapt.

## Web app with Postgres

A public web app on a verified domain, reading its database credentials
from a lease.

```yaml title="clusters/hetzner-fsn1.yaml" iac tree=web-postgres
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
provider: hetzner
region: fsn1
pools:
  - name: control-plane
    role: control_plane
  - name: general
```

```yaml title="projects/blog/project.yaml" iac tree=web-postgres
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
name: blog
cluster: hetzner-fsn1
```

```yaml title="projects/blog/apps/db.yaml" iac tree=web-postgres
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  template: postgres
  version: "16"
databases:
  blog:
    roles:
      app:
        owner: true
backup:
  enabled: true
```

```yaml title="projects/blog/apps/web.yaml" iac tree=web-postgres
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  image: ghcr.io/example/blog:1.0.0
port: 3000
domains:
  - domain: blog.example.com
http:
  https_redirect: true
env:
  DATABASE_URL:
    from: app/db
    lease: blog/app
    output: url
connections:
  - to: db
    ports:
      - port: 5432
```

`blog.example.com` must be covered by a [verified domain](/iac/domains).
Making `app` the owner is [held](/iac/gitops#held) until someone confirms
it.

## Public assets in a bucket

A bucket whose `public/` folder anyone can read, with the app told where it
is.

```yaml title="clusters/hetzner-fsn1.yaml" iac tree=assets
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
provider: hetzner
region: fsn1
pools:
  - name: control-plane
    role: control_plane
  - name: general
```

```yaml title="projects/media/project.yaml" iac tree=assets
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
name: media
cluster: hetzner-fsn1
buckets:
  - name: media-assets
    quota_gb: 25
    public_paths:
      - public/
```

```yaml title="projects/media/apps/uploader.yaml" iac tree=assets
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  image: ghcr.io/example/uploader:2.3.0
port: 8080
env:
  ASSETS_PUBLIC_URL:
    from: bucket/media-assets
    output: public_url
storage_bindings:
  - bucket: media-assets
```

The binding gives the app the bucket's credentials as `S3_*` variables; the
reference adds its public URL. See [references](/iac/references) and
[bucket access](/iac/data#storage-bindings).

## A locked-down project

A project whose apps can only reach one outside API.

```yaml title="clusters/hetzner-fsn1.yaml" iac tree=isolated
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
provider: hetzner
region: fsn1
pools:
  - name: control-plane
    role: control_plane
  - name: general
```

```yaml title="projects/billing/project.yaml" iac tree=isolated
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
name: billing
cluster: hetzner-fsn1
egress:
  mode: isolated
  rules:
    - kind: fqdn
      value: api.example.net
      port: 443
      protocol: tcp
```

```yaml title="projects/billing/apps/invoicer.yaml" iac tree=isolated
# yaml-language-server: $schema=https://a-line.cloud/schemas/iac/v1.json
version: 1
source:
  image: ghcr.io/example/invoicer:1.2.0
port: 8080
```

See [outbound traffic](/iac/networking#egress).
