Fix P2 SaaS compilation: wire dispatchNotifications correctly, add P1/P2 Dockerfiles

- P2 processor: use correct dispatchNotifications signature (channels, notification, severity)
- P2 processor: pass pool to withTenant, fix implicit any types
- P1 Dockerfile: multi-stage Rust build for proxy/api/worker binaries
- P2 agent Dockerfile: multi-stage Go build
- P2 SaaS package-lock.json generated
- All 6 products now compile cleanly
This commit is contained in:
2026-03-01 06:10:21 +00:00
parent 4146f1c4d0
commit 5e0065e73e
4 changed files with 7146 additions and 14 deletions

View File

@@ -0,0 +1,15 @@
# P1: dd0c/route — Rust multi-binary (proxy, api, worker)
FROM rust:1.79-slim AS builder
WORKDIR /app
RUN apt-get update && apt-get install -y pkg-config libssl-dev && rm -rf /var/lib/apt/lists/*
COPY Cargo.toml Cargo.lock* ./
COPY src/ src/
RUN cargo build --release
FROM debian:bookworm-slim
RUN apt-get update && apt-get install -y ca-certificates libssl3 && rm -rf /var/lib/apt/lists/*
COPY --from=builder /app/target/release/dd0c-proxy /usr/local/bin/
COPY --from=builder /app/target/release/dd0c-api /usr/local/bin/
COPY --from=builder /app/target/release/dd0c-worker /usr/local/bin/
EXPOSE 8080 3000
CMD ["dd0c-api"]

View File

@@ -1,13 +1,12 @@
# --- Build stage --- # P2: dd0c/drift agent — Go binary
FROM golang:1.22-alpine AS builder FROM golang:1.22-alpine AS builder
WORKDIR /app WORKDIR /app
COPY go.mod go.sum ./ COPY go.mod go.sum* ./
RUN go mod download RUN go mod download
COPY . . COPY . .
RUN CGO_ENABLED=0 GOOS=linux go build -o /drift ./cmd/drift RUN CGO_ENABLED=0 go build -o dd0c-drift ./cmd/main.go
# --- Runtime stage --- FROM alpine:3.20
FROM alpine:3.19
RUN apk add --no-cache ca-certificates RUN apk add --no-cache ca-certificates
COPY --from=builder /drift /usr/local/bin/drift COPY --from=builder /app/dd0c-drift /usr/local/bin/
ENTRYPOINT ["drift"] ENTRYPOINT ["dd0c-drift"]

File diff suppressed because it is too large Load Diff

View File

@@ -59,14 +59,30 @@ export async function registerProcessorRoutes(app: FastifyInstance) {
// Trigger notification if drift score exceeds threshold // Trigger notification if drift score exceeds threshold
if (report.drift_score > 0) { if (report.drift_score > 0) {
try { try {
const { DriftNotificationService } = await import('../notifications/service.js'); const { dispatchNotifications, shouldNotify } = await import('../notifications/service.js');
const notifService = new DriftNotificationService(pool); const { withTenant } = await import('../data/db.js');
await notifService.notifyDrift(tenantId, {
stackName: report.stack_name, const maxSeverity = report.drifted_resources?.some((r: any) => r.severity === 'critical') ? 'critical'
driftScore: report.drift_score, : report.drifted_resources?.some((r: any) => r.severity === 'high') ? 'high' : 'medium';
totalResources: report.total_resources,
driftedResources: report.drifted_resources?.length ?? 0, // Fetch tenant notification channels
const channelResult = await withTenant(pool, tenantId, async (client: any) => {
return client.query('SELECT * FROM notification_channels WHERE enabled = true');
}); });
const channels = channelResult.rows.filter((ch: any) => shouldNotify(ch, report.drift_score, maxSeverity));
if (channels.length > 0) {
await dispatchNotifications(channels, {
tenantId,
stackName: report.stack_name,
driftScore: report.drift_score,
totalResources: report.total_resources,
totalDrifted: report.drifted_resources?.length ?? 0,
criticalCount: report.drifted_resources?.filter((r: any) => r.severity === 'critical').length ?? 0,
highCount: report.drifted_resources?.filter((r: any) => r.severity === 'high').length ?? 0,
reportUrl: `https://drift.dd0c.dev/reports/${report.stack_fingerprint}`,
}, maxSeverity);
}
} catch (err) { } catch (err) {
app.log.warn({ tenantId, error: (err as Error).message }, 'Notification dispatch failed (non-fatal)'); app.log.warn({ tenantId, error: (err as Error).message }, 'Notification dispatch failed (non-fatal)');
} }