# Faster builds

How the build cache works, and how to order your Dockerfile, .dockerignore and lockfile for quicker builds.

Last reviewed: 2026-11-12

## How the DeployVera cache works

DeployVera keeps a build cache for each application automatically and uses it on every build. The cache belongs to one application and is never shared between customers.

The cache reuses layers and package downloads from earlier builds. This is not a guarantee: when a dependency file or source file changes, the affected steps run again. No specific build time is promised.

In the build list, successful builds that finish at least 30% and at least 30 seconds faster than the median of the application's recent successful builds are marked "Cached". The label is based only on build time, and it needs at least three earlier successful builds.

## Order Dockerfile layers correctly

Copy the dependency files and run the install first, then copy the rest of the source. When only source code changes, the dependency install is reused from the cache.

```
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
CMD ["npm", "start"]
```

## BuildKit cache mount: npm

`RUN --mount=type=cache` keeps the package manager's download cache outside the image and reuses it in later builds. This syntax needs BuildKit; the `# syntax=docker/dockerfile:1` line on the first line of the file enables it.

```
# syntax=docker/dockerfile:1
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN --mount=type=cache,target=/root/.npm npm ci
COPY . .
RUN npm run build
CMD ["npm", "start"]
```

## Cache mounts for pnpm and pip

pnpm must be installed in the image before the pnpm step. Do not add `--no-cache-dir` to the pip command, because that disables the pip cache. The target path depends on the home directory of the image user; check it in your base image.

```
# pnpm
RUN --mount=type=cache,target=/root/.local/share/pnpm/store pnpm install --frozen-lockfile

# pip
RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
```

## Exclude unneeded files with .dockerignore

Unneeded files in the build context invalidate copy layers for no reason. Exclude local dependencies, Git history and build output, and add secret files such as `.env`.

```
node_modules
.git
.next/cache
dist
```

## Commit the lockfile

Commit `package-lock.json` or `pnpm-lock.yaml` to the repository. `npm ci` does not work without a lockfile; when one exists, the same package versions are installed on every build and the dependency layer is reused more often.

## Avoid forced rebuilds

The panel does not currently offer a forced rebuild (skipping the cache); every build uses the cache. If you suspect the cache is causing a problem, open a support ticket and include the build ID.

## Next.js: standalone output

Setting `output: 'standalone'` in `next.config.js` collects the files needed at runtime into a separate folder and makes the image smaller. It does not shorten the build itself. With a Dockerfile, copy the `.next/standalone` folder into the image.

```
// next.config.js
module.exports = {
  output: 'standalone',
};
```

Sources: https://api.deployvera.com/api/plans · https://deployvera.com/docker · https://deployvera.com/help
