How to Create a Production Build of OpenWork: Desktop, Web UI, and API
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 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:
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:
pnpm run build
This command executes the following pipeline:
- Entry execution:
node scripts/build.mjs(located atscripts/build.mjs) forwards topnpm --filter @openwork/desktop build - Electron-Builder: Compiles the Electron application using the configuration in
packages/@openwork/desktop - Artifact generation: Outputs platform-specific installers (
.exe,.dmg,.AppImage) topackages/@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
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
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:
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:
cd packages/@openwork/desktop/dist
# macOS:
open OpenWork-0.0.0.dmg
# Windows:
OpenWork-Setup-0.0.0.exe
Den Web (Next.js):
cd packages/@openwork-ee/den-web
node_modules/.bin/next start
Den API (Node):
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:
docker build -f packaging/docker/Dockerfile.inference -t openwork/den-api:latest .
Den Web:
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=0for production mode - Desktop: Run
pnpm run buildto generate Electron installers viascripts/build.mjs - Server: Execute
pnpm run build:webandpnpm run build:apito compile the Next.js UI and API server - Artifacts: Desktop binaries appear in
packages/@openwork/desktop/dist/, while Den outputs reside inpackages/@openwork-ee/den-web/.next/andpackages/@openwork-ee/den-api/dist/ - Docker: Use
packaging/docker/Dockerfile.inferenceandDockerfile.webfor 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.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →