Files
co-lite/local/README.md
T

84 lines
2.9 KiB
Markdown

# Co-Lite local stack
Runs the whole Co-Lite backend on your machine: MySQL, Redis, the Pub/Sub emulator and the eight Java services, with the same service names as Kubernetes. Everything here is dev-only.
## Prerequisites
- JDK 21 and Maven 3.9+
- Docker with Compose v2
- Access to the base image registry: `docker login gitea.containerverse.dev`
- About 6 GB of free RAM
## Start
From the repository root:
```sh
local/up.sh
```
This copies `local/.env.example` to `local/.env` (git-ignored) if it is missing, builds every module with `mvn -T 1C -DskipTests package`, and starts the stack. The services take about a minute to boot after MySQL finishes seeding.
Then check it:
```sh
local/smoke.sh
```
It prints `smoke: OK` when admin login, `/api/admin/me`, the users list, a service-counter read and a public mobile-api call all succeed.
| What | Where |
|---|---|
| mobile-api | http://localhost:8080 (header `api-key: colite-local-app-key`) |
| api-gateway | http://localhost:8081 (header `api-key: colite-local-gateway-key-000000000000`) |
| MySQL | localhost:3307, user `root`, password `colite-dev` |
| Admin login | `admin` / `colite-dev-admin` |
## Admin portal
The portal runs outside Docker with `npm run dev` and talks to `mobile-api` on port 8080. With the stack up:
```sh
cd solvway-admin-portal
cat > .env.local <<'EOF'
MOBILE_API_BASE_URL=http://localhost:8080
MOBILE_API_KEY=colite-local-app-key
SESSION_SECRET=colite-local-session-secret-0123456789abcdef
EOF
npm ci
npm run dev
```
Open http://localhost:3001 and log in as `admin` / `colite-dev-admin`. `.env.local` is git-ignored. The portal declares Node 24; Node 22 also runs it.
## Reset
Deletes the database volume; the next start reseeds from `local/seed/`:
```sh
docker compose -f local/docker-compose.yml down -v
local/up.sh
```
## Seed data
`local/seed/` is loaded only when the MySQL volume is empty, in file-name order:
- `00-schemas.sql`: creates the five service schemas.
- `01-schema.sql`: table structure from a Tastefully schema-only dump.
- `02-reference.sql`: allow-listed reference rows (roles, modules, lookups, messages).
- `03-colite.sql`: the Co-Lite company and the dev admin login.
Never put Tastefully customer data (members, users, attendance, orders) in these files.
## Rebuild one service after a change
```sh
mvn -T 1C -B -q -DskipTests -pl solvway-services-counter -am package
docker compose -f local/docker-compose.yml up -d --build service-counter
```
`-am` builds the core library alongside the module; a module cannot be built alone because the `colite-v1` core library is not installed in `~/.m2` by default.
Services reach each other by container name (`service-system`, `api-gateway` and so on), so a service run from an IDE outside Docker cannot join the stack. Run it inside the stack and attach a debugger instead: add `-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005` to `JAVA_OPTS` for that service and publish port 5005.