# How to Create a Production Build of OpenWork: Desktop, Web UI, and API

> Learn how to create a production build of OpenWork for desktop, web UI, and API. Clone the repository, install dependencies, and run simple build commands.

- Repository: [Different AI/openwork](https://github.com/different-ai/openwork)
- Tags: how-to-guide
- Published: 2026-08-01

---

**To create a production build of OpenWork, clone the `different-ai/openwork` repository, install dependencies with `pnpm install`, then run `pnpm run build` for the Electron desktop client and `pnpm run build:web` / `pnpm run build:api` for the server-side Den components.**

OpenWork is a monorepo containing an Electron-based desktop application and server-side Den services built with Next.js and Express-like APIs. This guide walks through compiling production-ready artifacts from the source code using the pnpm workspace scripts defined in the repository.

## Prerequisites

Before building, ensure your environment matches the toolchain specifications defined in the root configuration files.

### Node.js and pnpm Versions

OpenWork requires **Node.js 20+** (specified in `/.nvmrc`) and **pnpm 11 or higher** (declared in [`package.json`](https://github.com/different-ai/openwork/blob/main/package.json) under `packageManager`). These versions ensure compatibility with the monorepo's workspaces and Turbo configuration.

### Environment Configuration

Set `OPENWORK_DEV_MODE=0` or simply omit development flags to ensure `NODE_ENV` resolves to `"production"`. This strips development-only code from the bundles and enables optimizations in both the Electron and Next.js builds.

## Clone and Install

Start by cloning the repository and installing workspace dependencies across all packages:

```bash
git clone https://github.com/different-ai/openwork.git
cd openwork
git checkout dev

pnpm install

```

The `pnpm install` command resolves the monorepo's workspaces, pulling in every package under `packages/`, `apps/`, and the `@openwork` namespace.

## Build the Desktop Client (Electron)

The desktop client build is orchestrated by `scripts/build.mjs`, which delegates to the `@openwork/desktop` package:

```bash
pnpm run build

```

This command executes the following pipeline:

1. **Entry execution**: `node scripts/build.mjs` (located at [`scripts/build.mjs`](https://github.com/different-ai/openwork/blob/dev/scripts/build.mjs)) forwards to `pnpm --filter @openwork/desktop build`
2. **Electron-Builder**: Compiles the Electron application using the configuration in `packages/@openwork/desktop`
3. **Artifact generation**: Outputs platform-specific installers (`.exe`, `.dmg`, `.AppImage`) to `packages/@openwork/desktop/dist/`

Electron-Builder automatically detects `NODE_ENV=production` when `OPENWORK_DEV_MODE` is unset, ensuring the final binaries exclude development dependencies and debugging tools.

## Build the Server-Side Den Components

The Den architecture consists of a Next.js web UI and an Express-like API server, each built separately.

### Build the Den Web UI

```bash
pnpm run build:web

```

This script expands to `pnpm --filter @openwork-ee/den-web build`, executing `next build` to produce a production-optimized `.next` directory in `packages/@openwork-ee/den-web/`.

### Build the Den API

```bash
pnpm run build:api

```

The API package (`@openwork-ee/den-api`) compiles TypeScript sources using `tsc` and bundles them for Node.js. Output lands in `packages/@openwork-ee/den-api/dist/`.

### Build the UI-Only Package (Optional)

If you need the React-based interface without Electron wrapper:

```bash
pnpm run build:ui

```

This compiles `@openwork/app` to static assets in `packages/@openwork/app/dist/`.

## Verify the Production Build Locally

Validate your artifacts before distribution:

**Desktop:**

```bash
cd packages/@openwork/desktop/dist

# macOS:

open OpenWork-0.0.0.dmg

# Windows:

OpenWork-Setup-0.0.0.exe

```

**Den Web (Next.js):**

```bash
cd packages/@openwork-ee/den-web
node_modules/.bin/next start

```

**Den API (Node):**

```bash
cd packages/@openwork-ee/den-api
node dist/index.js

```

Ensure `NODE_ENV` remains unset or explicitly set to `production` during verification.

## Docker Deployment (Optional)

For containerized production deployment of the Den services, use the provided Dockerfiles that copy pre-compiled assets:

**Den API:**

```bash
docker build -f packaging/docker/Dockerfile.inference -t openwork/den-api:latest .

```

**Den Web:**

```bash
docker build -f packaging/docker/Dockerfile.web -t openwork/den-web:latest .

```

These images reference the `dist/` and `.next/` directories generated by the previous build steps, eliminating runtime compilation and producing lightweight production containers.

## Summary

- **Prerequisites**: Node.js 20+, pnpm 11+, and `OPENWORK_DEV_MODE=0` for production mode
- **Desktop**: Run `pnpm run build` to generate Electron installers via `scripts/build.mjs`
- **Server**: Execute `pnpm run build:web` and `pnpm run build:api` to compile the Next.js UI and API server
- **Artifacts**: Desktop binaries appear in `packages/@openwork/desktop/dist/`, while Den outputs reside in `packages/@openwork-ee/den-web/.next/` and `packages/@openwork-ee/den-api/dist/`
- **Docker**: Use `packaging/docker/Dockerfile.inference` and `Dockerfile.web` for containerized deployments

## Frequently Asked Questions

### What version of Node.js does OpenWork require?

OpenWork targets Node.js 20 or higher as specified in the `/.nvmrc` file at the repository root. Using the exact version referenced there ensures compatibility with the pnpm workspaces and build scripts.

### Can I build only the web UI without the Electron desktop app?

Yes. Run `pnpm run build:ui` to compile only the React-based UI package (`@openwork/app`) to static assets, or `pnpm run build:web` for the full Next.js Den interface. These commands skip the Electron-Builder step entirely.

### Where are the production Dockerfiles located?

The production-ready Dockerfiles reside in `packaging/docker/`. Specifically, `Dockerfile.inference` builds the Den API image while `Dockerfile.web` packages the Next.js frontend. Both expect pre-built `dist/` or `.next/` directories to minimize image size.

### How do I ensure the build runs in production mode?

Omit the `OPENWORK_DEV_MODE` environment variable or explicitly set it to `0`. This ensures `NODE_ENV` resolves to `"production"`, triggering optimizations in Electron-Builder, Next.js, and the TypeScript compiler.