Replace Postgres with MariaDB 11 in docker-compose; convert all database/error_reporting and db/migrations SQL to InnoDB-friendly syntax (DATETIME(6), AUTO_INCREMENT, ON DUPLICATE KEY). Run admin portal DDL in the same migrate one-shot as error_reporting. Switch ingest-api, collector-worker, and api from pg to mysql2 (pools, parameterized queries, transactions). Align ingest writes with er_incident_occurrences and include project_id on idempotency inserts. Add scripts/run-mysql-migrations.sh for host-side applies; update LXC run-migrate/verify, deployment docs, and .env.example (mysql://, ER_MYSQL_*). Verified: npm run build + npm test in ingest-api and collector-worker; npm run build in api. Full docker compose not run here (no local daemon). Co-Authored-By: Paperclip <[email protected]>
105 lines
3.5 KiB
YAML
105 lines
3.5 KiB
YAML
# BitReport error reporting — reproducible stack: MariaDB, migrate (one-shot), ingest API, collector worker.
|
|
# Prerequisites: Docker Engine + Compose v2.
|
|
#
|
|
# Quick start:
|
|
# cp .env.example .env
|
|
# docker compose up --build
|
|
#
|
|
# Verify: curl -sf http://127.0.0.1:${ER_PUBLISH_INGEST_PORT:-3041}/health
|
|
#
|
|
# Docs: docs/deployment/bitreport-error-reporting-compose-proxmox.md
|
|
|
|
services:
|
|
mariadb:
|
|
image: mariadb:11
|
|
environment:
|
|
MARIADB_ROOT_PASSWORD: ${ER_MYSQL_ROOT_PASSWORD:-devrootchange}
|
|
MARIADB_DATABASE: ${ER_MYSQL_DATABASE:-error_reporting}
|
|
MARIADB_USER: ${ER_MYSQL_USER:-er_app}
|
|
MARIADB_PASSWORD: ${ER_MYSQL_PASSWORD:-er_app_secret}
|
|
ports:
|
|
- "${ER_PUBLISH_MYSQL_PORT:-3306}:3306"
|
|
healthcheck:
|
|
test:
|
|
[
|
|
"CMD-SHELL",
|
|
"mariadb-admin ping -h 127.0.0.1 -u \"$$MARIADB_USER\" -p\"$$MARIADB_PASSWORD\" --silent",
|
|
]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 24
|
|
start_period: 20s
|
|
|
|
migrate:
|
|
image: mariadb:11
|
|
depends_on:
|
|
mariadb:
|
|
condition: service_healthy
|
|
environment:
|
|
MARIADB_HOST: mariadb
|
|
MARIADB_USER: ${ER_MYSQL_USER:-er_app}
|
|
MARIADB_PASSWORD: ${ER_MYSQL_PASSWORD:-er_app_secret}
|
|
MARIADB_DATABASE: ${ER_MYSQL_DATABASE:-error_reporting}
|
|
volumes:
|
|
- ./database/error_reporting/migrations:/migrations/error_reporting:ro
|
|
- ./database/error_reporting/seed:/seed/error_reporting:ro
|
|
- ./db/migrations:/migrations/admin:ro
|
|
- ./scripts/docker-migrate.sh:/docker-migrate.sh:ro
|
|
entrypoint: ["/bin/bash", "/docker-migrate.sh"]
|
|
|
|
fixture-poll:
|
|
image: nginx:alpine
|
|
volumes:
|
|
- ./collector-worker/fixture/errors.json:/usr/share/nginx/html/errors.json:ro
|
|
|
|
ingest-api:
|
|
build:
|
|
context: ./ingest-api
|
|
dockerfile: Dockerfile
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
mariadb:
|
|
condition: service_healthy
|
|
environment:
|
|
DATABASE_URL: mysql://${ER_MYSQL_USER:-er_app}:${ER_MYSQL_PASSWORD:-er_app_secret}@mariadb:3306/${ER_MYSQL_DATABASE:-error_reporting}
|
|
PORT: "3041"
|
|
NODE_ENV: production
|
|
INGEST_RATE_LIMIT_MAX: ${INGEST_RATE_LIMIT_MAX:-300}
|
|
INGEST_RATE_LIMIT_WINDOW_MS: ${INGEST_RATE_LIMIT_WINDOW_MS:-60000}
|
|
ports:
|
|
- "${ER_PUBLISH_INGEST_PORT:-3041}:3041"
|
|
healthcheck:
|
|
test:
|
|
[
|
|
"CMD-SHELL",
|
|
"node -e \"fetch('http://127.0.0.1:3041/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))\"",
|
|
]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 12
|
|
start_period: 20s
|
|
|
|
collector-worker:
|
|
build:
|
|
context: ./collector-worker
|
|
dockerfile: Dockerfile
|
|
depends_on:
|
|
migrate:
|
|
condition: service_completed_successfully
|
|
ingest-api:
|
|
condition: service_healthy
|
|
fixture-poll:
|
|
condition: service_started
|
|
environment:
|
|
DATABASE_URL: mysql://${ER_MYSQL_USER:-er_app}:${ER_MYSQL_PASSWORD:-er_app_secret}@mariadb:3306/${ER_MYSQL_DATABASE:-error_reporting}
|
|
INGEST_BASE_URL: http://ingest-api:3041
|
|
TICK_INTERVAL_MS: ${TICK_INTERVAL_MS:-3000}
|
|
SOURCE_REFRESH_MS: ${SOURCE_REFRESH_MS:-15000}
|
|
HTTP_FETCH_TIMEOUT_MS: ${HTTP_FETCH_TIMEOUT_MS:-15000}
|
|
MAX_BACKOFF_EXPONENT: ${MAX_BACKOFF_EXPONENT:-8}
|
|
NODE_ENV: production
|
|
ER_COLLECTOR_PROJECT_ALPHA_TOKEN: ${ER_COLLECTOR_PROJECT_ALPHA_TOKEN:-er_tst_a_secret_one}
|
|
COLLECTOR_DEFAULT_INGEST_TOKEN: ${COLLECTOR_DEFAULT_INGEST_TOKEN:-}
|
|
restart: unless-stopped
|