Deploy Next.js from a monorepo

Run the deploy from your repository root. Reverhost builds the Dockerfile stored on your app, using either your Next.js folder or the whole repository as the build context.

Last updated November 25, 2026

A self-contained app folder

If apps/web has its own lockfile and no workspace dependencies, make it the build context.

npx ezhst link --project <project-slug> --app <app-slug>
npx ezhst build set --root-dir apps/web
npx ezhst build dockerfile set -f apps/web/Dockerfile
npx ezhst deploy

With a root directory set, the Dockerfile's COPY paths are relative to apps/web, so the Next.js hosting Dockerfile works as is.

An app that uses workspace packages

Leave the root directory empty so the whole repository is the build context. Install at the root, build only your app, then start it from its folder.

Dockerfile
FROM node:22-alpine
WORKDIR /app
COPY . .
RUN npm ci
RUN --mount=type=secret,id=appenv,target=/run/secrets/appenv sh -c 'set -a; . /run/secrets/appenv; set +a; npx turbo run build --filter=./apps/web'
WORKDIR /app/apps/web
ENV NODE_ENV=production PORT=3000
EXPOSE 3000
CMD ["sh", "-c", "exec npx next start -H 0.0.0.0 -p $PORT"]

Nx works the same way with npx nx build <project> as the build command.

Several apps, one project

A project holds 2 apps. Create one Reverhost app per deployable folder, each with its own Dockerfile and root directory. They share the project's database and bucket.

See the Next.js hub for every Next.js guide, or free Next.js hosting for what is included.

Frequently asked questions

Where should I run ezhst deploy?

From the repository root, so shared packages and the lockfile are included in the upload.

Start for free

Install the skill, choose Global or Local, then tell your agent to deploy. No credit card, no config files.

$npx ezhst skill install