Skip to content

Commit 6859887

Browse files
committed
📝 docs: update README with unified port architecture and Docker improvements
- Document single-port deployment: gateway serves UI/API/WS on 8080 - Add Ports & Services table showing production vs development setup - Clarify Vite dev server (5173) proxies to gateway (8080) in dev mode - Update WebSocket endpoint: ws://localhost:8080/ws (not separate port) - Fix docker-compose to use root Dockerfile (includes UI bundle) - Update test counts: 545+ files, 26,500+ tests (was 383/22,000) - Improve gateway
1 parent df9b9f3 commit 6859887

3 files changed

Lines changed: 59 additions & 41 deletions

File tree

README.md

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -230,9 +230,9 @@ Privacy-first personal AI assistant platform with soul agents, autonomous backgr
230230
```
231231
┌──────────────┐
232232
│ Web UI │ React 19 + Vite 7
233-
│ (Port 5173) │ Tailwind CSS 4
233+
│ (bundled) │ Tailwind CSS 4
234234
└──────┬───────┘
235-
│ HTTP + SSE + WebSocket
235+
│ HTTP + SSE + WebSocket (/ws)
236236
┌─────────────────┼─────────────────┐
237237
│ │ │
238238
┌────────┴────────┐ │ ┌─────────┴──────────┐
@@ -362,11 +362,10 @@ cp .env.example .env
362362
# Start PostgreSQL (if you don't have one already)
363363
docker compose --profile postgres up -d
364364

365-
# Start development (gateway + ui)
365+
# Start development (gateway on :8080 + Vite UI on :5173)
366366
pnpm dev
367367

368-
# UI: http://localhost:5173
369-
# API: http://localhost:8080
368+
# Open http://localhost:5173 (Vite proxies API/WS to gateway)
370369
```
371370

372371
AI provider API keys are configured via the **Config Center UI** (Settings page) after setup.
@@ -493,7 +492,7 @@ The foundational runtime library. Contains the AI engine, tool system, plugin ar
493492

494493
The API server built on [Hono](https://hono.dev/). Handles HTTP/WebSocket communication, database operations, agent execution, MCP integration, plugin management, and channel connectivity.
495494

496-
**~76,000 LOC** across 210+ source files. **239 test files** with **11,750+ tests**.
495+
**~76,000 LOC** across 210+ source files. **389 test files** with **16,400+ tests**.
497496

498497
**Route Modules (50+ top-level + 70+ sub-modules):**
499498

@@ -1518,7 +1517,7 @@ Sliding window algorithm with configurable window (default 60s), max requests (d
15181517

15191518
### WebSocket Events
15201519

1521-
Real-time broadcasts on `ws://localhost:18789`:
1520+
Real-time broadcasts via WebSocket at `ws://localhost:8080/ws` (attached to the HTTP server, same port):
15221521

15231522
| Event | Description |
15241523
| ------------------------- | ------------------------------------------------ |
@@ -1624,9 +1623,19 @@ LOG_LEVEL=info
16241623

16251624
## Deployment
16261625

1627-
### Docker Compose
1626+
### Ports & Services
1627+
1628+
| Service | Port | Protocol | Description |
1629+
| -------------- | ------- | -------- | -------------------------------------------- |
1630+
| **Gateway** | `8080` | HTTP | REST API + bundled UI (Vite static assets) |
1631+
| **WebSocket** | `8080` | WS | Real-time events at `/ws` (shares HTTP port) |
1632+
| **PostgreSQL** | `25432` | TCP | Database (mapped from container's `5432`) |
1633+
| **MQTT** | `1883` | TCP | Mosquitto broker (optional, for edge/IoT) |
1634+
| **MQTT WS** | `9001` | WS | MQTT WebSocket transport (optional) |
1635+
1636+
> **Note:** In production (Docker), a single port `8080` serves everything — REST API, WebSocket, and the pre-built UI. No separate frontend deployment needed.
16281637
1629-
The simplest way to run OwnPilot in production:
1638+
### Docker Compose
16301639

16311640
```bash
16321641
cp .env.example .env
@@ -1637,15 +1646,13 @@ docker compose --profile postgres up -d
16371646

16381647
# With MQTT broker for edge/IoT devices
16391648
docker compose --profile postgres --profile mqtt up -d
1640-
1641-
# UI + API: http://localhost:8080
16421649
```
16431650

1644-
The gateway container serves the bundled UI — no separate frontend deployment needed.
1651+
Open **http://localhost:8080** — the gateway serves the bundled React UI, REST API, and WebSocket on the same port.
16451652

16461653
### Pre-built Image
16471654

1648-
A multi-arch image (amd64 + arm64) is published to GitHub Container Registry:
1655+
A multi-arch image (amd64 + arm64) is published to GitHub Container Registry on every release:
16491656

16501657
```bash
16511658
docker pull ghcr.io/ownpilot/ownpilot:latest
@@ -1658,19 +1665,29 @@ docker run -d \
16581665
ghcr.io/ownpilot/ownpilot:latest
16591666
```
16601667

1661-
Health check endpoint: `GET /health`
1668+
Health check: `GET http://localhost:8080/health`
16621669

1663-
### Manual
1670+
### Development Mode
1671+
1672+
In development, Vite runs a separate dev server with hot reload:
1673+
1674+
| Service | Port | Description |
1675+
| ------------------- | ------- | ------------------------------------------------------- |
1676+
| **Vite Dev Server** | `5173` | React UI with HMR (proxies `/api` and `/ws` to gateway) |
1677+
| **Gateway** | `8080` | REST API + WebSocket |
1678+
| **PostgreSQL** | `25432` | Database |
16641679

16651680
```bash
1666-
# Build all packages
1667-
pnpm build
1681+
pnpm dev # Starts gateway (8080) + Vite UI (5173)
1682+
```
16681683

1669-
# Start production server
1670-
ownpilot start
1684+
Open **http://localhost:5173** for development. Vite automatically proxies API calls (`/api/*`) and WebSocket (`/ws`) to the gateway on port 8080.
1685+
1686+
### Manual Production
16711687

1672-
# Or start gateway only
1673-
pnpm --filter @ownpilot/gateway start
1688+
```bash
1689+
pnpm build # Build all packages (includes UI static assets)
1690+
ownpilot start # Start production server on port 8080
16741691
```
16751692

16761693
---
@@ -1721,7 +1738,7 @@ pnpm clean # Clear all build artifacts
17211738
| **Telegram** | Grammy 1.41 |
17221739
| **CLI** | Commander.js 14 |
17231740
| **MCP** | @modelcontextprotocol/sdk |
1724-
| **Testing** | Vitest 4.x (383+ test files, 22,000+ tests) |
1741+
| **Testing** | Vitest 4.x (545+ test files, 26,500+ tests) |
17251742
| **Linting** | ESLint 10 (flat config) |
17261743
| **Formatting** | Prettier 3.8 |
17271744
| **Container** | Docker multi-arch (ghcr.io/ownpilot/ownpilot) |

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ services:
3030
gateway:
3131
build:
3232
context: .
33-
dockerfile: packages/gateway/Dockerfile
33+
dockerfile: Dockerfile
3434
container_name: ownpilot
3535
restart: unless-stopped
3636
ports:

packages/gateway/Dockerfile

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,43 @@
1-
# OwnPilot Gateway Dockerfile
2-
# Multi-stage build for production optimization
1+
# OwnPilot Gateway-Only Dockerfile
2+
# API server without bundled UI (for headless/API-only deployments)
3+
# For full deployment (API + UI), use the root Dockerfile instead.
34

45
# ============================================================================
56
# Stage 1: Base
67
# ============================================================================
78
FROM node:22-alpine AS base
89

9-
# Install pnpm
10-
RUN npm install -g pnpm@10.29.3
10+
RUN corepack enable && corepack prepare pnpm@10.29.3 --activate
1111

12-
# Set working directory
1312
WORKDIR /app
1413

1514
# ============================================================================
1615
# Stage 2: Dependencies
1716
# ============================================================================
1817
FROM base AS dependencies
1918

20-
# Copy workspace files
2119
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
2220
COPY packages/core/package.json ./packages/core/
2321
COPY packages/gateway/package.json ./packages/gateway/
2422
COPY packages/cli/package.json ./packages/cli/
2523

26-
# Install dependencies
2724
RUN pnpm install --frozen-lockfile
2825

2926
# ============================================================================
3027
# Stage 3: Builder
3128
# ============================================================================
3229
FROM dependencies AS builder
3330

34-
# Copy source code
3531
COPY . .
3632

37-
# Build only necessary packages (exclude UI)
33+
# Build backend only (no UI)
3834
RUN pnpm run build --filter=@ownpilot/core --filter=@ownpilot/gateway --filter=@ownpilot/cli
3935

4036
# ============================================================================
4137
# Stage 4: Production
4238
# ============================================================================
4339
FROM base AS production
4440

45-
# Install production dependencies only
4641
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml turbo.json ./
4742
COPY packages/core/package.json ./packages/core/
4843
COPY packages/gateway/package.json ./packages/gateway/
@@ -52,22 +47,28 @@ RUN pnpm install --frozen-lockfile --prod
5247

5348
# Copy built artifacts
5449
COPY --from=builder /app/packages/core/dist ./packages/core/dist
50+
COPY --from=builder /app/packages/core/data ./packages/core/data
5551
COPY --from=builder /app/packages/gateway/dist ./packages/gateway/dist
52+
COPY --from=builder /app/packages/gateway/data ./packages/gateway/data
5653
COPY --from=builder /app/packages/cli/dist ./packages/cli/dist
5754

58-
# Copy necessary non-code files
59-
COPY packages/gateway/src/db/migrations ./packages/gateway/src/db/migrations
55+
# Create non-root user and data directory
56+
RUN addgroup -g 1001 -S ownpilot && adduser -S ownpilot -u 1001 -G ownpilot
57+
RUN mkdir -p /app/data && chown -R ownpilot:ownpilot /app/data
6058

61-
# Environment
6259
ENV NODE_ENV=production
6360
ENV PORT=8080
61+
ENV HOST=0.0.0.0
62+
63+
USER ownpilot
6464

65-
# Expose port
6665
EXPOSE 8080
6766

68-
# Health check
69-
HEALTHCHECK --interval=30s --timeout=3s --start-period=5s --retries=3 \
70-
CMD node -e "require('http').get('http://localhost:8080/api/v1/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
67+
HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \
68+
CMD wget --no-verbose --tries=1 --spider http://127.0.0.1:8080/health || exit 1
69+
70+
LABEL org.opencontainers.image.source="https://github.com/ownpilot/ownpilot"
71+
LABEL org.opencontainers.image.description="OwnPilot Gateway — API server only (no UI)"
72+
LABEL org.opencontainers.image.licenses="MIT"
7173

72-
# Start the gateway
7374
CMD ["node", "packages/gateway/dist/server.js"]

0 commit comments

Comments
 (0)