feat: add Docker support and compile shared package to dist

- Add multi-stage Dockerfile for server containerization
- Add .dockerignore to exclude unnecessary files from build context
- Switch shared package from source to compiled CommonJS output (dist/)
- Server dev/build scripts now build shared package first
- Fix deep imports to use @calchat/shared barrel export
- Update CLAUDE.md with Docker and shared package documentation
This commit is contained in:
2026-02-18 19:37:27 +01:00
parent 0c157da817
commit a3e7f0288e
9 changed files with 72 additions and 14 deletions

View File

@@ -26,10 +26,15 @@ npm run lint -w @calchat/client # Run ESLint
npm run build:apk -w @calchat/client # Build APK locally with EAS
```
### Shared (packages/shared)
```bash
npm run build -w @calchat/shared # Compile shared types to dist/
```
### Server (apps/server) - Express.js backend
```bash
npm run dev -w @calchat/server # Start dev server with hot reload (tsx watch)
npm run build -w @calchat/server # Compile TypeScript
npm run dev -w @calchat/server # Build shared + start dev server with hot reload (tsx watch)
npm run build -w @calchat/server # Build shared + compile TypeScript
npm run start -w @calchat/server # Run compiled server (port 3000)
```
@@ -53,6 +58,7 @@ npm run start -w @calchat/server # Run compiled server (port 3000)
| | react-native-logs | Client-side logging |
| | tsdav | CalDAV client library |
| | ical.js | iCalendar parsing/generation |
| Deployment | Docker | Server containerization (multi-stage build) |
| Planned | iCalendar | Event export/import |
## Architecture
@@ -318,6 +324,8 @@ src/
### Shared Package (packages/shared)
The shared package is compiled to `dist/` (CommonJS). All imports must use `@calchat/shared` (NOT `@calchat/shared/src/...`). Server `dev` and `build` scripts automatically build shared first.
```
src/
├── index.ts
@@ -530,6 +538,14 @@ docker compose up -d # Start Radicale CalDAV server
```
- Radicale: `localhost:5232`
### Server Docker Image
```bash
# Build from repo root:
docker build -f apps/server/docker/Dockerfile -t calchat-server .
docker run -p 3000:3000 --env-file apps/server/.env calchat-server
```
Multi-stage build: compiles shared + server in build stage, copies only `dist/` and production dependencies to runtime stage. `.dockerignore` excludes `node_modules`, `dist`, `apps/client`, `.git`, `.env`, `*.md`.
### Environment Variables
Server requires `.env` file in `apps/server/`:
```