chore: repo foundation and local stack (change 1) #1
No files matched your search
@@ -0,0 +1,20 @@
|
||||
# Local docker-compose stack only. Dev values, never used anywhere else.
|
||||
# up.sh copies this to local/.env (git-ignored) on first run.
|
||||
MYSQLHOST=mysql
|
||||
MYSQLPORT=3306
|
||||
MYSQLUSER=root
|
||||
MYSQLPWD=colite-dev
|
||||
REDISHOST=redis
|
||||
GCP_PROJECT=co-lite-local
|
||||
GCP_CREDENTIAL_FILE=
|
||||
APIGATEWAYURL=http://api-gateway
|
||||
AES_SECRET_KEY=colite-local-aes-key
|
||||
# Auth service signs and mobile-api verifies, so both must hold the same value (32+ chars).
|
||||
JWT_TOKEN=colite-local-jwt-secret-0123456789abcdef
|
||||
JWT_SECRET=colite-local-jwt-secret-0123456789abcdef
|
||||
USER_AUTH_API_SECRET=colite-local-user-auth-secret
|
||||
# mobile-api -> gateway key; must match a key in local/appkeys.json.
|
||||
APIKEY=colite-local-gateway-key-000000000000
|
||||
# Inbound keys clients send to mobile-api: "<key>:<PLATFORM>" (APP or CP).
|
||||
AUTH_API_KEYS=colite-local-app-key:APP,colite-local-cp-key:CP
|
||||
JAVA_OPTS=-Xmx384m
|
||||
@@ -0,0 +1,10 @@
|
||||
[
|
||||
{
|
||||
"key": "colite-local-gateway-key-000000000000",
|
||||
"name": "Local mobile-api",
|
||||
"desc": "Local docker-compose only",
|
||||
"type": "BO",
|
||||
"allowList": ["/"],
|
||||
"ipList": ["0.0.0.0/0"]
|
||||
}
|
||||
]
|
||||
@@ -0,0 +1,113 @@
|
||||
# Local dev stack. Service names match the Kubernetes service names.
|
||||
name: co-lite
|
||||
services:
|
||||
mysql:
|
||||
image: mysql:8.0
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: ${MYSQLPWD}
|
||||
ports: ["3307:3306"]
|
||||
volumes:
|
||||
- mysql-data:/var/lib/mysql
|
||||
- ./seed:/docker-entrypoint-initdb.d:ro
|
||||
healthcheck:
|
||||
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-p${MYSQLPWD}"]
|
||||
interval: 5s
|
||||
retries: 60
|
||||
redis:
|
||||
image: redis:7
|
||||
healthcheck:
|
||||
test: ["CMD", "redis-cli", "ping"]
|
||||
interval: 5s
|
||||
retries: 20
|
||||
pubsub:
|
||||
image: gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators
|
||||
command: gcloud beta emulators pubsub start --host-port=0.0.0.0:8085 --project=co-lite-local
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-sf", "http://localhost:8085"]
|
||||
interval: 5s
|
||||
retries: 30
|
||||
pubsub-init:
|
||||
image: curlimages/curl:8.11.1
|
||||
entrypoint: ["sh", "/pubsub/init.sh"]
|
||||
volumes:
|
||||
- ./pubsub:/pubsub:ro
|
||||
depends_on:
|
||||
pubsub: {condition: service_healthy}
|
||||
api-gateway:
|
||||
build:
|
||||
context: ../solvway-api-gateway
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
ports: ["8081:80"]
|
||||
volumes:
|
||||
- ./appkeys.json:/deployments/appkeys/appkeys.json:ro
|
||||
mobile-api:
|
||||
build:
|
||||
context: ../solvway-mobile-api
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
ports: ["8080:80"]
|
||||
service-auth:
|
||||
build:
|
||||
context: ../solvway-services-auth
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
service-system:
|
||||
build:
|
||||
context: ../solvway-services-system
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
service-counter:
|
||||
build:
|
||||
context: ../solvway-services-counter
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
service-member:
|
||||
build:
|
||||
context: ../solvway-services-member
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
service-log:
|
||||
build:
|
||||
context: ../solvway-services-log
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
service-email:
|
||||
build:
|
||||
context: ../solvway-services-email
|
||||
args: {BUILD_PROFILE: local}
|
||||
env_file: .env
|
||||
depends_on:
|
||||
mysql: {condition: service_healthy}
|
||||
redis: {condition: service_healthy}
|
||||
pubsub-init: {condition: service_completed_successfully}
|
||||
volumes:
|
||||
mysql-data:
|
||||
Executable
+15
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
# Creates every topic and subscription in topics.txt on the Pub/Sub emulator. Idempotent.
|
||||
set -eu
|
||||
base="http://pubsub:8085/v1/projects/co-lite-local"
|
||||
grep -v '^#' /pubsub/topics.txt | while read -r topic sub; do
|
||||
[ -z "$topic" ] && continue
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' -X PUT "$base/topics/$topic")
|
||||
case $code in 200|409) ;; *) echo "topic $topic failed: HTTP $code"; exit 1;; esac
|
||||
if [ -n "${sub:-}" ]; then
|
||||
code=$(curl -s -o /dev/null -w '%{http_code}' -X PUT -H 'Content-Type: application/json' \
|
||||
-d "{\"topic\":\"projects/co-lite-local/topics/$topic\"}" "$base/subscriptions/$sub")
|
||||
case $code in 200|409) ;; *) echo "subscription $sub failed: HTTP $code"; exit 1;; esac
|
||||
fi
|
||||
done
|
||||
echo "pubsub-init: done"
|
||||
@@ -0,0 +1,6 @@
|
||||
-- Local dev only. Creates the empty service schemas; 01-schema.sql (Tastefully dump) fills them.
|
||||
CREATE DATABASE IF NOT EXISTS `service-system` CHARACTER SET utf8mb4;
|
||||
CREATE DATABASE IF NOT EXISTS `service-counter` CHARACTER SET utf8mb4;
|
||||
CREATE DATABASE IF NOT EXISTS `service-member` CHARACTER SET utf8mb4;
|
||||
CREATE DATABASE IF NOT EXISTS `service-log` CHARACTER SET utf8mb4;
|
||||
CREATE DATABASE IF NOT EXISTS `service-email` CHARACTER SET utf8mb4;
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/bin/sh
|
||||
# Builds every backend module and starts the local stack.
|
||||
set -eu
|
||||
cd "$(dirname "$0")"
|
||||
[ -f .env ] || cp .env.example .env
|
||||
(cd .. && mvn -T 1C -B -q -DskipTests package)
|
||||
docker compose up -d --build
|
||||
docker compose ps
|
||||
@@ -18,7 +18,7 @@ Run serially: every group touches build files or shared config.
|
||||
|
||||
- [x] 3.1 Extract every Pub/Sub topic and subscription name used by the kept modules: read each `PubSubConfig`, `PubSubListener` and publisher call, and resolve property values. Write them to `local/pubsub/topics.txt` as `topic subscription` lines, plus publish-only topics as `topic` lines. Verify: every `@Value("${pubsub...}")` key in the kept modules resolves to a name (none unresolved). Result: 32 unique subscriptions plus 9 publish-only topics. There are fewer than the 37 adapter constructions because Tastefully shares some subscription names across services (e.g. `new-member-add-user-subscription` in system, counter and member). This is kept as-is.
|
||||
- [x] 3.2 Add `application-local.yml` to each kept Spring module with the emulator host and `co-lite-local` project id. Verify: `mvn -T 1C verify` still passes.
|
||||
- [ ] 3.3 Add `local/docker-compose.yml`: mysql:8, redis:7, the Pub/Sub emulator, a pubsub-init one-shot that reads `topics.txt`, and the eight Java services named as in design decision 4, each with `JAVA_OPTS=-Xmx384m`. Add `local/.env.example` with dev-only values for every env var listed in design Context, and git-ignore `local/.env`. Add `local/up.sh`, which runs `mvn -T 1C -DskipTests package` then `docker compose up -d --build`. Verify: with an empty MySQL (schemas created empty by an init script), `local/up.sh` brings pubsub-init to exit 0, and no service log shows a missing topic or subscription error.
|
||||
- [x] 3.3 Add `local/docker-compose.yml`: mysql:8, redis:7, the Pub/Sub emulator, a pubsub-init one-shot that reads `topics.txt`, and the eight Java services named as in design decision 4, each with `JAVA_OPTS=-Xmx384m`. Add `local/.env.example` with dev-only values for every env var listed in design Context, and git-ignore `local/.env`. Add `local/up.sh`, which runs `mvn -T 1C -DskipTests package` then `docker compose up -d --build`. Verify: with an empty MySQL (schemas created empty by an init script), `local/up.sh` brings pubsub-init to exit 0, and no service log shows a missing topic or subscription error. Result (2026-11-26): pubsub-init exit 0, 7 of 8 services start on empty schemas, and service-counter stops only on `Table 'service-counter.event' doesn't exist`, which is expected until group 4 seeds the schema. Gateway API keys are mounted from `local/appkeys.json` at `/deployments/appkeys/appkeys.json`, as in k8s.
|
||||
|
||||
## 4. Seed (needs the user's Tastefully dump)
|
||||
|
||||
|
||||
Reference in new issue
Block a user