Repository navigation
Expand file tree
/
Copy pathcompose.yaml
More file actions
236 lines (230 loc) · 10.7 KB
/
Copy pathcompose.yaml
File metadata and controls
236 lines (230 loc) · 10.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
# devinfra — local development infrastructure stack
#
# Every stateful service writes to a named volume, so `docker compose down`
# followed by `docker compose up` preserves data. Only `down -v` destroys it.
#
# Selection:
# Every service carries its own Module name in `profiles:`, plus any Bundle it
# joins. Nothing starts unless the Selection asks for it — there is no longer a
# set of core services that always start, and an empty COMPOSE_PROFILES starts
# nothing at all.
#
# COMPOSE_PROFILES in .env names Modules and Bundles; scripts/select.sh expands
# that request to its transitive depends_on closure before Compose sees it, and
# every lifecycle task goes through it (ADR 0013). A raw `--profile <module>`
# bypassing the resolver is expected to fail on the dependency it did not select.
#
# Bundles:
# The `x-bundles:` registry below is the *only* place a Bundle name becomes
# legal; read the block itself for the names it registers. It carries what no
# single service can know — that the name exists, what the Bundle is for, and
# roughly what it costs to run (NFR-7).
#
# It deliberately does not list members. Membership is declared per service, in
# that service's own `profiles:` (AD-7), so it cannot drift from what actually
# starts; a `modules:` key here would be a second, hand-maintained answer to
# "what starts" and would go stale the first time a Module joined or left.
# `pixi run lint-config` closes the loop in both directions: a registered name
# no Module joins fails, a profile no entry here names fails, and a Bundle whose
# members reach outside themselves through depends_on fails — which is what
# makes every Bundle dependency-closed by declaration rather than by the
# resolver expanding it at runtime (ADR 0014).
#
# Extraction is complete: every service lives in services/<name>/ with its config
# and seed data beside it, and this file assembles them through the `include:`
# list below. That list is the record of what the stack runs — this file declares
# no services of its own, and a service added back here would be invisible to
# every per-module check. The shared restart/logging/networks fragment lives in
# common/base.yaml and reaches each module through `extends`; the `x-defaults`
# anchor that used to duplicate it here is gone, because a YAML anchor cannot
# cross an `include` boundary and nothing is left in this file to read it.
name: ${COMPOSE_PROJECT_NAME:-devinfra}
# ---------------------------------------------------------------------------
# Bundles — the closed vocabulary of Selection names that are not Modules
#
# Names only. Which Modules are in a Bundle is declared by those Modules, in
# their own `profiles:` lists; see the header above for why that split is not
# negotiable. Every entry carries exactly a description and an approximate
# memory footprint, both required by lint-config. The footprint is repeated in
# README.md, .env.example and CHANGELOG.md; the self-test parses each of those
# tables into a name -> footprint mapping and requires all of them to agree with
# this block, Bundle by Bundle.
#
# Figures are measured, resident-set at idle, and rounded — a stack under load
# will want more. Most were read off this stack running; pgAdmin and the OTel
# Collector were measured standalone in throwaway containers rather than under
# this stack's configuration, so `admin` and `observability` are the two softer
# figures.
#
# The Bundles are not disjoint and must not be summed: `minimal` is wholly
# inside `core`, and `core` and `admin` both count Postgres and Redis, so a sum
# double-counts the data layer twice over. The shipped default
# `core,admin,observability` is the whole stack, ~1.9 GB.
#
# `x-` is Compose's own extension namespace, so this block adds no service, no
# volume and no network: it renders straight through to `config` as data and
# changes nothing about what starts.
# ---------------------------------------------------------------------------
x-bundles:
minimal:
description: Postgres and Redis only — the data layer, nothing else.
memory: "~60 MB"
core:
description: Postgres, Redis, Keycloak, object storage and Mailpit — what `up-core` starts.
memory: "~800 MB"
admin:
description: The three web consoles — pgAdmin, RedisInsight and Flower — with the data layer they read.
memory: "~450 MB"
observability:
description: The five-container signal stack — OTel Collector, Prometheus, Loki, Tempo and Grafana.
memory: "~725 MB"
# ---------------------------------------------------------------------------
# Application variables — the application tier of the two-tier namespace
#
# ADR 0003 splits every name in .env into two tiers: Module variables, spelled
# `<MODULE>_<CONCERN>` and owned by the Module they are named for, and contract
# variables — the names an external contract dictates, which no Module may
# rename, "listed in a Core-owned registry naming exactly one owning module".
# This block is that registry, and it is the only place such a name becomes
# legal.
#
# Each entry is one variable an application's own SDK reads, owned by exactly
# one Module and pinned to one of that Module's `x-endpoints:` keys — so the
# name is unambiguous about which service it reaches and where, even where the
# names look alike (`REDIS_URL`, `CELERY_BROKER_URL` and `CELERY_RESULT_BACKEND`
# are three logical databases on one endpoint). `value:` is interpolated exactly
# as Compose interpolates it, so the fallbacks here and the declarations in
# .env.example are one statement and `pixi run lint-endpoints` fails when they
# disagree.
#
# Three unprefixed names are deliberately NOT here: BIND_ADDRESS,
# COMPOSE_PROJECT_NAME and COMPOSE_PROFILES are Core's own, dictated by Compose
# rather than by an application SDK, and none of them names an endpoint. A
# registry entry for one of them would have no Module to own it and no endpoint
# key to point at.
#
# Nothing reads this block at runtime. `x-` is Compose's own extension
# namespace, so it adds no service, no volume and no network and renders
# straight through to `config` as inert data; the generator parses this file
# directly, because Compose discards a top-level `x-` key from an *included*
# file (ADR 0012) and the endpoint half of the catalog lives in those.
# ---------------------------------------------------------------------------
x-app-variables:
DATABASE_URL:
module: postgres
endpoint: POSTGRES_PORT
# A double-quoted scalar folds a trailing `\` with no inserted space, which
# is the only way to keep this DSN inside yamllint's 120 columns.
value: "postgresql://${POSTGRES_USER:-devinfra}:${POSTGRES_PASSWORD:-devinfra}\
@localhost:${POSTGRES_PORT:-5432}/${POSTGRES_DB:-devinfra}"
description: SQLAlchemy and psycopg connection DSN.
REDIS_URL:
module: redis
endpoint: REDIS_PORT
value: "redis://:${REDIS_PASSWORD:-devinfra}@localhost:${REDIS_PORT:-6379}/${REDIS_CACHE_DB:-0}"
description: Application cache — logical database 0.
CELERY_BROKER_URL:
module: redis
endpoint: REDIS_PORT
value: "redis://:${REDIS_PASSWORD:-devinfra}@localhost:${REDIS_PORT:-6379}/${REDIS_BROKER_DB:-1}"
description: Celery broker — logical database 1.
CELERY_RESULT_BACKEND:
module: redis
endpoint: REDIS_PORT
value: "redis://:${REDIS_PASSWORD:-devinfra}@localhost:${REDIS_PORT:-6379}/${REDIS_BACKEND_DB:-2}"
description: Celery result backend — logical database 2.
OIDC_ISSUER:
module: keycloak
endpoint: KEYCLOAK_PORT
value: "http://localhost:${KEYCLOAK_PORT:-8080}/realms/${KEYCLOAK_REALM:-devinfra}"
description: OIDC issuer; append /.well-known/openid-configuration for discovery.
OIDC_DISCOVERY_URL:
module: keycloak
endpoint: KEYCLOAK_PORT
value: "http://localhost:${KEYCLOAK_PORT:-8080}/realms/${KEYCLOAK_REALM:-devinfra}\
/.well-known/openid-configuration"
description: Discovery document an OIDC client fetches to configure itself.
OIDC_CLIENT_ID:
module: keycloak
endpoint: KEYCLOAK_PORT
# A literal, not an interpolation: the client id is fixed by the realm seed in
# services/keycloak/seed/, so there is no tunable for it to read.
value: "devinfra-api"
description: The confidential client the realm import creates.
OIDC_CLIENT_SECRET:
module: keycloak
endpoint: KEYCLOAK_PORT
value: "${KEYCLOAK_CLIENT_SECRET:-devinfra-local-secret}"
description: Secret the realm import wires into the devinfra-api client.
AWS_ENDPOINT_URL:
module: minio
endpoint: MINIO_API_PORT
value: "http://localhost:${MINIO_API_PORT:-9100}"
description: S3 API endpoint every AWS SDK reads.
AWS_ACCESS_KEY_ID:
module: minio
endpoint: MINIO_API_PORT
value: "${MINIO_ROOT_USER:-devinfra}"
description: S3 access key.
AWS_SECRET_ACCESS_KEY:
module: minio
endpoint: MINIO_API_PORT
value: "${MINIO_ROOT_PASSWORD:-devinfra123}"
description: S3 secret key.
SMTP_HOST:
module: mailpit
endpoint: MAILPIT_SMTP_PORT
value: "localhost"
description: SMTP host; Mailpit accepts any credentials and delivers nothing onward.
SMTP_PORT:
module: mailpit
endpoint: MAILPIT_SMTP_PORT
value: "${MAILPIT_SMTP_PORT:-1025}"
description: SMTP port.
OTEL_EXPORTER_OTLP_ENDPOINT:
module: otel-collector
endpoint: OTEL_HTTP_PORT
value: "http://localhost:${OTEL_HTTP_PORT:-4318}"
description: OTLP/HTTP ingest for traces, logs and metrics.
OTEL_EXPORTER_OTLP_PROTOCOL:
module: otel-collector
endpoint: OTEL_HTTP_PORT
value: "http/protobuf"
description: Wire protocol that endpoint expects; grpc needs OTEL_GRPC_PORT instead.
# ---------------------------------------------------------------------------
# Modules — one file per extracted service, reassembled here
# ---------------------------------------------------------------------------
include:
- ./services/flower/compose.yaml
- ./services/grafana/compose.yaml
- ./services/keycloak/compose.yaml
- ./services/loki/compose.yaml
- ./services/mailpit/compose.yaml
- ./services/minio/compose.yaml
- ./services/otel-collector/compose.yaml
- ./services/pgadmin/compose.yaml
- ./services/postgres/compose.yaml
- ./services/prometheus/compose.yaml
- ./services/redis/compose.yaml
- ./services/redisinsight/compose.yaml
- ./services/tempo/compose.yaml
# ---------------------------------------------------------------------------
# Named volumes — everything stateful lands here and survives `down`
# ---------------------------------------------------------------------------
volumes:
postgres-data:
redis-data:
keycloak-data:
minio-data:
mailpit-data:
pgadmin-data:
redisinsight-data:
flower-data:
prometheus-data:
loki-data:
tempo-data:
grafana-data:
networks:
devinfra:
name: devinfra
driver: bridge