drift Docs
Start
What is Drift?
The tour, if you are new here.
Use cases
Whether Drift does your thing.
Getting started
Nothing to deployed, in one command.
Architecture
How a slice is put together.
What it costs
The free grant, four unit prices, two rules.
Build
Canvas
Static sites, same origin as your API.
Tools
Operate
Auth
Route gates, API keys and your account.
Teams
More than one person on one account.
Security
Boundaries, sandboxing and hardening.
Troubleshooting
Error codes
What went wrong, and what to do about it.
Legal
Acceptable use
What a slice may not be used for.
Data processing
The DPA, and every sub-processor.

Canvas sites

Canvas serves static sites, declared inside one canvas block. Each site is a site block labelled with the path it is served at, and it names the folder to serve. site "/" mounts a folder at the root; any other path mounts a sub-path, which is handy for a public site plus an admin or reviewer area.

TypeDefaultMeaning
  • site "/path"
    Type
    label
    Default
    REQUIRED
    Meaning
    The path the site is served at: "/" for the root, "/reviewer" for a sub-path.
  • dir
    Type
    string
    Default
    REQUIRED
    Meaning
    The folder it serves, relative to the Driftfile. A folder that does not exist is refused at this line.
Driftfile
canvas {
  site "/" {
    dir = "canvas/public"
  }

  site "/reviewer" {
    dir = "canvas/reviewer"
  }
}

A file has at most one canvas block, and it may declare several sites, one block each. A site block with no dir is refused, naming the site.

How much storage the slice has for all its sites together is canvas_storage in the limits block of slice, a size such as "200MiB". It is the storage across every site the slice serves, and the free slice grants 50MiB of it.

Driftfile
slice "gemeente" {
  limits {
    canvas_storage = "200MiB"
  }
}

canvas {
  site "/" {
    dir = "site"
  }

  site "/reviewer" {
    dir = "admin"
  }
}

A site the file does not name is left serving. drift plan shows it as - site /old still served: no drift command removes a site yet, and nothing prunes it: no drift command removes a site today, and the plan says exactly that rather than offering a command that does not exist. A site the file does name is uploaded again on every apply, since the slice keeps no hash of a site's files to compare.

A password gate in front of the sites is declared under edge.site_auth.

Read the Canvas guide