docker-compose.yml 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. # docker-compose.yml — single-host M0 stack.
  2. # Run: docker compose up -d
  3. # Then: see M0_VERIFICATION.md for the loadgen smoke test.
  4. #
  5. # Port conventions (project rule):
  6. # - app HTTP services: 8800–8899 (ingestd/routerd/deliverd-fcm/deliverd-telegram/telegramd/admind/loadgen/faketgmd)
  7. # - canonical ports stay (5432 postgres, 4222 nats, 6379 redis,
  8. # 1883 mqtt, 9090 prometheus, 3000 grafana, etc.)
  9. services:
  10. # ── Data tier ────────────────────────────────────────────────────
  11. postgres:
  12. image: timescale/timescaledb:latest-pg16
  13. environment:
  14. POSTGRES_USER: ba
  15. POSTGRES_PASSWORD: ba
  16. POSTGRES_DB: ba
  17. # No host port mapping: a host-local postgres is already on
  18. # :5432. The app services reach this one via the docker network
  19. # DNS name 'postgres'. Use `docker compose exec postgres psql ...`
  20. # to talk to it from the host.
  21. expose: ["5432"]
  22. volumes:
  23. - pgdata:/var/lib/postgresql/data
  24. healthcheck:
  25. test: ["CMD-SHELL", "pg_isready -U ba"]
  26. interval: 5s
  27. timeout: 3s
  28. retries: 10
  29. redis:
  30. image: redis:7-alpine
  31. # No host port mapping: a host-local redis is on :6379. App
  32. # services reach this one via docker DNS 'redis'.
  33. expose: ["6379"]
  34. healthcheck:
  35. test: ["CMD", "redis-cli", "ping"]
  36. interval: 5s
  37. timeout: 3s
  38. retries: 10
  39. nats:
  40. image: nats:2.10-alpine
  41. command: ["-js", "-sd", "/data", "-m", "8222"]
  42. ports: ["4222:4222", "8222:8222"] # 8222 is the monitoring HTTP
  43. volumes:
  44. - natsdata:/data
  45. healthcheck:
  46. test: ["CMD", "wget", "-qO-", "http://localhost:8222/healthz"]
  47. interval: 5s
  48. timeout: 3s
  49. retries: 20
  50. emqx:
  51. image: emqx/emqx:5.10.4
  52. ports: ["1883:1883", "18083:18083"] # MQTT + admin UI
  53. healthcheck:
  54. test: ["CMD-SHELL", "echo > /dev/tcp/127.0.0.1/1883 || exit 1"]
  55. interval: 10s
  56. timeout: 5s
  57. retries: 20
  58. clickhouse:
  59. image: clickhouse/clickhouse-server:24-alpine
  60. ports: ["8123:8123", "9000:9000"]
  61. volumes:
  62. - chdata:/var/lib/clickhouse
  63. ulimits:
  64. nofile: { soft: 262144, hard: 262144 }
  65. # ── App tier ─────────────────────────────────────────────────────
  66. ingestd:
  67. build: .
  68. command: ["/app/ingestd"]
  69. environment:
  70. BA_ENV: dev
  71. BA_HTTP_ADDR: ":8800"
  72. BA_NATS_URL: nats://nats:4222
  73. BA_REDIS_URL: redis://redis:6379/0
  74. BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
  75. BA_INGESTD_SOURCES: "acme-001:prom-prod:s3cret-acme,globex-002:grafana:s3cret-globex"
  76. BA_INGESTD_RATE_LIMIT_PER_SOURCE: "100"
  77. BA_INGESTD_RATE_LIMIT_PER_COMPANY: "10000"
  78. ports: ["8800:8800"]
  79. depends_on:
  80. nats: { condition: service_healthy }
  81. redis: { condition: service_healthy }
  82. postgres: { condition: service_healthy }
  83. routerd:
  84. build: .
  85. command: ["/app/routerd"]
  86. environment:
  87. BA_ENV: dev
  88. BA_HTTP_ADDR: ":8801"
  89. BA_NATS_URL: nats://nats:4222
  90. BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
  91. ports: ["8801:8801"]
  92. depends_on:
  93. nats: { condition: service_healthy }
  94. postgres: { condition: service_healthy }
  95. deliverd-fcm:
  96. build: .
  97. command: ["/app/deliverd-fcm"]
  98. environment:
  99. BA_ENV: dev
  100. BA_HTTP_ADDR: ":8802"
  101. BA_NATS_URL: nats://nats:4222
  102. BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
  103. BA_FAKECMD_URL: "http://fakefcmd:8820"
  104. ports: ["8802:8802"]
  105. depends_on:
  106. nats: { condition: service_healthy }
  107. postgres: { condition: service_healthy }
  108. fakefcmd: { condition: service_started }
  109. deliverd-telegram:
  110. build: .
  111. command: ["/app/deliverd-telegram"]
  112. environment:
  113. BA_ENV: dev
  114. BA_HTTP_ADDR: ":8821"
  115. BA_NATS_URL: nats://nats:4222
  116. BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
  117. BA_TELEGRAM_BOT_TOKEN: "fake-tg-bot-token-acme-001"
  118. BA_TELEGRAM_FAKE_URL: "http://faketgmd:8830"
  119. ports: ["8821:8821"]
  120. depends_on:
  121. nats: { condition: service_healthy }
  122. postgres: { condition: service_healthy }
  123. faketgmd: { condition: service_started }
  124. telegramd:
  125. build: .
  126. command: ["/app/telegramd"]
  127. environment:
  128. BA_ENV: dev
  129. BA_HTTP_ADDR: ":8822"
  130. BA_NATS_URL: nats://nats:4222
  131. BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
  132. BA_TELEGRAM_FAKE_URL: "http://faketgmd:8830"
  133. ports: ["8822:8822"]
  134. depends_on:
  135. nats: { condition: service_healthy }
  136. postgres: { condition: service_healthy }
  137. faketgmd: { condition: service_started }
  138. faketgmd:
  139. build: .
  140. command: ["/app/faketgmd", "--addr", ":8830", "--timeout", "5"]
  141. ports: ["8830:8830"]
  142. fakefcmd:
  143. build: .
  144. command: ["/app/fakefcmd", "--addr", ":8820"]
  145. ports: ["8820:8820"]
  146. healthcheck:
  147. test: ["CMD", "wget", "-qO-", "http://localhost:8820/health"]
  148. interval: 5s
  149. timeout: 3s
  150. retries: 10
  151. seed:
  152. build: .
  153. command: ["/app/seed"]
  154. environment:
  155. BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
  156. BA_MIGRATIONS_DIR: /migrations
  157. volumes:
  158. - ./migrations:/migrations:ro
  159. depends_on:
  160. postgres: { condition: service_healthy }
  161. admind:
  162. build: .
  163. command: ["/app/admind"]
  164. environment:
  165. BA_ENV: dev
  166. BA_HTTP_ADDR: ":8803"
  167. BA_NATS_URL: nats://nats:4222
  168. BA_POSTGRES_DSN: postgres://ba:ba@postgres:5432/ba?sslmode=disable
  169. ports: ["8803:8803"]
  170. depends_on:
  171. nats: { condition: service_healthy }
  172. postgres: { condition: service_healthy }
  173. # ── Observability ────────────────────────────────────────────────
  174. prometheus:
  175. image: prom/prometheus:latest
  176. command:
  177. - --config.file=/etc/prometheus/prometheus.yml
  178. volumes:
  179. - ./deploy/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
  180. ports: ["9090:9090"]
  181. depends_on: [ingestd, routerd, deliverd-fcm, deliverd-telegram, telegramd, admind]
  182. grafana:
  183. image: grafana/grafana:latest
  184. # :3000 is held by gogs (git3) on this host. Map to :3001
  185. # on the host, keep :3000 internal. M0 ports convention
  186. # says canonical ports stay; the host-port override is a
  187. # one-line exception, fully isolated to grafana.
  188. ports: ["3001:3000"]
  189. environment:
  190. GF_SECURITY_ADMIN_USER: admin
  191. GF_SECURITY_ADMIN_PASSWORD: admin
  192. depends_on: [prometheus]
  193. # ── Loadgen (one-shot smoke profile) ────────────────────
  194. loadgen-http:
  195. build: .
  196. command:
  197. - /app/loadgen-http
  198. - --target=http://ingestd:8800
  199. - --api-key=acme-001:prom-prod:s3cret-acme
  200. - --mode=normal
  201. - --rate=50
  202. - --duration=30s
  203. - --metrics=:8891
  204. profiles: ["loadgen"]
  205. depends_on:
  206. ingestd: { condition: service_started }
  207. volumes:
  208. pgdata: {}
  209. natsdata: {}
  210. chdata: {}