diff --git a/docker-compose.macmini.yml b/docker-compose.macmini.yml index 878c5e418..71ce1878a 100644 --- a/docker-compose.macmini.yml +++ b/docker-compose.macmini.yml @@ -208,6 +208,7 @@ services: # Cross-domain SSO: share session cookies across all *.mana.how subdomains COOKIE_DOMAIN: .mana.how MANA_CORE_SERVICE_KEY: ${MANA_CORE_SERVICE_KEY} + MANA_CREDITS_URL: http://mana-credits:3061 SMTP_HOST: smtp-relay.brevo.com SMTP_PORT: 587 SMTP_USER: ${SMTP_USER:-94cde5002@smtp-brevo.com} @@ -243,6 +244,44 @@ services: retries: 3 start_period: 40s + # ============================================ + # Tier 1b: Credits Service (Hono + Bun) + # ============================================ + + mana-credits: + build: + context: services/mana-credits + dockerfile: Dockerfile + image: mana-credits:local + container_name: mana-credits + restart: always + depends_on: + postgres: + condition: service_healthy + environment: + TZ: Europe/Berlin + PORT: 3061 + DATABASE_URL: postgresql://postgres:${POSTGRES_PASSWORD:-mana123}@postgres:5432/mana_credits + MANA_CORE_AUTH_URL: http://mana-auth:3001 + MANA_CORE_SERVICE_KEY: ${MANA_CORE_SERVICE_KEY} + STRIPE_SECRET_KEY: ${STRIPE_SECRET_KEY:-} + STRIPE_WEBHOOK_SECRET: ${STRIPE_CREDITS_WEBHOOK_SECRET:-} + BASE_URL: https://credits.mana.how + CORS_ORIGINS: https://mana.how,https://chat.mana.how,https://picture.mana.how,https://todo.mana.how,https://zitare.mana.how,https://calendar.mana.how,https://clock.mana.how,https://contacts.mana.how,https://manadeck.mana.how,https://presi.mana.how,https://storage.mana.how,https://nutriphi.mana.how,https://planta.mana.how,https://mukke.mana.how,https://context.mana.how,https://photos.mana.how,https://questions.mana.how + ports: + - "3061:3061" + healthcheck: + test: ["CMD", "bun", "-e", "fetch('http://127.0.0.1:3061/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"] + interval: 120s + timeout: 10s + retries: 3 + start_period: 15s + labels: + - "traefik.enable=true" + - "traefik.http.routers.mana-credits.rule=Host(`credits.mana.how`)" + - "traefik.http.routers.mana-credits.tls=true" + - "traefik.http.services.mana-credits.loadbalancer.server.port=3061" + # ============================================ # Tier 2: Gateway & Search Services (Ports 3010-3029) # ============================================ diff --git a/services/mana-core-auth/src/auth/services/better-auth.service.ts b/services/mana-core-auth/src/auth/services/better-auth.service.ts index 38ffa37fb..778c6e160 100644 --- a/services/mana-core-auth/src/auth/services/better-auth.service.ts +++ b/services/mana-core-auth/src/auth/services/better-auth.service.ts @@ -151,7 +151,7 @@ export class BetterAuthService { // Redeem any pending gift codes via mana-credits service try { - const creditsUrl = process.env.MANA_CREDITS_URL || 'http://localhost:3060'; + const creditsUrl = process.env.MANA_CREDITS_URL || 'http://localhost:3061'; const serviceKey = process.env.MANA_CORE_SERVICE_KEY || ''; const giftRes = await fetch(`${creditsUrl}/api/v1/internal/gifts/redeem-pending`, { method: 'POST', @@ -1758,7 +1758,7 @@ export class BetterAuthService { */ private async createPersonalCreditBalance(userId: string) { try { - const creditsUrl = process.env.MANA_CREDITS_URL || 'http://localhost:3060'; + const creditsUrl = process.env.MANA_CREDITS_URL || 'http://localhost:3061'; const serviceKey = process.env.MANA_CORE_SERVICE_KEY || ''; await fetch(`${creditsUrl}/api/v1/internal/credits/init`, { method: 'POST', @@ -1778,7 +1778,7 @@ export class BetterAuthService { */ private async initializeGuildPool(organizationId: string) { try { - const creditsUrl = process.env.MANA_CREDITS_URL || 'http://localhost:3060'; + const creditsUrl = process.env.MANA_CREDITS_URL || 'http://localhost:3061'; const serviceKey = process.env.MANA_CORE_SERVICE_KEY || ''; await fetch(`${creditsUrl}/api/v1/internal/guild-pool/init`, { method: 'POST', diff --git a/services/mana-credits/CLAUDE.md b/services/mana-credits/CLAUDE.md index f323bbdb5..6dfac9d9c 100644 --- a/services/mana-credits/CLAUDE.md +++ b/services/mana-credits/CLAUDE.md @@ -23,7 +23,7 @@ bun run db:push # Push schema bun run db:studio # Open Drizzle Studio ``` -## Port: 3060 +## Port: 3061 ## API Endpoints @@ -81,11 +81,11 @@ bun run db:studio # Open Drizzle Studio ## Environment Variables ```env -PORT=3060 +PORT=3061 DATABASE_URL=postgresql://manacore:devpassword@localhost:5432/mana_credits MANA_CORE_AUTH_URL=http://localhost:3001 MANA_CORE_SERVICE_KEY=dev-service-key -BASE_URL=http://localhost:3060 +BASE_URL=http://localhost:3061 STRIPE_SECRET_KEY=sk_test_... STRIPE_WEBHOOK_SECRET=whsec_... CORS_ORIGINS=http://localhost:5173,http://localhost:5180 diff --git a/services/mana-credits/Dockerfile b/services/mana-credits/Dockerfile index a15514e96..4b7ab300e 100644 --- a/services/mana-credits/Dockerfile +++ b/services/mana-credits/Dockerfile @@ -10,9 +10,9 @@ RUN bun install --frozen-lockfile 2>/dev/null || bun install COPY src ./src COPY tsconfig.json drizzle.config.ts ./ -EXPOSE 3060 +EXPOSE 3061 HEALTHCHECK --interval=30s --timeout=10s --start-period=10s --retries=3 \ - CMD bun -e "fetch('http://localhost:3060/health').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))" + CMD bun -e "fetch('http://localhost:3061/health').then(r => process.exit(r.ok ? 0 : 1)).catch(() => process.exit(1))" CMD ["bun", "run", "src/index.ts"] diff --git a/services/mana-credits/src/config.ts b/services/mana-credits/src/config.ts index 5603fafe8..70920cdbe 100644 --- a/services/mana-credits/src/config.ts +++ b/services/mana-credits/src/config.ts @@ -25,7 +25,7 @@ export function loadConfig(): Config { }; return { - port: parseInt(process.env.PORT || '3060', 10), + port: parseInt(process.env.PORT || '3061', 10), databaseUrl: requiredEnv( 'DATABASE_URL', 'postgresql://manacore:devpassword@localhost:5432/mana_credits'