mirror of
https://github.com/vee1e/workorder-desk.git
synced 2026-09-01 09:50:13 +00:00
144 lines
5.1 KiB
YAML
144 lines
5.1 KiB
YAML
# =============================================================================
|
|
# Work Order Management — DEVELOPMENT compose stack
|
|
#
|
|
# docker compose up --build
|
|
#
|
|
# Runs Mongo 7, the Express API (tsx watch hot reload), and the Vite dev
|
|
# server (HMR) with bind-mounts so source edits hot-apply. nginx is NOT used
|
|
# in dev: Vite proxies /api, /health, /ready to the api service (SPEC §4).
|
|
#
|
|
# IMPORTANT (dev proxy): the Vite dev proxy target inside this compose network
|
|
# must be http://api:4000 (the api service name). `frontend/vite.config.ts`
|
|
# reads that from VITE_PROXY_TARGET (defaults to http://localhost:4000 on the
|
|
# host, set to http://api:4000 in this file). See README.md.
|
|
#
|
|
# Dockerfile targets: backend/Dockerfile:dev and frontend/Dockerfile:dev run
|
|
# the dev stages (full deps + source). Both containers also run a `tsc --watch`
|
|
# on packages/shared so shared schema/type edits rebuild dist/ live.
|
|
# =============================================================================
|
|
|
|
name: workorders-dev
|
|
|
|
services:
|
|
mongo:
|
|
image: mongo:7
|
|
restart: unless-stopped
|
|
# Named volume so data survives `docker compose down`.
|
|
volumes:
|
|
- mongo-data:/data/db
|
|
# Published so host-side tooling (`npm run seed` with
|
|
# MONGODB_URI=mongodb://localhost:27017/workorders) can reach Mongo.
|
|
ports:
|
|
- "27017:27017"
|
|
healthcheck:
|
|
test: ["CMD", "mongosh", "--quiet", "--eval", "db.adminCommand('ping').ok"]
|
|
interval: 10s
|
|
timeout: 5s
|
|
retries: 5
|
|
start_period: 10s
|
|
|
|
api:
|
|
build:
|
|
context: .
|
|
dockerfile: backend/Dockerfile
|
|
target: dev
|
|
image: workorders-api:dev
|
|
restart: unless-stopped
|
|
init: true
|
|
working_dir: /app/backend
|
|
# Rebuild packages/shared dist/ on change, then run tsx watch (hot reload).
|
|
command: >
|
|
sh -c "npx tsc -p ../packages/shared/tsconfig.json --watch --preserveWatchOutput &
|
|
exec npx tsx watch src/server.ts"
|
|
environment:
|
|
NODE_ENV: development
|
|
PORT: "4000"
|
|
MONGODB_URI: mongodb://mongo:27017/workorders
|
|
# ── dev only: long random-looking values so backend validation passes.
|
|
# These are NOT secrets; production reads real values from .env.
|
|
JWT_SECRET: dev-only-e7c1a9f34d5b8e2c0a6f9d1b4c7e3a85
|
|
COOKIE_SECRET: dev-only-b2f6a4d9c8e1b3f7a5c0d2e4f8b6a1c7
|
|
CORS_ORIGIN: http://localhost:5173
|
|
APP_URL: http://localhost:5173
|
|
TRUST_PROXY_HOPS: "0"
|
|
DEBUG_ERRORS: "true"
|
|
LOG_LEVEL: debug
|
|
volumes:
|
|
- ./backend/src:/app/backend/src
|
|
- ./packages/shared/src:/app/packages/shared/src
|
|
ports:
|
|
- "4000:4000"
|
|
depends_on:
|
|
mongo:
|
|
condition: service_healthy
|
|
|
|
worker:
|
|
build:
|
|
context: .
|
|
dockerfile: backend/Dockerfile
|
|
target: dev
|
|
image: workorders-worker:dev
|
|
restart: unless-stopped
|
|
init: true
|
|
working_dir: /app/backend
|
|
# Rebuild packages/shared dist/ on change, then run tsx watch on the
|
|
# autonomous triage worker (separate process from the API, SPEC §7).
|
|
command: >
|
|
sh -c "npx tsc -p ../packages/shared/tsconfig.json --watch --preserveWatchOutput &
|
|
exec npx tsx watch src/worker.ts"
|
|
environment:
|
|
NODE_ENV: development
|
|
MONGODB_URI: mongodb://mongo:27017/workorders
|
|
# ── dev only: long random-looking values so backend validation passes.
|
|
# These are NOT secrets; production reads real values from .env.
|
|
JWT_SECRET: dev-only-e7c1a9f34d5b8e2c0a6f9d1b4c7e3a85
|
|
COOKIE_SECRET: dev-only-b2f6a4d9c8e1b3f7a5c0d2e4f8b6a1c7
|
|
CORS_ORIGIN: http://localhost:5173
|
|
APP_URL: http://localhost:5173
|
|
TRUST_PROXY_HOPS: "0"
|
|
DEBUG_ERRORS: "true"
|
|
LOG_LEVEL: debug
|
|
# The AI_* keys (AI_ENABLED, AI_BASE_URL, AI_API_KEY, ...) are
|
|
# intentionally NOT hardcoded here. In real deployments they come from
|
|
# the API/worker environment; for local containerized dev, uncomment and
|
|
# set them as needed (AI_ENABLED=true requires a real non-private
|
|
# https AI_BASE_URL + AI_API_KEY). Non-container runs pick them up from
|
|
# the repo-root .env via backend env.ts.
|
|
# AI_ENABLED: "false"
|
|
# AI_BASE_URL: https://api.openai.com/v1
|
|
# AI_API_KEY: sk-...
|
|
volumes:
|
|
- ./backend/src:/app/backend/src
|
|
- ./packages/shared/src:/app/packages/shared/src
|
|
depends_on:
|
|
mongo:
|
|
condition: service_healthy
|
|
|
|
vite:
|
|
build:
|
|
context: .
|
|
dockerfile: frontend/Dockerfile
|
|
target: dev
|
|
image: workorders-vite:dev
|
|
restart: unless-stopped
|
|
init: true
|
|
working_dir: /app/frontend
|
|
# Keep packages/shared dist/ fresh for Vite, then start the dev server.
|
|
command: >
|
|
sh -c "npx tsc -p ../packages/shared/tsconfig.json --watch --preserveWatchOutput &
|
|
exec npm run dev -- --host 0.0.0.0"
|
|
environment:
|
|
NODE_ENV: development
|
|
VITE_APP_URL: http://localhost:5173
|
|
VITE_PROXY_TARGET: http://api:4000
|
|
# Unset / empty => Vite dev proxy handles /api (SPEC §10).
|
|
volumes:
|
|
- ./frontend/src:/app/frontend/src
|
|
- ./packages/shared/src:/app/packages/shared/src
|
|
ports:
|
|
- "5173:5173"
|
|
depends_on:
|
|
- api
|
|
|
|
volumes:
|
|
mongo-data:
|