# Compose baseline — MariaDB + MinIO

Three docker-compose files + two Dockerfiles. **MariaDB** (binlog CDC) +
**MinIO** (object storage) included. Two flavours: dev with volume-mounted
HMR, prod with built images. The local mirror of the Helm/MariaDB
production shape.

## Layout

```
.
├── docker/
│   ├── api.Dockerfile        # multi-stage: deps + builder + prod
│   ├── web.Dockerfile        # multi-stage: deps + builder + prod
│   ├── mariadb-init.sql      # grants the app user REPLICATION (CDC reader)
│   └── .dockerignore
├── docker-compose.yml        # mariadb + minio — the "infra" file
├── docker-compose.dev.yml    # mariadb + minio + apps in dev mode
└── docker-compose.prod.yml   # mariadb + minio + apps in prod (built images)
```

The MariaDB service runs with `binlog_format=ROW` + `binlog_row_image=FULL`
and a replication grant — Voltro's CDC reader tails the binary log to fan
real-time subscriptions out across replicas (the binlog IS the message
bus). MinIO provides S3-compatible object storage for the file-storage
primitive; the `createbuckets` one-shot provisions the app bucket.

## Common flows

### Daily dev — fastest

```sh
pnpm db:up      # boot mariadb + minio (+ create the bucket)
pnpm dev        # pnpm -r --parallel dev, native node, HMR <50ms
```

### Daily dev — full-docker (slower HMR but zero host install)

```sh
pnpm dev:docker        # boots mariadb + minio + all apps in containers
pnpm dev:docker:down   # stop everything
```

### Production smoke-test on localhost

```sh
pnpm prod:build      # build all images (slow first run, ~5 min)
pnpm prod:up         # boot the prod stack
pnpm prod:down       # tear down
```

## When to add apps

The shipped compose files cover ONE api + ONE web by default. As you
add apps to `apps/`, mirror the pattern in both `docker-compose.dev.yml`
and `docker-compose.prod.yml`: copy a service block, change its
`working_dir` / `APP_PATH` / port.

A future `voltro baseline sync` will auto-regenerate the service
blocks from your `project.json` / `app.config.ts` files. Until then,
hand-edit.

## What's NOT in here

- No CI configs (GitHub Actions / GitLab CI). Each provider's syntax
  is different; we don't pick a winner.
- No reverse proxy (Traefik / nginx / Caddy). If you need one in
  prod, add it as a service in `docker-compose.prod.yml`.
- No Redis, S3-emulator, or other infra. Add as needed.

## Switching baselines

`voltro baseline set helm` → swaps to Helm chart + Kustomize overlays.
`voltro baseline set bare` → removes docker-compose entirely.

Either switch backs up the current docker-compose files + Dockerfiles
to `.voltro-baseline-backup/<timestamp>/`. Application code is never
touched.
