Files
huajishe-tts/docker-compose.yml
Claude 585930cc19 feat(multiplayer): LAN/local online mode via SocketIO
Phase 2 (local LAN) — server runs on tsx (0.0.0.0:8000), two clients
in the same room sync state via SocketIO. Tested end-to-end with 2
browser tabs.

server:
- src/index.ts: read ALLOWED_ORIGINS env, register all 3 games
  (War, Mill, DragTest), add /healthz endpoint, SIGTERM handler
- package.json: 'start' uses 'node --import tsx' for prod-like run
- Dockerfile: multi-stage build (pnpm install → tsc → pnpm deploy prod
  deps → alpine runtime, non-root, healthcheck)
- docker-compose.yml at repo root for local stack
- Wars.ts: add turn: { activePlayers: ActivePlayers.ALL } so P1 can
  call collect (SocketIO transport rejects moves from non-currentPlayer)

web/App.tsx:
- Add mode toggle: 本地 / 联机
- OnlineConfigBar: server URL (default http://localhost:8000),
  matchID, playerID, credentials; persisted to localStorage
- CardOnlineView / MillOnlineView: SocketIO transport with config
  server, no debug panel
- OnlineClient rendered with matchID + playerID + credentials

Verified with 2 Playwright tabs:
- Tab 0 (player 0, secret p0) clicks 翻牌: 26→25 decks, 1 card each pile
- Tab 1 (player 1, secret p1) sees identical state
- Tab 1 clicks 收牌: 7♣ wins, p0-deck 25→27, piles empty
- Tab 0 sees the exact same final state
2026-08-17 21:07:49 +08:00

31 lines
931 B
YAML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 本地开发 + 部署模板
#
# 用法:
# docker compose up --build 启动 server端口 8000
# docker compose down 停止
#
# 生产部署时把这一份拷到部署服务器,根据实际域名/Origin 改环境变量。
services:
server:
build:
context: .
dockerfile: packages/server/Dockerfile
image: tts-like-server:latest
container_name: tts-like-server
restart: unless-stopped
ports:
- "8000:8000"
environment:
NODE_ENV: production
PORT: 8000
# 生产改成你的真实域名(逗号分隔)
ALLOWED_ORIGINS: "https://play.example.com,https://www.example.com"
healthcheck:
test: ["CMD", "wget", "-qO-", "http://localhost:8000/healthz"]
interval: 30s
timeout: 5s
retries: 3
# 反向代理假设Nginx/Caddy 终止 TLS转发到 host:8000
# wss://play.example.com -> ws://server:8000