chore(local): smoke check and local stack README
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfj5akPxyikzGc2iAHM
This commit is contained in:
1 parent
b3fcb2883a
commit
d72f48cbc0
5 files changed
+102
-5
No files matched your search
@@ -0,0 +1,66 @@
|
||||
# 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, 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` |
|
||||
|
||||
## 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.
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/bin/sh
|
||||
# Smoke check for the local stack: exits non-zero and names the failing call if any step fails.
|
||||
set -u
|
||||
GW=http://localhost:8081
|
||||
MOBILE=http://localhost:8080
|
||||
GW_KEY=colite-local-gateway-key-000000000000
|
||||
APP_KEY=colite-local-app-key
|
||||
|
||||
fail() { echo "FAIL: $1"; exit 1; }
|
||||
|
||||
# 1. Admin login: gateway -> service-auth -> service-system -> MySQL
|
||||
token=$(curl -sf -X POST "$GW/auth/authenticate" -H "api-key: $GW_KEY" -H 'Content-Type: application/json' \
|
||||
-d '{"username":"admin","password":"colite-dev-admin"}') || fail "POST $GW/auth/authenticate"
|
||||
[ -n "$token" ] || fail "POST $GW/auth/authenticate returned no token"
|
||||
echo "auth/authenticate: 200"
|
||||
|
||||
# 2. gateway -> service-counter -> MySQL
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' "$GW/counter/event/findCurrentEvent" \
|
||||
-H "api-key: $GW_KEY" -H "Authorization: Bearer $token")
|
||||
[ "$code" = 200 ] || fail "GET $GW/counter/event/findCurrentEvent returned $code"
|
||||
echo "counter/event/findCurrentEvent: $code"
|
||||
|
||||
# 3. mobile-api -> gateway -> service-system -> MySQL
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' "$MOBILE/api/public/messages/en_US" -H "api-key: $APP_KEY")
|
||||
[ "$code" = 200 ] || fail "GET $MOBILE/api/public/messages/en_US returned $code"
|
||||
echo "api/public/messages/en_US: $code"
|
||||
echo "smoke: OK"
|
||||
Reference in new issue
Block a user