mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-15 05:01:08 +02:00
Adds a NestJS service that delivers Umami analytics via Telegram: - Telegram commands: /start, /stats, /today, /week, /realtime, /users - Scheduled reports: Daily at 9:00, Weekly on Monday at 9:00 - Umami API integration with token management - User statistics from auth database - Docker + CI/CD pipeline integration Bot: @stats_mana_bot Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
58 lines
1.3 KiB
Docker
58 lines
1.3 KiB
Docker
# Build stage
|
|
FROM node:20-alpine AS builder
|
|
|
|
# Install pnpm
|
|
RUN npm install -g pnpm@9.15.0
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files for telegram-stats-bot only (standalone build)
|
|
COPY services/telegram-stats-bot/package.json ./
|
|
|
|
# Install all dependencies (including devDependencies for build)
|
|
RUN pnpm install
|
|
|
|
# Copy source code
|
|
COPY services/telegram-stats-bot/src ./src
|
|
COPY services/telegram-stats-bot/tsconfig*.json ./
|
|
COPY services/telegram-stats-bot/nest-cli.json ./
|
|
|
|
# Build the application
|
|
RUN pnpm build
|
|
|
|
# Production stage
|
|
FROM node:20-alpine AS production
|
|
|
|
# Install pnpm
|
|
RUN npm install -g pnpm@9.15.0
|
|
|
|
WORKDIR /app
|
|
|
|
# Copy package files
|
|
COPY --from=builder /app/package.json ./
|
|
|
|
# Install production dependencies only
|
|
RUN pnpm install --prod
|
|
|
|
# Copy built application
|
|
COPY --from=builder /app/dist ./dist
|
|
|
|
# Create non-root user
|
|
RUN addgroup -g 1001 -S nodejs && \
|
|
adduser -S nestjs -u 1001
|
|
|
|
# Change ownership
|
|
RUN chown -R nestjs:nodejs /app
|
|
|
|
# Switch to non-root user
|
|
USER nestjs
|
|
|
|
# Expose port
|
|
EXPOSE 3300
|
|
|
|
# Health check
|
|
HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
|
|
CMD node -e "require('http').get('http://localhost:3300/health', (r) => {process.exit(r.statusCode === 200 ? 0 : 1)})"
|
|
|
|
# Start the application
|
|
CMD ["node", "dist/main"]
|