diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c40560eb8..657290aaf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,6 +72,16 @@ jobs: nutriphi-web: ${{ steps.changes.outputs.nutriphi-web }} skilltree-backend: ${{ steps.changes.outputs.skilltree-backend }} skilltree-web: ${{ steps.changes.outputs.skilltree-web }} + matrix-mana-bot: ${{ steps.changes.outputs.matrix-mana-bot }} + matrix-ollama-bot: ${{ steps.changes.outputs.matrix-ollama-bot }} + matrix-stats-bot: ${{ steps.changes.outputs.matrix-stats-bot }} + matrix-project-doc-bot: ${{ steps.changes.outputs.matrix-project-doc-bot }} + matrix-todo-bot: ${{ steps.changes.outputs.matrix-todo-bot }} + matrix-calendar-bot: ${{ steps.changes.outputs.matrix-calendar-bot }} + matrix-nutriphi-bot: ${{ steps.changes.outputs.matrix-nutriphi-bot }} + matrix-zitare-bot: ${{ steps.changes.outputs.matrix-zitare-bot }} + matrix-clock-bot: ${{ steps.changes.outputs.matrix-clock-bot }} + matrix-tts-bot: ${{ steps.changes.outputs.matrix-tts-bot }} any-changes: ${{ steps.changes.outputs.any-changes }} steps: - name: Checkout code @@ -108,6 +118,16 @@ jobs: echo "nutriphi-web=true" >> $GITHUB_OUTPUT echo "skilltree-backend=true" >> $GITHUB_OUTPUT echo "skilltree-web=true" >> $GITHUB_OUTPUT + echo "matrix-mana-bot=true" >> $GITHUB_OUTPUT + echo "matrix-ollama-bot=true" >> $GITHUB_OUTPUT + echo "matrix-stats-bot=true" >> $GITHUB_OUTPUT + echo "matrix-project-doc-bot=true" >> $GITHUB_OUTPUT + echo "matrix-todo-bot=true" >> $GITHUB_OUTPUT + echo "matrix-calendar-bot=true" >> $GITHUB_OUTPUT + echo "matrix-nutriphi-bot=true" >> $GITHUB_OUTPUT + echo "matrix-zitare-bot=true" >> $GITHUB_OUTPUT + echo "matrix-clock-bot=true" >> $GITHUB_OUTPUT + echo "matrix-tts-bot=true" >> $GITHUB_OUTPUT echo "any-changes=true" >> $GITHUB_OUTPUT exit 0 fi @@ -148,6 +168,16 @@ jobs: echo "nutriphi-web=true" >> $GITHUB_OUTPUT echo "skilltree-backend=true" >> $GITHUB_OUTPUT echo "skilltree-web=true" >> $GITHUB_OUTPUT + echo "matrix-mana-bot=true" >> $GITHUB_OUTPUT + echo "matrix-ollama-bot=true" >> $GITHUB_OUTPUT + echo "matrix-stats-bot=true" >> $GITHUB_OUTPUT + echo "matrix-project-doc-bot=true" >> $GITHUB_OUTPUT + echo "matrix-todo-bot=true" >> $GITHUB_OUTPUT + echo "matrix-calendar-bot=true" >> $GITHUB_OUTPUT + echo "matrix-nutriphi-bot=true" >> $GITHUB_OUTPUT + echo "matrix-zitare-bot=true" >> $GITHUB_OUTPUT + echo "matrix-clock-bot=true" >> $GITHUB_OUTPUT + echo "matrix-tts-bot=true" >> $GITHUB_OUTPUT echo "any-changes=true" >> $GITHUB_OUTPUT exit 0 fi @@ -162,6 +192,7 @@ jobs: SHARED_AUTH_PATTERN="packages/shared-auth/|packages/shared-types/" SHARED_UI_PATTERN="packages/shared-ui/|packages/shared-theme/|packages/shared-icons/|packages/shared-tailwind/|packages/shared-branding/" SHARED_WEB_PATTERN="packages/shared-auth-ui/|packages/shared-theme-ui/|packages/shared-feedback-ui/|packages/shared-profile-ui/|packages/shared-subscription-ui/|packages/shared-splitscreen/" + SHARED_BOT_PATTERN="packages/bot-services/|packages/matrix-bot-common/" # Function to check if any pattern matches check_pattern() { @@ -174,10 +205,13 @@ jobs: SHARED_UI_CHANGED=$(check_pattern "$SHARED_UI_PATTERN") SHARED_WEB_CHANGED=$(check_pattern "$SHARED_WEB_PATTERN") + SHARED_BOT_CHANGED=$(check_pattern "$SHARED_BOT_PATTERN") + echo "Common changed: $COMMON_CHANGED" echo "Shared auth changed: $SHARED_AUTH_CHANGED" echo "Shared UI changed: $SHARED_UI_CHANGED" echo "Shared web changed: $SHARED_WEB_CHANGED" + echo "Shared bot changed: $SHARED_BOT_CHANGED" # mana-core-auth: services/mana-core-auth + packages/shared-nestjs-auth AUTH_CHANGED=$(check_pattern "services/mana-core-auth/|packages/shared-nestjs-auth/") @@ -363,6 +397,86 @@ jobs: echo "skilltree-web=false" >> $GITHUB_OUTPUT fi + # matrix-mana-bot + MATRIX_MANA_BOT_CHANGED=$(check_pattern "services/matrix-mana-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_MANA_BOT_CHANGED" == "true" ]; then + echo "matrix-mana-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-mana-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-ollama-bot + MATRIX_OLLAMA_BOT_CHANGED=$(check_pattern "services/matrix-ollama-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_OLLAMA_BOT_CHANGED" == "true" ]; then + echo "matrix-ollama-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-ollama-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-stats-bot + MATRIX_STATS_BOT_CHANGED=$(check_pattern "services/matrix-stats-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_STATS_BOT_CHANGED" == "true" ]; then + echo "matrix-stats-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-stats-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-project-doc-bot + MATRIX_PROJECT_DOC_BOT_CHANGED=$(check_pattern "services/matrix-project-doc-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_PROJECT_DOC_BOT_CHANGED" == "true" ]; then + echo "matrix-project-doc-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-project-doc-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-todo-bot + MATRIX_TODO_BOT_CHANGED=$(check_pattern "services/matrix-todo-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_TODO_BOT_CHANGED" == "true" ]; then + echo "matrix-todo-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-todo-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-calendar-bot + MATRIX_CALENDAR_BOT_CHANGED=$(check_pattern "services/matrix-calendar-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_CALENDAR_BOT_CHANGED" == "true" ]; then + echo "matrix-calendar-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-calendar-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-nutriphi-bot + MATRIX_NUTRIPHI_BOT_CHANGED=$(check_pattern "services/matrix-nutriphi-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_NUTRIPHI_BOT_CHANGED" == "true" ]; then + echo "matrix-nutriphi-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-nutriphi-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-zitare-bot + MATRIX_ZITARE_BOT_CHANGED=$(check_pattern "services/matrix-zitare-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_ZITARE_BOT_CHANGED" == "true" ]; then + echo "matrix-zitare-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-zitare-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-clock-bot + MATRIX_CLOCK_BOT_CHANGED=$(check_pattern "services/matrix-clock-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_CLOCK_BOT_CHANGED" == "true" ]; then + echo "matrix-clock-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-clock-bot=false" >> $GITHUB_OUTPUT + fi + + # matrix-tts-bot + MATRIX_TTS_BOT_CHANGED=$(check_pattern "services/matrix-tts-bot/") + if [ "$COMMON_CHANGED" == "true" ] || [ "$SHARED_BOT_CHANGED" == "true" ] || [ "$MATRIX_TTS_BOT_CHANGED" == "true" ]; then + echo "matrix-tts-bot=true" >> $GITHUB_OUTPUT + else + echo "matrix-tts-bot=false" >> $GITHUB_OUTPUT + fi + # Check if any service needs building if grep -q "=true" $GITHUB_OUTPUT; then echo "any-changes=true" >> $GITHUB_OUTPUT @@ -399,6 +513,16 @@ jobs: echo "| nutriphi-web | ${{ steps.changes.outputs.nutriphi-web }} |" >> $GITHUB_STEP_SUMMARY echo "| skilltree-backend | ${{ steps.changes.outputs.skilltree-backend }} |" >> $GITHUB_STEP_SUMMARY echo "| skilltree-web | ${{ steps.changes.outputs.skilltree-web }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-mana-bot | ${{ steps.changes.outputs.matrix-mana-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-ollama-bot | ${{ steps.changes.outputs.matrix-ollama-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-stats-bot | ${{ steps.changes.outputs.matrix-stats-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-project-doc-bot | ${{ steps.changes.outputs.matrix-project-doc-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-todo-bot | ${{ steps.changes.outputs.matrix-todo-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-calendar-bot | ${{ steps.changes.outputs.matrix-calendar-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-nutriphi-bot | ${{ steps.changes.outputs.matrix-nutriphi-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-zitare-bot | ${{ steps.changes.outputs.matrix-zitare-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-clock-bot | ${{ steps.changes.outputs.matrix-clock-bot }} |" >> $GITHUB_STEP_SUMMARY + echo "| matrix-tts-bot | ${{ steps.changes.outputs.matrix-tts-bot }} |" >> $GITHUB_STEP_SUMMARY # =========================================== # Validation job - runs on PRs @@ -1104,3 +1228,297 @@ jobs: tags: ${{ steps.meta.outputs.tags }} cache-from: type=gha cache-to: type=gha,mode=max + + # =========================================== + # Matrix Bots + # =========================================== + + build-matrix-mana-bot: + name: Build matrix-mana-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-mana-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-mana-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-mana-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-ollama-bot: + name: Build matrix-ollama-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-ollama-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-ollama-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-ollama-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-stats-bot: + name: Build matrix-stats-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-stats-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-stats-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-stats-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-project-doc-bot: + name: Build matrix-project-doc-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-project-doc-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-project-doc-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-project-doc-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-todo-bot: + name: Build matrix-todo-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-todo-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-todo-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-todo-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-calendar-bot: + name: Build matrix-calendar-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-calendar-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-calendar-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-calendar-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-nutriphi-bot: + name: Build matrix-nutriphi-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-nutriphi-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-nutriphi-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-nutriphi-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-zitare-bot: + name: Build matrix-zitare-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-zitare-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-zitare-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-zitare-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-clock-bot: + name: Build matrix-clock-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-clock-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-clock-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-clock-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max + + build-matrix-tts-bot: + name: Build matrix-tts-bot + runs-on: ubuntu-latest + needs: detect-changes + if: needs.detect-changes.outputs.matrix-tts-bot == 'true' + steps: + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + - uses: docker/metadata-action@v5 + id: meta + with: + images: ghcr.io/${{ github.repository_owner }}/matrix-tts-bot + tags: type=raw,value=latest + - uses: docker/build-push-action@v5 + with: + context: . + file: services/matrix-tts-bot/Dockerfile + platforms: linux/amd64,linux/arm64 + push: true + tags: ${{ steps.meta.outputs.tags }} + cache-from: type=gha + cache-to: type=gha,mode=max diff --git a/docker-compose.macmini.yml b/docker-compose.macmini.yml index 7a5fd0419..8c85d8527 100644 --- a/docker-compose.macmini.yml +++ b/docker-compose.macmini.yml @@ -514,7 +514,7 @@ services: # Matrix Bots (Ports 4010-4029) matrix-mana-bot: - image: matrix-mana-bot:latest + image: ghcr.io/memo-2023/matrix-mana-bot:latest container_name: mana-matrix-bot-mana restart: always depends_on: @@ -546,7 +546,7 @@ services: start_period: 40s matrix-ollama-bot: - image: matrix-ollama-bot:latest + image: ghcr.io/memo-2023/matrix-ollama-bot:latest container_name: mana-matrix-bot-ollama restart: always depends_on: @@ -574,7 +574,7 @@ services: start_period: 40s matrix-stats-bot: - image: matrix-stats-bot:latest + image: ghcr.io/memo-2023/matrix-stats-bot:latest container_name: mana-matrix-bot-stats restart: always depends_on: @@ -603,7 +603,7 @@ services: start_period: 40s matrix-project-doc-bot: - image: matrix-project-doc-bot:latest + image: ghcr.io/memo-2023/matrix-project-doc-bot:latest container_name: mana-matrix-bot-projectdoc restart: always depends_on: @@ -636,7 +636,7 @@ services: start_period: 40s matrix-todo-bot: - image: matrix-todo-bot:latest + image: ghcr.io/memo-2023/matrix-todo-bot:latest container_name: mana-matrix-bot-todo restart: always depends_on: @@ -661,7 +661,7 @@ services: start_period: 40s matrix-calendar-bot: - image: matrix-calendar-bot:latest + image: ghcr.io/memo-2023/matrix-calendar-bot:latest container_name: mana-matrix-bot-calendar restart: always depends_on: @@ -686,7 +686,7 @@ services: start_period: 40s matrix-nutriphi-bot: - image: matrix-nutriphi-bot:latest + image: ghcr.io/memo-2023/matrix-nutriphi-bot:latest container_name: mana-matrix-bot-nutriphi restart: always depends_on: @@ -713,7 +713,7 @@ services: start_period: 40s matrix-zitare-bot: - image: matrix-zitare-bot:latest + image: ghcr.io/memo-2023/matrix-zitare-bot:latest container_name: mana-matrix-bot-zitare restart: always depends_on: @@ -740,7 +740,7 @@ services: start_period: 40s matrix-clock-bot: - image: matrix-clock-bot:latest + image: ghcr.io/memo-2023/matrix-clock-bot:latest container_name: mana-matrix-bot-clock restart: always depends_on: @@ -767,7 +767,7 @@ services: start_period: 40s matrix-tts-bot: - image: matrix-tts-bot:latest + image: ghcr.io/memo-2023/matrix-tts-bot:latest container_name: mana-matrix-bot-tts restart: always depends_on: diff --git a/services/matrix-calendar-bot/Dockerfile b/services/matrix-calendar-bot/Dockerfile index 7cac324a8..56bd20c69 100644 --- a/services/matrix-calendar-bot/Dockerfile +++ b/services/matrix-calendar-bot/Dockerfile @@ -3,46 +3,68 @@ FROM node:20-alpine AS builder WORKDIR /app -# Copy package files -COPY package.json ./ +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -# Install all dependencies (including devDependencies for build) -RUN npm install +# Copy workspace configuration +COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./ -# Copy source code -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 TypeScript -RUN rm -rf dist && npx tsc -p tsconfig.build.json +# Copy this bot +COPY services/matrix-calendar-bot ./services/matrix-calendar-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-calendar-bot build # Production stage FROM node:20-alpine AS runner WORKDIR /app -# Create data directory for 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-calendar-bot/dist ./services/matrix-calendar-bot/dist +COPY --from=builder /app/services/matrix-calendar-bot/package.json ./services/matrix-calendar-bot/ # Install production dependencies only -RUN npm install --omit=dev +RUN pnpm install --frozen-lockfile --prod --ignore-scripts -# Copy built application -COPY --from=builder /app/dist ./dist +# Create data directory +RUN mkdir -p /app/data # Create non-root user -RUN addgroup -g 1001 -S nodejs && \ - adduser -S nestjs -u 1001 && \ +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=5s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:3315/health || exit 1 +WORKDIR /app/services/matrix-calendar-bot -EXPOSE 3315 +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4015/health || exit 1 + +EXPOSE 4015 CMD ["node", "dist/main.js"] diff --git a/services/matrix-clock-bot/Dockerfile b/services/matrix-clock-bot/Dockerfile index 8de12dee6..d4eb4fb28 100644 --- a/services/matrix-clock-bot/Dockerfile +++ b/services/matrix-clock-bot/Dockerfile @@ -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"] diff --git a/services/matrix-mana-bot/Dockerfile b/services/matrix-mana-bot/Dockerfile index d45cf6a43..d2ce93b5d 100644 --- a/services/matrix-mana-bot/Dockerfile +++ b/services/matrix-mana-bot/Dockerfile @@ -1,29 +1,70 @@ -FROM node:20-slim +# Build stage +FROM node:20-alpine AS builder WORKDIR /app -# Install pnpm -RUN npm install -g pnpm@9 +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -# Copy package files -COPY package.json pnpm-lock.yaml* ./ +# Copy workspace configuration +COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./ -# Install dependencies -RUN pnpm install --frozen-lockfile --prod +# Copy shared packages that this bot depends on +COPY packages/bot-services ./packages/bot-services +COPY packages/matrix-bot-common ./packages/matrix-bot-common -# Copy source -COPY . . +# Copy this bot +COPY services/matrix-mana-bot ./services/matrix-mana-bot -# Build -RUN pnpm build +# 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 matrix-mana-bot build + +# Production stage +FROM node:20-alpine AS runner + +WORKDIR /app + +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate + +# 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-mana-bot/dist ./services/matrix-mana-bot/dist +COPY --from=builder /app/services/matrix-mana-bot/package.json ./services/matrix-mana-bot/ + +# Install production dependencies only +RUN pnpm install --frozen-lockfile --prod --ignore-scripts # Create data directory RUN mkdir -p /app/data -# Health check -HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD curl -f http://localhost:3310/health || exit 1 +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nestjs && \ + chown -R nestjs:nodejs /app -EXPOSE 3310 +USER nestjs + +WORKDIR /app/services/matrix-mana-bot + +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4010/health || exit 1 + +EXPOSE 4010 CMD ["node", "dist/main.js"] diff --git a/services/matrix-nutriphi-bot/Dockerfile b/services/matrix-nutriphi-bot/Dockerfile index 03e956aec..5bc16553f 100644 --- a/services/matrix-nutriphi-bot/Dockerfile +++ b/services/matrix-nutriphi-bot/Dockerfile @@ -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-nutriphi-bot ./services/matrix-nutriphi-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-nutriphi-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-nutriphi-bot/dist ./services/matrix-nutriphi-bot/dist +COPY --from=builder /app/services/matrix-nutriphi-bot/package.json ./services/matrix-nutriphi-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:3316/health || exit 1 +WORKDIR /app/services/matrix-nutriphi-bot -EXPOSE 3316 +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4016/health || exit 1 + +EXPOSE 4016 CMD ["node", "dist/main.js"] diff --git a/services/matrix-ollama-bot/Dockerfile b/services/matrix-ollama-bot/Dockerfile index 82cdf37cb..4c2a1099e 100644 --- a/services/matrix-ollama-bot/Dockerfile +++ b/services/matrix-ollama-bot/Dockerfile @@ -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-ollama-bot ./services/matrix-ollama-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-ollama-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-ollama-bot/dist ./services/matrix-ollama-bot/dist +COPY --from=builder /app/services/matrix-ollama-bot/package.json ./services/matrix-ollama-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:3311/health || exit 1 +WORKDIR /app/services/matrix-ollama-bot -EXPOSE 3311 +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4011/health || exit 1 + +EXPOSE 4011 CMD ["node", "dist/main.js"] diff --git a/services/matrix-project-doc-bot/Dockerfile b/services/matrix-project-doc-bot/Dockerfile index a0d7fe451..6868bb5c3 100644 --- a/services/matrix-project-doc-bot/Dockerfile +++ b/services/matrix-project-doc-bot/Dockerfile @@ -1,25 +1,70 @@ +# Build stage FROM node:20-alpine AS builder -WORKDIR /app -RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -COPY package.json pnpm-lock.yaml* ./ -RUN pnpm install --frozen-lockfile --ignore-scripts || pnpm install --ignore-scripts -COPY . . -RUN pnpm build -FROM node:20-alpine AS runner WORKDIR /app + +# Enable pnpm via corepack RUN corepack enable && corepack prepare pnpm@9.15.0 --activate + +# Copy workspace configuration +COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./ + +# Copy shared packages that this bot depends on +COPY packages/bot-services ./packages/bot-services +COPY packages/matrix-bot-common ./packages/matrix-bot-common + +# Copy this bot +COPY services/matrix-project-doc-bot ./services/matrix-project-doc-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-project-doc-bot build + +# Production stage +FROM node:20-alpine AS runner + +WORKDIR /app + +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate + +# 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-project-doc-bot/dist ./services/matrix-project-doc-bot/dist +COPY --from=builder /app/services/matrix-project-doc-bot/package.json ./services/matrix-project-doc-bot/ + +# Install production dependencies only +RUN pnpm install --frozen-lockfile --prod --ignore-scripts + +# Create data directory RUN mkdir -p /app/data -COPY package.json pnpm-lock.yaml* ./ -RUN pnpm install --prod --frozen-lockfile --ignore-scripts || pnpm install --prod --ignore-scripts -COPY --from=builder /app/dist ./dist -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nestjs -RUN chown -R nestjs:nodejs /app + +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nestjs && \ + chown -R nestjs:nodejs /app + USER nestjs -HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:3313/health || exit 1 +WORKDIR /app/services/matrix-project-doc-bot -EXPOSE 3313 -CMD ["node", "dist/src/main.js"] +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4013/health || exit 1 + +EXPOSE 4013 + +CMD ["node", "dist/main.js"] diff --git a/services/matrix-stats-bot/Dockerfile b/services/matrix-stats-bot/Dockerfile index 0f92d875e..17fbf85b0 100644 --- a/services/matrix-stats-bot/Dockerfile +++ b/services/matrix-stats-bot/Dockerfile @@ -1,25 +1,70 @@ +# Build stage FROM node:20-alpine AS builder -WORKDIR /app -RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -COPY package.json pnpm-lock.yaml* ./ -RUN pnpm install --frozen-lockfile --ignore-scripts || pnpm install --ignore-scripts -COPY . . -RUN pnpm build -FROM node:20-alpine AS runner WORKDIR /app + +# Enable pnpm via corepack RUN corepack enable && corepack prepare pnpm@9.15.0 --activate + +# Copy workspace configuration +COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./ + +# Copy shared packages that this bot depends on +COPY packages/bot-services ./packages/bot-services +COPY packages/matrix-bot-common ./packages/matrix-bot-common + +# Copy this bot +COPY services/matrix-stats-bot ./services/matrix-stats-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-stats-bot build + +# Production stage +FROM node:20-alpine AS runner + +WORKDIR /app + +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate + +# 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-stats-bot/dist ./services/matrix-stats-bot/dist +COPY --from=builder /app/services/matrix-stats-bot/package.json ./services/matrix-stats-bot/ + +# Install production dependencies only +RUN pnpm install --frozen-lockfile --prod --ignore-scripts + +# Create data directory RUN mkdir -p /app/data -COPY package.json pnpm-lock.yaml* ./ -RUN pnpm install --prod --frozen-lockfile --ignore-scripts || pnpm install --prod --ignore-scripts -COPY --from=builder /app/dist ./dist -RUN addgroup --system --gid 1001 nodejs -RUN adduser --system --uid 1001 nestjs -RUN chown -R nestjs:nodejs /app + +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nestjs && \ + chown -R nestjs:nodejs /app + USER nestjs -HEALTHCHECK --interval=30s --timeout=10s --start-period=40s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:3312/health || exit 1 +WORKDIR /app/services/matrix-stats-bot + +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4012/health || exit 1 + +EXPOSE 4012 -EXPOSE 3312 CMD ["node", "dist/main.js"] diff --git a/services/matrix-todo-bot/Dockerfile b/services/matrix-todo-bot/Dockerfile index 1e79d7d56..3a9d9aab5 100644 --- a/services/matrix-todo-bot/Dockerfile +++ b/services/matrix-todo-bot/Dockerfile @@ -3,46 +3,68 @@ FROM node:20-alpine AS builder WORKDIR /app -# Copy package files -COPY package.json ./ +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -# Install all dependencies (including devDependencies for build) -RUN npm install +# Copy workspace configuration +COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./ -# Copy source code -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 TypeScript -RUN rm -rf dist && npx tsc -p tsconfig.build.json +# Copy this bot +COPY services/matrix-todo-bot ./services/matrix-todo-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-todo-bot build # Production stage FROM node:20-alpine AS runner WORKDIR /app -# Create data directory for 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-todo-bot/dist ./services/matrix-todo-bot/dist +COPY --from=builder /app/services/matrix-todo-bot/package.json ./services/matrix-todo-bot/ # Install production dependencies only -RUN npm install --omit=dev +RUN pnpm install --frozen-lockfile --prod --ignore-scripts -# Copy built application -COPY --from=builder /app/dist ./dist +# Create data directory +RUN mkdir -p /app/data # Create non-root user -RUN addgroup -g 1001 -S nodejs && \ - adduser -S nestjs -u 1001 && \ +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=5s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:3314/health || exit 1 +WORKDIR /app/services/matrix-todo-bot -EXPOSE 3314 +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4014/health || exit 1 + +EXPOSE 4014 CMD ["node", "dist/main.js"] diff --git a/services/matrix-tts-bot/Dockerfile b/services/matrix-tts-bot/Dockerfile index f7e79b9f2..10e7388a5 100644 --- a/services/matrix-tts-bot/Dockerfile +++ b/services/matrix-tts-bot/Dockerfile @@ -1,44 +1,70 @@ +# Build stage FROM node:20-alpine AS builder WORKDIR /app -# Install pnpm +# 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 ./ -# Install dependencies -RUN pnpm install --ignore-scripts +# Copy shared packages that this bot depends on +COPY packages/bot-services ./packages/bot-services +COPY packages/matrix-bot-common ./packages/matrix-bot-common -# Copy source -COPY . . +# Copy this bot +COPY services/matrix-tts-bot ./services/matrix-tts-bot -# Build -RUN pnpm build +# Install all dependencies +RUN pnpm install --frozen-lockfile --ignore-scripts -# Production image -FROM node:20-alpine +# 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-tts-bot build + +# Production stage +FROM node:20-alpine AS runner WORKDIR /app -# Install pnpm +# Enable pnpm via corepack RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -# Copy package files and built code -COPY --from=builder /app/package.json ./ -COPY --from=builder /app/node_modules ./node_modules -COPY --from=builder /app/dist ./dist +# 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-tts-bot/dist ./services/matrix-tts-bot/dist +COPY --from=builder /app/services/matrix-tts-bot/package.json ./services/matrix-tts-bot/ + +# Install production dependencies only +RUN pnpm install --frozen-lockfile --prod --ignore-scripts # Create data directory RUN mkdir -p /app/data -# Run as non-root user -RUN addgroup -g 1001 -S nodejs && \ - adduser -S nestjs -u 1001 && \ +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nestjs && \ chown -R nestjs:nodejs /app + USER nestjs -EXPOSE 3023 +WORKDIR /app/services/matrix-tts-bot + +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4019/health || exit 1 + +EXPOSE 4019 CMD ["node", "dist/main.js"] diff --git a/services/matrix-zitare-bot/Dockerfile b/services/matrix-zitare-bot/Dockerfile index 88740d71f..5fc7936a7 100644 --- a/services/matrix-zitare-bot/Dockerfile +++ b/services/matrix-zitare-bot/Dockerfile @@ -3,39 +3,68 @@ FROM node:20-alpine AS builder WORKDIR /app -# Copy package files -COPY package.json ./ +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -# Install dependencies -RUN npm install +# Copy workspace configuration +COPY pnpm-workspace.yaml package.json pnpm-lock.yaml ./ -# Copy source code -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 the application -RUN npm run build +# Copy this bot +COPY services/matrix-zitare-bot ./services/matrix-zitare-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-zitare-bot build # Production stage -FROM node:20-alpine +FROM node:20-alpine AS runner WORKDIR /app -# Copy package files and install production dependencies only -COPY package.json ./ -RUN npm install --omit=dev +# Enable pnpm via corepack +RUN corepack enable && corepack prepare pnpm@9.15.0 --activate -# Copy built application from builder -COPY --from=builder /app/dist ./dist +# 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-zitare-bot/dist ./services/matrix-zitare-bot/dist +COPY --from=builder /app/services/matrix-zitare-bot/package.json ./services/matrix-zitare-bot/ + +# Install production dependencies only +RUN pnpm install --frozen-lockfile --prod --ignore-scripts # Create data directory RUN mkdir -p /app/data -# Expose port -EXPOSE 3317 +# Create non-root user +RUN addgroup --system --gid 1001 nodejs && \ + adduser --system --uid 1001 nestjs && \ + chown -R nestjs:nodejs /app -# Health check -HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \ - CMD wget --no-verbose --tries=1 --spider http://localhost:3317/health || exit 1 +USER nestjs + +WORKDIR /app/services/matrix-zitare-bot + +HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \ + CMD wget --no-verbose --tries=1 --spider http://localhost:4017/health || exit 1 + +EXPOSE 4017 -# Start the application CMD ["node", "dist/main.js"]