codeforge-dev 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (131) hide show
  1. package/.devcontainer/.env +22 -0
  2. package/.devcontainer/CHANGELOG.md +197 -0
  3. package/.devcontainer/CLAUDE.md +117 -0
  4. package/.devcontainer/README.md +222 -0
  5. package/.devcontainer/config/main-system-prompt.md +502 -0
  6. package/.devcontainer/config/settings.json +47 -0
  7. package/.devcontainer/devcontainer.json +94 -0
  8. package/.devcontainer/features/README.md +113 -0
  9. package/.devcontainer/features/agent-browser/README.md +65 -0
  10. package/.devcontainer/features/agent-browser/devcontainer-feature.json +23 -0
  11. package/.devcontainer/features/agent-browser/install.sh +79 -0
  12. package/.devcontainer/features/ast-grep/README.md +24 -0
  13. package/.devcontainer/features/ast-grep/devcontainer-feature.json +24 -0
  14. package/.devcontainer/features/ast-grep/install.sh +51 -0
  15. package/.devcontainer/features/ccstatusline/README.md +296 -0
  16. package/.devcontainer/features/ccstatusline/devcontainer-feature.json +19 -0
  17. package/.devcontainer/features/ccstatusline/install.sh +290 -0
  18. package/.devcontainer/features/ccusage/README.md +205 -0
  19. package/.devcontainer/features/ccusage/devcontainer-feature.json +38 -0
  20. package/.devcontainer/features/ccusage/install.sh +132 -0
  21. package/.devcontainer/features/claude-code/README.md +498 -0
  22. package/.devcontainer/features/claude-code/config/settings.json +36 -0
  23. package/.devcontainer/features/claude-code/config/system-prompt.md +118 -0
  24. package/.devcontainer/features/claude-code/config/world-building-sp.md +1432 -0
  25. package/.devcontainer/features/claude-code/devcontainer-feature.json +42 -0
  26. package/.devcontainer/features/claude-code/install.sh +466 -0
  27. package/.devcontainer/features/claude-monitor/README.md +74 -0
  28. package/.devcontainer/features/claude-monitor/devcontainer-feature.json +38 -0
  29. package/.devcontainer/features/claude-monitor/install.sh +99 -0
  30. package/.devcontainer/features/lsp-servers/README.md +85 -0
  31. package/.devcontainer/features/lsp-servers/devcontainer-feature.json +40 -0
  32. package/.devcontainer/features/lsp-servers/install.sh +116 -0
  33. package/.devcontainer/features/mcp-qdrant/CHANGES.md +399 -0
  34. package/.devcontainer/features/mcp-qdrant/README.md +474 -0
  35. package/.devcontainer/features/mcp-qdrant/devcontainer-feature.json +57 -0
  36. package/.devcontainer/features/mcp-qdrant/install.sh +295 -0
  37. package/.devcontainer/features/mcp-qdrant/poststart-hook.sh +129 -0
  38. package/.devcontainer/features/mcp-reasoner/README.md +177 -0
  39. package/.devcontainer/features/mcp-reasoner/devcontainer-feature.json +20 -0
  40. package/.devcontainer/features/mcp-reasoner/install.sh +177 -0
  41. package/.devcontainer/features/mcp-reasoner/poststart-hook.sh +67 -0
  42. package/.devcontainer/features/notify-hook/README.md +86 -0
  43. package/.devcontainer/features/notify-hook/devcontainer-feature.json +23 -0
  44. package/.devcontainer/features/notify-hook/install.sh +38 -0
  45. package/.devcontainer/features/splitrail/README.md +140 -0
  46. package/.devcontainer/features/splitrail/devcontainer-feature.json +34 -0
  47. package/.devcontainer/features/splitrail/install.sh +129 -0
  48. package/.devcontainer/features/tree-sitter/README.md +138 -0
  49. package/.devcontainer/features/tree-sitter/devcontainer-feature.json +52 -0
  50. package/.devcontainer/features/tree-sitter/install.sh +173 -0
  51. package/.devcontainer/plugins/devs-marketplace/.claude-plugin/marketplace.json +106 -0
  52. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/.claude-plugin/plugin.json +7 -0
  53. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/hooks/hooks.json +17 -0
  54. package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/format-file.py +101 -0
  55. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/.claude-plugin/plugin.json +7 -0
  56. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/hooks/hooks.json +17 -0
  57. package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/lint-file.py +137 -0
  58. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/.claude-plugin/plugin.json +8 -0
  59. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/claude-code-headless/SKILL.md +387 -0
  60. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/claude-code-headless/references/cli-flags-and-output.md +312 -0
  61. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/claude-code-headless/references/sdk-and-mcp.md +569 -0
  62. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker/SKILL.md +309 -0
  63. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker/references/compose-services.md +438 -0
  64. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker/references/dockerfile-patterns.md +340 -0
  65. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker-py/SKILL.md +412 -0
  66. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker-py/references/container-lifecycle.md +388 -0
  67. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker-py/references/resources-and-security.md +444 -0
  68. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/SKILL.md +344 -0
  69. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/middleware-and-lifespan.md +254 -0
  70. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/pydantic-models.md +245 -0
  71. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/routing-and-dependencies.md +255 -0
  72. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/sse-and-streaming.md +318 -0
  73. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/pydantic-ai/SKILL.md +345 -0
  74. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/pydantic-ai/references/agents-and-tools.md +271 -0
  75. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/pydantic-ai/references/models-and-streaming.md +422 -0
  76. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/SKILL.md +220 -0
  77. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/references/cross-vendor-principles.md +139 -0
  78. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/references/patterns-and-antipatterns.md +376 -0
  79. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/references/skill-authoring-patterns.md +356 -0
  80. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/SKILL.md +329 -0
  81. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/advanced-queries.md +314 -0
  82. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/javascript-patterns.md +323 -0
  83. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/python-patterns.md +354 -0
  84. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/schema-and-pragmas.md +326 -0
  85. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/SKILL.md +356 -0
  86. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/ai-sdk-svelte.md +128 -0
  87. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/component-patterns.md +332 -0
  88. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/layercake.md +203 -0
  89. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/migration-guide.md +350 -0
  90. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/runes-and-reactivity.md +328 -0
  91. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/spa-and-routing.md +262 -0
  92. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/svelte-dnd-action.md +181 -0
  93. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/testing/SKILL.md +414 -0
  94. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/testing/references/fastapi-testing.md +411 -0
  95. package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/testing/references/svelte-testing.md +538 -0
  96. package/.devcontainer/plugins/devs-marketplace/plugins/codeforge-lsp/.claude-plugin/plugin.json +7 -0
  97. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/.claude-plugin/plugin.json +7 -0
  98. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/hooks/hooks.json +17 -0
  99. package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/block-dangerous.py +110 -0
  100. package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/.claude-plugin/plugin.json +7 -0
  101. package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/hooks/hooks.json +17 -0
  102. package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/.claude-plugin/plugin.json +7 -0
  103. package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/hooks/hooks.json +17 -0
  104. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/.claude-plugin/plugin.json +7 -0
  105. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/hooks/hooks.json +17 -0
  106. package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/guard-protected.py +108 -0
  107. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272create-pr.md +337 -0
  108. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272new.md +166 -0
  109. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272review-commit.md +290 -0
  110. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272work.md +257 -0
  111. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/plugin.json +8 -0
  112. package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/system-prompt.md +184 -0
  113. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/.claude-plugin/plugin.json +6 -0
  114. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/config/planning-instructions.md +14 -0
  115. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/functional-conjuring-map.md +989 -0
  116. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/hooks/hooks.json +33 -0
  117. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/__pycache__/post-enhance-task.cpython-314.pyc +0 -0
  118. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhance-planning.py +71 -0
  119. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-plan.sh +68 -0
  120. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-task.sh +120 -0
  121. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-plan.py +133 -0
  122. package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-task.py +253 -0
  123. package/.devcontainer/scripts/setup-aliases.sh +80 -0
  124. package/.devcontainer/scripts/setup-config.sh +28 -0
  125. package/.devcontainer/scripts/setup-irie-claude.sh +32 -0
  126. package/.devcontainer/scripts/setup-plugins.sh +80 -0
  127. package/.devcontainer/scripts/setup.sh +58 -0
  128. package/LICENSE.txt +674 -0
  129. package/README.md +267 -0
  130. package/package.json +44 -0
  131. package/setup.js +83 -0
@@ -0,0 +1,438 @@
1
+ # Compose Services — Deep Dive
2
+
3
+ ## 1. Health Check Recipes
4
+
5
+ ### PostgreSQL
6
+
7
+ ```yaml
8
+ healthcheck:
9
+ test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-postgres}"]
10
+ interval: 10s
11
+ timeout: 5s
12
+ retries: 5
13
+ start_period: 30s
14
+ ```
15
+
16
+ ### MySQL / MariaDB
17
+
18
+ ```yaml
19
+ healthcheck:
20
+ test: ["CMD", "mysqladmin", "ping", "-h", "localhost"]
21
+ interval: 10s
22
+ timeout: 5s
23
+ retries: 5
24
+ start_period: 30s
25
+ ```
26
+
27
+ ### Redis
28
+
29
+ ```yaml
30
+ healthcheck:
31
+ test: ["CMD", "redis-cli", "ping"]
32
+ interval: 10s
33
+ timeout: 3s
34
+ retries: 3
35
+ ```
36
+
37
+ ### RabbitMQ
38
+
39
+ ```yaml
40
+ healthcheck:
41
+ test: ["CMD", "rabbitmq-diagnostics", "check_running"]
42
+ interval: 15s
43
+ timeout: 10s
44
+ retries: 5
45
+ start_period: 30s
46
+ ```
47
+
48
+ ### HTTP Service
49
+
50
+ ```yaml
51
+ healthcheck:
52
+ test: ["CMD-SHELL", "wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1"]
53
+ interval: 15s
54
+ timeout: 5s
55
+ retries: 3
56
+ start_period: 10s
57
+ ```
58
+
59
+ ### MongoDB
60
+
61
+ ```yaml
62
+ healthcheck:
63
+ test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
64
+ interval: 10s
65
+ timeout: 5s
66
+ retries: 5
67
+ start_period: 20s
68
+ ```
69
+
70
+ ### Elasticsearch
71
+
72
+ ```yaml
73
+ healthcheck:
74
+ test: ["CMD-SHELL", "curl -sf http://localhost:9200/_cluster/health || exit 1"]
75
+ interval: 15s
76
+ timeout: 10s
77
+ retries: 5
78
+ start_period: 60s
79
+ ```
80
+
81
+ ---
82
+
83
+ ## 2. depends_on Conditions
84
+
85
+ ### Condition Types
86
+
87
+ | Condition | Waits Until | Use Case |
88
+ |-----------|-------------|----------|
89
+ | `service_started` | Container has started | Services without health checks |
90
+ | `service_healthy` | Health check reports healthy | Databases, caches, brokers |
91
+ | `service_completed_successfully` | Container exits with code 0 | Migrations, seed scripts |
92
+
93
+ ### Full Syntax
94
+
95
+ ```yaml
96
+ services:
97
+ api:
98
+ depends_on:
99
+ db:
100
+ condition: service_healthy
101
+ restart: true
102
+ required: true
103
+ migration:
104
+ condition: service_completed_successfully
105
+ cache:
106
+ condition: service_started
107
+ required: false
108
+ ```
109
+
110
+ The `restart: true` flag (Compose v2.17.0+) automatically restarts the dependent service when the dependency is recreated or updated. This enables rolling updates where restarting a database triggers restart of dependent services.
111
+
112
+ The `required: false` flag (Compose v2.20.0+) makes a dependency optional — Compose warns but does not error if the dependency service is unavailable or not defined in the current profile.
113
+
114
+ ### Migration Pattern
115
+
116
+ ```yaml
117
+ services:
118
+ migration:
119
+ build:
120
+ context: .
121
+ target: migration
122
+ depends_on:
123
+ db:
124
+ condition: service_healthy
125
+ restart: "no"
126
+
127
+ api:
128
+ build:
129
+ context: .
130
+ target: runtime
131
+ depends_on:
132
+ db:
133
+ condition: service_healthy
134
+ migration:
135
+ condition: service_completed_successfully
136
+ ```
137
+
138
+ The migration service runs once, applies database changes, and exits. The API service starts only after migrations complete successfully.
139
+
140
+ ---
141
+
142
+ ## 3. Resource Limits
143
+
144
+ ### CPU and Memory
145
+
146
+ ```yaml
147
+ services:
148
+ app:
149
+ deploy:
150
+ resources:
151
+ limits:
152
+ cpus: "1.0"
153
+ memory: 512M
154
+ pids: 200
155
+ reservations:
156
+ cpus: "0.25"
157
+ memory: 128M
158
+ ```
159
+
160
+ | Field | Under `limits` | Under `reservations` |
161
+ |-------|---------------|---------------------|
162
+ | `cpus` | Maximum CPU shares (string, fractional) | Guaranteed minimum |
163
+ | `memory` | Hard ceiling — OOM killed if exceeded | Guaranteed allocation |
164
+ | `pids` | Maximum process/thread count | — |
165
+
166
+ Memory values accept suffixes: `b`, `k`, `m`, `g` (or uppercase `B`, `K`, `M`, `G`).
167
+
168
+ ### GPU Reservations
169
+
170
+ ```yaml
171
+ services:
172
+ ml-worker:
173
+ deploy:
174
+ resources:
175
+ reservations:
176
+ devices:
177
+ - driver: nvidia
178
+ count: 1
179
+ capabilities: [gpu]
180
+ ```
181
+
182
+ Alternatively, specify exact GPU IDs:
183
+
184
+ ```yaml
185
+ devices:
186
+ - driver: nvidia
187
+ device_ids: ["0", "2"]
188
+ capabilities: [gpu, compute]
189
+ ```
190
+
191
+ Capabilities include `gpu`, `compute`, `utility`, and `video`. The `count` field accepts an integer or `all`.
192
+
193
+ ---
194
+
195
+ ## 4. Profiles
196
+
197
+ ### Conditional Service Groups
198
+
199
+ ```yaml
200
+ services:
201
+ app:
202
+ build: .
203
+
204
+ db:
205
+ image: postgres:16-alpine
206
+
207
+ adminer:
208
+ image: adminer
209
+ profiles: [debug]
210
+ ports:
211
+ - "8080:8080"
212
+
213
+ mailhog:
214
+ image: mailhog/mailhog
215
+ profiles: [debug]
216
+
217
+ seed:
218
+ image: seed-runner
219
+ profiles: [setup]
220
+ depends_on:
221
+ db:
222
+ condition: service_healthy
223
+
224
+ test-runner:
225
+ build:
226
+ context: .
227
+ target: test
228
+ profiles: [test]
229
+ ```
230
+
231
+ Services without `profiles` always start. Activate profiles:
232
+
233
+ ```bash
234
+ # Single profile
235
+ docker compose --profile debug up
236
+
237
+ # Multiple profiles
238
+ docker compose --profile debug --profile setup up
239
+
240
+ # Via environment
241
+ COMPOSE_PROFILES=debug,test docker compose up
242
+ ```
243
+
244
+ A service with `depends_on` referencing a profiled service automatically activates that profile when started directly:
245
+
246
+ ```bash
247
+ docker compose run seed # Activates setup profile, starts db
248
+ ```
249
+
250
+ ---
251
+
252
+ ## 5. include and extends
253
+
254
+ ### include — Compose Sub-Applications
255
+
256
+ Load external Compose files as independent sub-applications. Each included file is evaluated in its own context (relative paths resolve from the included file's directory):
257
+
258
+ ```yaml
259
+ # compose.yaml
260
+ include:
261
+ - path: ./monitoring/compose.yaml
262
+ - path: ./shared/compose.yaml
263
+ project_directory: ./shared
264
+ env_file: ./shared/.env
265
+ ```
266
+
267
+ ```yaml
268
+ # monitoring/compose.yaml
269
+ services:
270
+ prometheus:
271
+ image: prom/prometheus
272
+ volumes:
273
+ - ./prometheus.yml:/etc/prometheus/prometheus.yml
274
+ grafana:
275
+ image: grafana/grafana
276
+ ports:
277
+ - "3001:3000"
278
+ ```
279
+
280
+ Included services join the same project. Resource name conflicts produce a warning — Compose does not merge conflicting definitions. Variable interpolation works in paths: `${MONITORING_PATH:?required}/compose.yaml`.
281
+
282
+ ### extends — Service Reuse
283
+
284
+ Reuse and override service definitions:
285
+
286
+ ```yaml
287
+ # compose.yaml
288
+ services:
289
+ web:
290
+ extends:
291
+ file: base-compose.yaml
292
+ service: base-web
293
+ environment:
294
+ APP_ENV: production
295
+ ports:
296
+ - "80:8080"
297
+ ```
298
+
299
+ ```yaml
300
+ # base-compose.yaml
301
+ services:
302
+ base-web:
303
+ build:
304
+ context: .
305
+ target: runtime
306
+ restart: unless-stopped
307
+ healthcheck:
308
+ test: ["CMD-SHELL", "wget --spider http://localhost:8080/health || exit 1"]
309
+ interval: 15s
310
+ timeout: 5s
311
+ retries: 3
312
+ ```
313
+
314
+ Merge rules for `extends`:
315
+ - **Mappings** (`environment`, `labels`): Missing keys are added; conflicting keys are overridden
316
+ - **Sequences** (`ports`, `volumes`): Values are appended
317
+ - **Scalars** (`command`, `image`): The extending service's value replaces entirely
318
+ - **Shell commands** (`command`, `entrypoint`, `healthcheck.test`): Always replaced, never appended
319
+
320
+ Use `!reset` to clear an inherited attribute to its default value. Use `!override` to fully replace an attribute, bypassing merge rules.
321
+
322
+ ---
323
+
324
+ ## 6. Build Caching
325
+
326
+ ### Local Cache
327
+
328
+ ```yaml
329
+ services:
330
+ app:
331
+ build:
332
+ context: .
333
+ cache_from:
334
+ - type=local,src=/tmp/buildcache
335
+ cache_to:
336
+ - type=local,dest=/tmp/buildcache,mode=max
337
+ ```
338
+
339
+ ### Registry Cache
340
+
341
+ ```yaml
342
+ services:
343
+ app:
344
+ build:
345
+ context: .
346
+ cache_from:
347
+ - type=registry,ref=registry.example.com/app:cache
348
+ cache_to:
349
+ - type=registry,ref=registry.example.com/app:cache,mode=max
350
+ ```
351
+
352
+ ### GitHub Actions Cache
353
+
354
+ ```yaml
355
+ services:
356
+ app:
357
+ build:
358
+ context: .
359
+ cache_from:
360
+ - type=gha
361
+ cache_to:
362
+ - type=gha,mode=max
363
+ ```
364
+
365
+ The `mode=max` option caches all layers from all stages, not just the final stage. This maximizes cache hits at the cost of more storage.
366
+
367
+ ---
368
+
369
+ ## 7. Multi-Platform Builds
370
+
371
+ ```yaml
372
+ services:
373
+ app:
374
+ build:
375
+ context: .
376
+ platforms:
377
+ - linux/amd64
378
+ - linux/arm64
379
+ ```
380
+
381
+ Multi-platform builds require BuildKit and produce a manifest list. Push directly to a registry:
382
+
383
+ ```bash
384
+ docker compose build --push
385
+ ```
386
+
387
+ For local testing, build a single platform:
388
+
389
+ ```bash
390
+ docker compose build --no-cache --builder default
391
+ ```
392
+
393
+ ---
394
+
395
+ ## 8. Environment Variable Precedence
396
+
397
+ Environment variables resolve in the following order (highest priority first):
398
+
399
+ | Priority | Source | Scope |
400
+ |----------|--------|-------|
401
+ | 1 | `docker compose run -e VAR=val` | Container |
402
+ | 2 | `environment` attribute in Compose file | Container |
403
+ | 3 | `--env-file` CLI flag | Container |
404
+ | 4 | `env_file` attribute in Compose file | Container |
405
+ | 5 | Dockerfile `ENV` instruction | Container |
406
+ | 6 | `.env` file in project directory | Compose file interpolation only |
407
+
408
+ The `.env` file is special — it provides values for `${VAR}` substitution within the Compose file itself. It does not directly set variables inside containers unless explicitly referenced:
409
+
410
+ ```yaml
411
+ # .env
412
+ DB_PORT=5432
413
+
414
+ # compose.yaml — ${DB_PORT} resolves to 5432 via .env
415
+ services:
416
+ db:
417
+ ports:
418
+ - "${DB_PORT}:5432"
419
+ ```
420
+
421
+ Interpolation supports defaults and error messages:
422
+
423
+ | Syntax | Behavior |
424
+ |--------|----------|
425
+ | `${VAR}` | Value of VAR, empty string if unset |
426
+ | `${VAR:-default}` | Value of VAR, or "default" if unset or empty |
427
+ | `${VAR-default}` | Value of VAR, or "default" if unset (empty is kept) |
428
+ | `${VAR:?error msg}` | Value of VAR, or error if unset or empty |
429
+ | `${VAR?error msg}` | Value of VAR, or error if unset |
430
+
431
+ The `env_file` attribute supports the `required` field (default `true`). Set `required: false` to silently skip missing files:
432
+
433
+ ```yaml
434
+ env_file:
435
+ - .env.defaults
436
+ - path: .env.local
437
+ required: false
438
+ ```