Documentation Index
Fetch the complete documentation index at: https://docs.vers.sh/llms.txt
Use this file to discover all available pages before exploring further.
vers build reads a literal Dockerfile and produces a Vers commit. Each instruction becomes a cached “layer.” The output is the same commit id any other Vers command accepts — it boots with vers run-commit, branches with vers branch, and can be tagged with vers tag or -t.
This page explains the model. For the command-level reference, see vers build.
The mapping
Every supported Dockerfile instruction translates to one or more Vers actions:| Dockerfile | Vers action |
|---|---|
FROM scratch | vm.NewRoot with explicit sizing flags |
FROM <tag-or-commit> | vm.RestoreFromCommit (tag lookup first) |
RUN | vers exec with accumulated ENV / WORKDIR / USER |
COPY / ADD (local) | SFTP upload from the build context |
ENV, ARG, WORKDIR, USER, LABEL | Builder state — no VM mutation, but affects future layers |
CMD, ENTRYPOINT, EXPOSE | Captured as commit metadata |
Supported instructions
FROM, RUN, COPY, ADD (local paths only), ENV, ARG, WORKDIR, USER, LABEL, CMD, ENTRYPOINT, EXPOSE.
Line continuations, exec-form arrays (CMD ["node", "server.js"]), .dockerignore patterns, and $VAR / ${VAR} substitution are supported.
The cache model
Every materializing instruction (RUN or COPY/ADD) produces a commit. Before executing, the builder computes a cache key:.vers/buildcache.json in your project — the builder skips execution and uses the cached commit as the new parent. Otherwise it runs the step and writes the resulting commit back to the cache.
This is the same shape as Docker’s layer cache, with two differences:
- Layers here are first-class Vers commits, not OCI blobs. You can
vers brancha mid-build layer directly. - Cache invalidation is content-based, not timestamp-based. Touching a file without changing it doesn’t invalidate.
Cache invalidation
A layer re-runs when any of:- The instruction text changes (even whitespace-significant)
- The accumulated ENV/WORKDIR/USER before this instruction differs
- For COPY: any file in the copied tree changes size, mode, or contents
- For COPY:
.dockerignorechanges the visible tree --build-argvalues change (and that ARG is declared in the Dockerfile)
Cache busting
--no-cache— bypass the cache for this build.- Delete
.vers/buildcache.json— reset all cache state. vers commit delete <commit-id>— remove specific cached layers; next build re-runs them.
Stale cache
If a cached commit id has been deleted server-side, the builder falls through to real execution and prints acache entry stale note. No hard failure — you just lose the speedup for that step.
FROM semantics
| Form | Behaviour |
|---|---|
FROM scratch | Fresh VM via vm.NewRoot. Requires --mem-size, --vcpu-count, --fs-size-vm-mib. There are no implicit defaults. |
FROM <name> | Looked up as a vers tag first, falling back to treating <name> as a commit id. |
FROM <commit-id> | Restored directly. |
FROM ubuntu:22.04 doesn’t work out of the box — you either use FROM scratch with a Vers rootfs, or point at a commit someone else has already built and shared (via vers repo fork or a tag id you were given).
A worked example
vers build --mem-size 2048 --vcpu-count 2 --fs-size-vm-mib 4096 -t myapp:prod .) produces:
ARG / ENV / WORKDIR
Metadata only. Applied to builder state, bakes into every subsequent layer’s cache key.
COPY package.json package-lock.json ./
Uploaded; layer committed. Cache keyed on the two files’ contents.
COPY . /app
Every file (minus
.dockerignore) uploaded; layer committed. Most likely to invalidate on change, which is why package.json copy came first.Common patterns
Dependency layer, then source layer
PutCOPY of dependency manifests (package.json, go.sum, requirements.txt) before COPY . /app. That way editing source code doesn’t invalidate the dependency install layer.
Using a golden base
Dockerfile as the project’s run config
Instead of maintainingvers.toml and a Dockerfile, you can tag the build and use vers run-commit as your default boot path:
See also
- vers build — the command reference
- Commits — what
vers buildproduces - vers tag, vers repo — naming and sharing builds