ration/.github/workflows/docker-build.yml
caelum0x 13abc31645 feat(ration): observability, infra-as-code, security hardening, and test depth
Phase 2 sections 2-6 and 8 of docs/SCALE-EXPANSION.md:

- pkg/telemetry + pkg/metrics: OpenTelemetry trace propagation and
  Prometheus metrics across every service hop (CLI -> agent -> gateway ->
  card-issuance/tenant-registry/auth -> ledger-core), tracing added to
  ledger-core itself via services/ledger-core/src/telemetry.rs.
- infra/: otel-collector + Prometheus + Grafana docker-compose stack, a
  Terraform ECS Fargate module + dev/staging/prod envs (plan-only, no
  apply — real AWS spend is an owner action), and a dev-only mTLS CA
  (infra/dev-ca) wired through pkg/mtls + services/ledger-core/src/mtls.rs.
- services/audit-log (from the prior commit) gets its async mirror writer
  in services/ledger-core/src/audit_mirror.rs, and services/gateway gets
  a per-tenant token-bucket rate limiter (internal/ratelimit).
- Test depth: a Rust proptest suite proving concurrent ApplyEntry never
  breaches the reserve floor (tests/apply_entry_proptest.rs, passing), a Go
  fuzz seed corpus for the policy envelope (rules_fuzz_test.go), a libFuzzer
  harness for the C WAL frame parser (services/wal/fuzz, deliberately not
  wired into `make test` per its own Makefile comment - needs a
  libFuzzer-bundled clang), and a real chaos test
  (scripts/chaos/kill-ledger-mid-write.sh) that SIGKILLs ledger-core
  mid-write under concurrent load and verifies via ListEntries that
  nothing was lost or double-applied.
- docs/formal/ledger.tla: a TLA+ spec of the ledger state machine (balance
  >= reserve_floor safety, HOLD-eventually-resolves liveness) plus a TLC
  model config - not run through TLC in this pass, that's a precise
  documented TODO, not faked.
- docs/adr/0001-0004, docs/RUNBOOK.md, docs/SLO.md, docs/THREAT-MODEL.md.

Verified: `make build && make test` clean (C WAL, Rust incl. the new
proptest suite, all 10 Go modules) from a cold target.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-10-19 12:25:58 +03:00

84 lines
3.0 KiB
YAML

name: Docker build
# Builds (and, on main, pushes) one image per service Dockerfile.
#
# SCALE-EXPANSION.md section 3 (infra-as-code) is what actually adds
# `Dockerfile` under each `services/<name>/` directory; as of this workflow
# being authored none exist yet. Rather than hardcode a service list that
# would hard-fail with "Dockerfile not found" until section 3 lands (or go
# stale the moment a service is renamed/added), this workflow discovers
# `services/*/Dockerfile` at run time. With zero Dockerfiles present, the
# `build` job's matrix resolves to an empty list and the job runs zero
# times — an honest "nothing to build yet" rather than a fake green check
# or a hard failure on files that are a different unit of work's job to add.
#
# TODO(registry): the push target below is GitHub Container Registry under
# this repo (ghcr.io/<owner>/<repo>/<service>), using the repo's own
# GITHUB_TOKEN — a real, working default that needs no owner setup. If the
# owner wants a different registry (ECR, Docker Hub, etc.) that's a config
# change to the `images: ...` tag and the login step's `registry`/
# `username`/`password` inputs, not a structural change to this workflow.
on:
push:
branches: [main]
pull_request:
concurrency:
group: docker-build-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
discover:
name: Discover service Dockerfiles
runs-on: ubuntu-latest
outputs:
services: ${{ steps.find.outputs.services }}
steps:
- uses: actions/checkout@v4
- id: find
name: Find services/*/Dockerfile
run: |
services=$(find services -mindepth 2 -maxdepth 2 -name Dockerfile -print0 \
| xargs -0 -n1 dirname | xargs -n1 basename | sort \
| jq -R -s -c 'split("\n")[:-1]')
echo "services=$services" >> "$GITHUB_OUTPUT"
echo "Discovered service Dockerfiles: $services"
build:
name: Build ${{ matrix.service }}
needs: discover
if: needs.discover.outputs.services != '[]'
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
service: ${{ fromJson(needs.discover.outputs.services) }}
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build (and push on main)
uses: docker/build-push-action@v6
with:
context: .
file: services/${{ matrix.service }}/Dockerfile
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: ghcr.io/${{ github.repository }}/${{ matrix.service }}:${{ github.sha }}
cache-from: type=gha,scope=${{ matrix.service }}
cache-to: type=gha,mode=max,scope=${{ matrix.service }}