mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-23 21:36:41 +02:00
🚀 feat(matrix-bots): add CI/CD pipeline for automated GHCR deployment
- Update 10 Matrix Bot Dockerfiles for monorepo builds with pnpm - Add shared package support (bot-services, matrix-bot-common) - Extend CI pipeline with change detection and build jobs - Update docker-compose.macmini.yml to use GHCR images - Enable Watchtower auto-updates for Matrix Bots Bots: mana, ollama, stats, project-doc, todo, calendar, nutriphi, zitare, clock, tts Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
f016d5aa82
commit
45152ee954
12 changed files with 923 additions and 206 deletions
|
|
@ -3,45 +3,68 @@ FROM node:20-alpine AS builder
|
|||
|
||||
WORKDIR /app
|
||||
|
||||
# Copy package files (exclude pnpm-lock.yaml to use npm)
|
||||
COPY package.json ./
|
||||
# Enable pnpm via corepack
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
||||
|
||||
# Install dependencies using npm (more compatible with standard tooling)
|
||||
RUN npm install
|
||||
# Copy workspace configuration
|
||||
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
|
||||
|
||||
# Copy source
|
||||
COPY . .
|
||||
# Copy shared packages that this bot depends on
|
||||
COPY packages/bot-services ./packages/bot-services
|
||||
COPY packages/matrix-bot-common ./packages/matrix-bot-common
|
||||
|
||||
# Build using TypeScript
|
||||
RUN rm -rf dist && npx tsc -p tsconfig.build.json
|
||||
# Copy this bot
|
||||
COPY services/matrix-clock-bot ./services/matrix-clock-bot
|
||||
|
||||
# Install all dependencies
|
||||
RUN pnpm install --frozen-lockfile --ignore-scripts
|
||||
|
||||
# Build shared packages first (in dependency order)
|
||||
RUN pnpm --filter @manacore/bot-services build
|
||||
RUN pnpm --filter @manacore/matrix-bot-common build
|
||||
|
||||
# Build the bot
|
||||
RUN pnpm --filter @manacore/matrix-clock-bot build
|
||||
|
||||
# Production stage
|
||||
FROM node:20-alpine AS runner
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
# Create data directory for bot storage
|
||||
RUN mkdir -p /app/data
|
||||
# Enable pnpm via corepack
|
||||
RUN corepack enable && corepack prepare pnpm@9.15.0 --activate
|
||||
|
||||
# Copy package files
|
||||
COPY package.json ./
|
||||
# Copy workspace configuration
|
||||
COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./
|
||||
|
||||
# Copy built shared packages
|
||||
COPY --from=builder /app/packages/bot-services/dist ./packages/bot-services/dist
|
||||
COPY --from=builder /app/packages/bot-services/package.json ./packages/bot-services/
|
||||
COPY --from=builder /app/packages/matrix-bot-common/dist ./packages/matrix-bot-common/dist
|
||||
COPY --from=builder /app/packages/matrix-bot-common/package.json ./packages/matrix-bot-common/
|
||||
|
||||
# Copy built bot
|
||||
COPY --from=builder /app/services/matrix-clock-bot/dist ./services/matrix-clock-bot/dist
|
||||
COPY --from=builder /app/services/matrix-clock-bot/package.json ./services/matrix-clock-bot/
|
||||
|
||||
# Install production dependencies only
|
||||
RUN npm install --omit=dev
|
||||
RUN pnpm install --frozen-lockfile --prod --ignore-scripts
|
||||
|
||||
# Copy built files
|
||||
COPY --from=builder /app/dist ./dist
|
||||
# Create data directory
|
||||
RUN mkdir -p /app/data
|
||||
|
||||
# Create non-root user
|
||||
RUN addgroup --system --gid 1001 nodejs
|
||||
RUN adduser --system --uid 1001 nestjs
|
||||
RUN chown -R nestjs:nodejs /app
|
||||
RUN addgroup --system --gid 1001 nodejs && \
|
||||
adduser --system --uid 1001 nestjs && \
|
||||
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
|
||||
WORKDIR /app/services/matrix-clock-bot
|
||||
|
||||
EXPOSE 3318
|
||||
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
|
||||
CMD wget --no-verbose --tries=1 --spider http://localhost:4018/health || exit 1
|
||||
|
||||
EXPOSE 4018
|
||||
|
||||
CMD ["node", "dist/main.js"]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue