# Static sites

A static site is a service whose files are served by Alf itself, not by a container: the HTML, CSS, JavaScript and images that `npm run build` puts in `dist`, or a whole site generator's output. It's built from a Dockerfile like any other service, on one of your servers. Its site folder is then copied out of the image, and after that nothing of it runs anywhere. It doesn't sleep, so there's never a cold start, and you pay only for the storage its files take.

On the canvas it's a service like the others, with its own address, [custom domains](/docs/domains), deployments and rollbacks.

## Make one

- **+ Create → Static site**: name it, pick where it comes from (code you push, or a published image), and say which folder of the image holds the site. Then push its code with the command shown, as for [any service](/docs/deploying-code).
- **From a Dockerfile**: add `LABEL smartalfred.static=<folder>`. A service built from it is published as a static site from its next deploy on, nothing else to set.
- **From a compose file**: its [labels](/docs/site-builds#in-a-compose-file).
- **An existing service**: **Settings → Serve as a static site**. It's deployed again as a site, and its container goes.

## Deploys and rollbacks

Each deploy builds the image, copies the site folder out, and sends Alf only the files it doesn't have already, so a deploy that changed one page uploads one page. It goes live all at once when every file is there: a visitor gets the old version or the new one, never half of each. If a deploy fails, visitors keep the version before it.

Rolling back is instant. The files of the newest 10 deploys are kept, so going back to one of those switches to its files with nothing built. An older deploy is built again from its code.

## Limits and cost

A site can hold up to 20,000 files and 2 GB, and each file can be up to 25 MB. A static site has no volumes, can't be private, and takes no memory on any server: it's built on one, and that's all.

Its files count as storage, like a volume's contents: each distinct file once, however many of the kept deploys use it ([GB-months](/docs/usage#storage)). Requests to it cost nothing.

## More about sites

- [Building a site](/docs/site-builds): the Dockerfile, its variables, and sites in a compose file.
- [Paths and caching](/docs/site-paths): which file a path gets, single-page apps, and what browsers keep.
