feat(matrix-clock-bot): add Matrix bot for time tracking

- Add Docker build configuration with npm overrides for matrix-sdk
- Update port from 3317 to 3318 to avoid conflict with Zitare bot
- Add tsconfig.build.json for production builds
- Add clock-bot service to docker-compose.macmini.yml
- Bot supports timers, alarms, and world clocks via Matrix chat

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Till-JS 2026-01-28 17:04:45 +01:00
parent 9a7afea7fe
commit e2a3277fa1
7 changed files with 90 additions and 19 deletions

View file

@ -1099,6 +1099,37 @@ services:
retries: 3
start_period: 40s
# ============================================
# Matrix Clock Bot (GDPR-compliant Time Tracking)
# ============================================
matrix-clock-bot:
image: matrix-clock-bot:latest
container_name: manacore-matrix-clock-bot
restart: always
depends_on:
synapse:
condition: service_healthy
environment:
NODE_ENV: production
PORT: 3318
TZ: Europe/Berlin
MATRIX_HOMESERVER_URL: http://synapse:8008
MATRIX_ACCESS_TOKEN: ${MATRIX_CLOCK_BOT_TOKEN}
MATRIX_ALLOWED_ROOMS: ${MATRIX_CLOCK_BOT_ROOMS:-}
CLOCK_API_URL: http://host.docker.internal:3017/api/v1
STT_URL: http://mana-stt:3020
volumes:
- matrix_clock_bot_data:/app/data
ports:
- "3318:3318"
healthcheck:
test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://127.0.0.1:3318/health"]
interval: 30s
timeout: 10s
retries: 3
start_period: 40s
# ============================================
# Auto-Update (Watchtower)
# ============================================
@ -1155,3 +1186,5 @@ volumes:
name: manacore-matrix-nutriphi-bot
matrix_zitare_bot_data:
name: manacore-matrix-zitare-bot
matrix_clock_bot_data:
name: manacore-matrix-clock-bot

View file

@ -30,7 +30,7 @@ pnpm type-check # Check TypeScript types
```
services/matrix-clock-bot/
├── src/
│ ├── main.ts # Application entry point (port 3317)
│ ├── main.ts # Application entry point (port 3318)
│ ├── app.module.ts # Root module
│ ├── health.controller.ts # Health check endpoint
│ ├── config/
@ -94,7 +94,7 @@ Voice notes are transcribed and parsed as commands.
```env
# Server
PORT=3317
PORT=3318
# Matrix
MATRIX_HOMESERVER_URL=http://localhost:8008
@ -133,7 +133,7 @@ STT_URL=http://localhost:3020
docker build -f services/matrix-clock-bot/Dockerfile -t matrix-clock-bot services/matrix-clock-bot
# Run
docker run -p 3317:3317 \
docker run -p 3318:3318 \
-e MATRIX_HOMESERVER_URL=http://synapse:8008 \
-e MATRIX_ACCESS_TOKEN=syt_xxx \
-e CLOCK_API_URL=http://clock-backend:3017/api/v1 \
@ -145,7 +145,7 @@ docker run -p 3317:3317 \
## Health Check
```bash
curl http://localhost:3317/health
curl http://localhost:3318/health
```
## Authentication

View file

@ -1,25 +1,47 @@
FROM node:20-alpine
# Build stage
FROM node:20-alpine AS builder
WORKDIR /app
# Install pnpm
RUN npm install -g pnpm
# Copy package files (exclude pnpm-lock.yaml to use npm)
COPY package.json ./
# Copy package files
COPY package.json pnpm-lock.yaml* ./
# Install dependencies
RUN pnpm install --frozen-lockfile || pnpm install
# Install dependencies using npm (more compatible with standard tooling)
RUN npm install
# Copy source
COPY . .
# Build
RUN pnpm build
# Build using TypeScript
RUN rm -rf dist && npx tsc -p tsconfig.build.json
# Create data directory
# Production stage
FROM node:20-alpine AS runner
WORKDIR /app
# Create data directory for bot storage
RUN mkdir -p /app/data
EXPOSE 3317
# Copy package files
COPY package.json ./
# Install production dependencies only
RUN npm install --omit=dev
# Copy built files
COPY --from=builder /app/dist ./dist
# Create non-root user
RUN addgroup --system --gid 1001 nodejs
RUN adduser --system --uid 1001 nestjs
RUN chown -R nestjs:nodejs /app
USER nestjs
# Health check
HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \
CMD wget --no-verbose --tries=1 --spider http://localhost:3318/health || exit 1
EXPOSE 3318
CMD ["node", "dist/main.js"]

View file

@ -3,8 +3,20 @@
"version": "1.0.0",
"description": "Matrix bot for time tracking with Clock app",
"private": true,
"pnpm": {
"neverBuiltDependencies": [
"@matrix-org/matrix-sdk-crypto-nodejs"
],
"overrides": {
"@matrix-org/matrix-sdk-crypto-nodejs": "npm:empty-npm-package@1.0.0"
}
},
"overrides": {
"@matrix-org/matrix-sdk-crypto-nodejs": "npm:empty-npm-package@1.0.0"
},
"scripts": {
"build": "nest build",
"prebuild": "rm -rf dist || true",
"build": "tsc -p tsconfig.build.json",
"start": "nest start",
"start:dev": "nest start --watch",
"start:debug": "nest start --debug --watch",

View file

@ -4,7 +4,7 @@ import { Logger } from '@nestjs/common';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const port = process.env.PORT || 3317;
const port = process.env.PORT || 3318;
await app.listen(port);

View file

@ -0,0 +1,4 @@
{
"extends": "./tsconfig.json",
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
}

View file

@ -6,7 +6,7 @@
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2021",
"target": "ES2022",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",