mirror of
https://github.com/Memo-2023/mana-monorepo.git
synced 2026-05-14 23:41:08 +02:00
Validates workspace dependencies and Dockerfile freshness before Docker builds. Catches missing deps and outdated COPYs in PRs. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
129 lines
3.7 KiB
YAML
129 lines
3.7 KiB
YAML
# Docker Validation: Validates Dockerfiles and builds representative images on PRs
|
|
#
|
|
# Flow:
|
|
# PR → main : Validates Dockerfiles + builds representative Docker images
|
|
# Push → main : Same validation (catches force-merges)
|
|
#
|
|
# The build job tests a representative subset of images that covers
|
|
# all shared packages without building all 40+ services.
|
|
|
|
name: Docker Validate
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '**/Dockerfile'
|
|
- '**/package.json'
|
|
- 'packages/**'
|
|
- 'apps/**'
|
|
- 'services/**'
|
|
- 'pnpm-lock.yaml'
|
|
- 'pnpm-workspace.yaml'
|
|
- '.github/workflows/docker-validate.yml'
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
paths:
|
|
- '**/Dockerfile'
|
|
- '**/package.json'
|
|
- 'packages/**'
|
|
- 'apps/**'
|
|
- 'services/**'
|
|
- 'pnpm-lock.yaml'
|
|
- 'pnpm-workspace.yaml'
|
|
- '.github/workflows/docker-validate.yml'
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
env:
|
|
NODE_VERSION: '20'
|
|
PNPM_VERSION: '9.15.0'
|
|
|
|
jobs:
|
|
# ===========================================
|
|
# Job 1: Validate Dockerfiles (fast, no Docker needed)
|
|
# ===========================================
|
|
validate-dockerfiles:
|
|
name: Validate Dockerfiles
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup pnpm
|
|
uses: pnpm/action-setup@v2
|
|
with:
|
|
version: ${{ env.PNPM_VERSION }}
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: ${{ env.NODE_VERSION }}
|
|
cache: 'pnpm'
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile
|
|
|
|
- name: Audit workspace dependencies
|
|
run: pnpm audit:deps
|
|
|
|
- name: Check Dockerfiles are up to date
|
|
run: pnpm generate:dockerfiles -- --check
|
|
|
|
- name: Validate Dockerfiles
|
|
run: pnpm validate:dockerfiles
|
|
|
|
# ===========================================
|
|
# Job 2: Build representative Docker images
|
|
# ===========================================
|
|
# Builds a subset that covers all shared packages:
|
|
# - mana-core-auth: covers shared-storage, shared-nestjs-auth, shared-llm
|
|
# - todo-web: covers most shared-* web packages
|
|
# - zitare-web: covers content packages, shared-pwa
|
|
# - calendar-web: covers calendar shared packages
|
|
# - todo-backend: covers NestJS backend pattern + shared packages
|
|
# ===========================================
|
|
build-docker-images:
|
|
name: Build ${{ matrix.service }}
|
|
runs-on: ubuntu-latest
|
|
needs: validate-dockerfiles
|
|
timeout-minutes: 20
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
- service: mana-core-auth
|
|
dockerfile: services/mana-core-auth/Dockerfile
|
|
context: .
|
|
- service: todo-backend
|
|
dockerfile: apps/todo/apps/backend/Dockerfile
|
|
context: .
|
|
- service: todo-web
|
|
dockerfile: apps/todo/apps/web/Dockerfile
|
|
context: .
|
|
- service: zitare-web
|
|
dockerfile: apps/zitare/apps/web/Dockerfile
|
|
context: .
|
|
- service: calendar-web
|
|
dockerfile: apps/calendar/apps/web/Dockerfile
|
|
context: .
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v3
|
|
|
|
- name: Build ${{ matrix.service }}
|
|
uses: docker/build-push-action@v5
|
|
with:
|
|
context: ${{ matrix.context }}
|
|
file: ${{ matrix.dockerfile }}
|
|
push: false
|
|
cache-from: type=gha,scope=${{ matrix.service }}
|
|
cache-to: type=gha,scope=${{ matrix.service }},mode=max
|