Deployment
Portable mode, PM2, and operational deployment notes for Enrai.
Internal-first deployment model
Enrai is designed for:
- local development
- trusted internal environments
- hosts behind a firewall
- machines where file access and shell execution are intentional features
Portable mode
Portable mode serves the editor frontend from the same Express process used by the backend:
npm run build:portable
npm run start:portableURL:
http://localhost:3001/editorSplit frontend and backend
You can also serve the frontend and backend separately.
This is useful if you want:
- a managed frontend on Vercel or Amplify
- a separate VM/container for the Enrai backend
- different deploy cadences for UI and backend
In this model:
frontend/is deployed as a normal Next.js appbackend/is deployed separately on your own host- the frontend points to that backend through
NEXT_PUBLIC_EDITOR_BACKEND_URL
Example:
Frontend: https://editor.example.com
Backend: https://enrai-api.example.comFrontend environment variable:
NEXT_PUBLIC_EDITOR_BACKEND_URL=https://enrai-api.example.comThe editor will then call:
https://enrai-api.example.com/api/...
https://enrai-api.example.com/ws
https://enrai-api.example.com/api/enrai/tasksIf you use the Enrai task queue from external automation, you can also configure a completion callback URL so Enrai sends a POST when a task finishes as completed, failed, or interrupted.
Vercel
For a Vercel frontend:
- Import the repository in Vercel.
- Set the root directory to
frontend. - Add
NEXT_PUBLIC_EDITOR_BACKEND_URL. - Deploy the backend separately on your own machine, VM, or container host.
AWS Amplify
For an Amplify frontend:
- Create a new app from this repository.
- Set the app root to
frontend/. - Add
NEXT_PUBLIC_EDITOR_BACKEND_URLin the environment settings. - Deploy the backend separately and expose it through your preferred proxy/domain.
Notes:
- The backend still needs WebSocket support.
- The backend should usually sit behind Nginx, Caddy, Apache, or another reverse proxy.
- If you do this split deployment, keep the backend on a trusted host or behind a firewall.
Docker
Enrai now includes a root Dockerfile for the portable runtime.
Build the image:
docker build -t enrai/editor:latest .Run the container:
docker run --rm -it \
-p 3001:3001 \
-e OPENAI_API_KEY=your_key_here \
-e EDITOR_WORKDIR=/workspace \
-v "$(pwd)/backend/projects:/workspace" \
enrai/editor:latestContainer URL:
http://localhost:3001/editorNotes:
- The image builds the portable frontend during
docker build. - The runtime serves the app from the embedded Express backend.
- Mount a host directory if you want persistent project files inside the workspace.
Build from source
If you want to copy, fork, or modify Enrai and build it yourself:
npm install
cd backend && npm install && cd ..
npm run build:portable
npm run start:portableIf you want to build only the frontend:
cd frontend
npm install
npm run build
npm run startIf you want to run the backend separately:
cd backend
npm install
npm run devIf you use a split deployment, make sure the frontend gets:
NEXT_PUBLIC_EDITOR_BACKEND_URL=https://your-backend.example.comIf you also want the docs app:
cd documentation
npm install
npm run build
npm run startPM2
For a long-running internal deployment:
npm run build:portable
npm run pm2:start
pm2 save
sudo env PATH=$PATH:/usr/bin pm2 startup systemd -u "$USER" --hp "$HOME"Useful commands:
npm run pm2:logs
npm run pm2:restart
npm run pm2:stopNotes
- The backend can read and write real project files.
- The terminal can execute commands directly in the workspace.
- Codex sessions can modify files and run tools in the selected workdir.
- If Enrai is exposed beyond a trusted internal network, add authentication and access control yourself.
For the full trust model and suggested controls, see Security.