# Deploy Koa from a monorepo

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

## A self-contained app folder

If `apps/api` 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/api
npx ezhst build dockerfile set -f apps/api/Dockerfile
npx ezhst deploy
```

With a root directory set, the Dockerfile's `COPY` paths are relative to `apps/api`, so the [Koa hosting Dockerfile](/free-koa-hosting) 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/api'
WORKDIR /app/apps/api
ENV NODE_ENV=production PORT=3000
EXPOSE 3000
CMD ["npm", "start"]
```

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 [Koa hub](/frameworks/koa) for every Koa guide, or [free Koa hosting](/free-koa-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.
