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.
- package/.devcontainer/.env +22 -0
- package/.devcontainer/CHANGELOG.md +197 -0
- package/.devcontainer/CLAUDE.md +117 -0
- package/.devcontainer/README.md +222 -0
- package/.devcontainer/config/main-system-prompt.md +502 -0
- package/.devcontainer/config/settings.json +47 -0
- package/.devcontainer/devcontainer.json +94 -0
- package/.devcontainer/features/README.md +113 -0
- package/.devcontainer/features/agent-browser/README.md +65 -0
- package/.devcontainer/features/agent-browser/devcontainer-feature.json +23 -0
- package/.devcontainer/features/agent-browser/install.sh +79 -0
- package/.devcontainer/features/ast-grep/README.md +24 -0
- package/.devcontainer/features/ast-grep/devcontainer-feature.json +24 -0
- package/.devcontainer/features/ast-grep/install.sh +51 -0
- package/.devcontainer/features/ccstatusline/README.md +296 -0
- package/.devcontainer/features/ccstatusline/devcontainer-feature.json +19 -0
- package/.devcontainer/features/ccstatusline/install.sh +290 -0
- package/.devcontainer/features/ccusage/README.md +205 -0
- package/.devcontainer/features/ccusage/devcontainer-feature.json +38 -0
- package/.devcontainer/features/ccusage/install.sh +132 -0
- package/.devcontainer/features/claude-code/README.md +498 -0
- package/.devcontainer/features/claude-code/config/settings.json +36 -0
- package/.devcontainer/features/claude-code/config/system-prompt.md +118 -0
- package/.devcontainer/features/claude-code/config/world-building-sp.md +1432 -0
- package/.devcontainer/features/claude-code/devcontainer-feature.json +42 -0
- package/.devcontainer/features/claude-code/install.sh +466 -0
- package/.devcontainer/features/claude-monitor/README.md +74 -0
- package/.devcontainer/features/claude-monitor/devcontainer-feature.json +38 -0
- package/.devcontainer/features/claude-monitor/install.sh +99 -0
- package/.devcontainer/features/lsp-servers/README.md +85 -0
- package/.devcontainer/features/lsp-servers/devcontainer-feature.json +40 -0
- package/.devcontainer/features/lsp-servers/install.sh +116 -0
- package/.devcontainer/features/mcp-qdrant/CHANGES.md +399 -0
- package/.devcontainer/features/mcp-qdrant/README.md +474 -0
- package/.devcontainer/features/mcp-qdrant/devcontainer-feature.json +57 -0
- package/.devcontainer/features/mcp-qdrant/install.sh +295 -0
- package/.devcontainer/features/mcp-qdrant/poststart-hook.sh +129 -0
- package/.devcontainer/features/mcp-reasoner/README.md +177 -0
- package/.devcontainer/features/mcp-reasoner/devcontainer-feature.json +20 -0
- package/.devcontainer/features/mcp-reasoner/install.sh +177 -0
- package/.devcontainer/features/mcp-reasoner/poststart-hook.sh +67 -0
- package/.devcontainer/features/notify-hook/README.md +86 -0
- package/.devcontainer/features/notify-hook/devcontainer-feature.json +23 -0
- package/.devcontainer/features/notify-hook/install.sh +38 -0
- package/.devcontainer/features/splitrail/README.md +140 -0
- package/.devcontainer/features/splitrail/devcontainer-feature.json +34 -0
- package/.devcontainer/features/splitrail/install.sh +129 -0
- package/.devcontainer/features/tree-sitter/README.md +138 -0
- package/.devcontainer/features/tree-sitter/devcontainer-feature.json +52 -0
- package/.devcontainer/features/tree-sitter/install.sh +173 -0
- package/.devcontainer/plugins/devs-marketplace/.claude-plugin/marketplace.json +106 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/.claude-plugin/plugin.json +7 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/hooks/hooks.json +17 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-formatter/scripts/format-file.py +101 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/.claude-plugin/plugin.json +7 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/hooks/hooks.json +17 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/auto-linter/scripts/lint-file.py +137 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/.claude-plugin/plugin.json +8 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/claude-code-headless/SKILL.md +387 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/claude-code-headless/references/cli-flags-and-output.md +312 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/claude-code-headless/references/sdk-and-mcp.md +569 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker/SKILL.md +309 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker/references/compose-services.md +438 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker/references/dockerfile-patterns.md +340 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker-py/SKILL.md +412 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker-py/references/container-lifecycle.md +388 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker-py/references/resources-and-security.md +444 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/SKILL.md +344 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/middleware-and-lifespan.md +254 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/pydantic-models.md +245 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/routing-and-dependencies.md +255 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/fastapi/references/sse-and-streaming.md +318 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/pydantic-ai/SKILL.md +345 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/pydantic-ai/references/agents-and-tools.md +271 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/pydantic-ai/references/models-and-streaming.md +422 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/SKILL.md +220 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/references/cross-vendor-principles.md +139 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/references/patterns-and-antipatterns.md +376 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/skill-building/references/skill-authoring-patterns.md +356 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/SKILL.md +329 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/advanced-queries.md +314 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/javascript-patterns.md +323 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/python-patterns.md +354 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/sqlite/references/schema-and-pragmas.md +326 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/SKILL.md +356 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/ai-sdk-svelte.md +128 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/component-patterns.md +332 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/layercake.md +203 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/migration-guide.md +350 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/runes-and-reactivity.md +328 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/spa-and-routing.md +262 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/svelte5/references/svelte-dnd-action.md +181 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/testing/SKILL.md +414 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/testing/references/fastapi-testing.md +411 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/testing/references/svelte-testing.md +538 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/codeforge-lsp/.claude-plugin/plugin.json +7 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/.claude-plugin/plugin.json +7 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/hooks/hooks.json +17 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/dangerous-command-blocker/scripts/block-dangerous.py +110 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/.claude-plugin/plugin.json +7 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/notify-hook/hooks/hooks.json +17 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/.claude-plugin/plugin.json +7 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/planning-reminder/hooks/hooks.json +17 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/.claude-plugin/plugin.json +7 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/hooks/hooks.json +17 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/protected-files-guard/scripts/guard-protected.py +108 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272create-pr.md +337 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272new.md +166 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272review-commit.md +290 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/commands/ticket/357/200/272work.md +257 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/plugin.json +8 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/ticket-workflow/.claude-plugin/system-prompt.md +184 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/.claude-plugin/plugin.json +6 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/config/planning-instructions.md +14 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/functional-conjuring-map.md +989 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/hooks/hooks.json +33 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/__pycache__/post-enhance-task.cpython-314.pyc +0 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhance-planning.py +71 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-plan.sh +68 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/enhancers/enhance-task.sh +120 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-plan.py +133 -0
- package/.devcontainer/plugins/devs-marketplace/plugins/workflow-enhancer/scripts/post-enhance-task.py +253 -0
- package/.devcontainer/scripts/setup-aliases.sh +80 -0
- package/.devcontainer/scripts/setup-config.sh +28 -0
- package/.devcontainer/scripts/setup-irie-claude.sh +32 -0
- package/.devcontainer/scripts/setup-plugins.sh +80 -0
- package/.devcontainer/scripts/setup.sh +58 -0
- package/LICENSE.txt +674 -0
- package/README.md +267 -0
- package/package.json +44 -0
- package/setup.js +83 -0
package/.devcontainer/plugins/devs-marketplace/plugins/codedirective-skills/skills/docker/SKILL.md
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: docker
|
|
3
|
+
description: >-
|
|
4
|
+
This skill should be used when the user asks to "write a Dockerfile",
|
|
5
|
+
"set up Docker Compose", "create a multi-stage Docker build",
|
|
6
|
+
"add health checks to Docker Compose", "use Docker Compose watch for development",
|
|
7
|
+
"configure Docker networking", "optimize Docker image size",
|
|
8
|
+
"add secrets to Docker Compose", or discusses Dockerfile best practices,
|
|
9
|
+
Compose service orchestration, container networking, volume management,
|
|
10
|
+
build caching, resource limits, or development workflows with containers.
|
|
11
|
+
version: 0.1.0
|
|
12
|
+
---
|
|
13
|
+
|
|
14
|
+
# Docker & Docker Compose
|
|
15
|
+
|
|
16
|
+
## Mental Model
|
|
17
|
+
|
|
18
|
+
Containers are immutable, reproducible process environments. A Dockerfile defines how to build an image — a read-only filesystem snapshot plus metadata (entrypoint, exposed ports, environment). Containers are ephemeral instances of images; any state that must survive container recreation belongs in volumes or external stores.
|
|
19
|
+
|
|
20
|
+
Docker Compose is declarative service orchestration for local and CI environments. The Compose Specification is the unified format — there is no `version` field. The `docker-compose` standalone binary is deprecated; the current interface is the `docker compose` V2 plugin (invoked as a subcommand of `docker`).
|
|
21
|
+
|
|
22
|
+
A Compose file declares services, networks, volumes, secrets, and configs. Services reference images or build contexts. Dependencies between services use `depends_on` with health check conditions to ensure correct startup ordering.
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Dockerfile Patterns
|
|
27
|
+
|
|
28
|
+
Multi-stage builds separate build-time dependencies from the runtime image. Each `FROM` instruction starts a new stage; only the final stage produces layers in the output image. Earlier stages provide artifacts via `COPY --from=<stage>`:
|
|
29
|
+
|
|
30
|
+
```dockerfile
|
|
31
|
+
FROM node:22-alpine AS deps
|
|
32
|
+
WORKDIR /app
|
|
33
|
+
COPY package.json package-lock.json ./
|
|
34
|
+
RUN npm ci --production
|
|
35
|
+
|
|
36
|
+
FROM node:22-alpine AS builder
|
|
37
|
+
WORKDIR /app
|
|
38
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
39
|
+
COPY . .
|
|
40
|
+
RUN npm run build
|
|
41
|
+
|
|
42
|
+
FROM node:22-alpine
|
|
43
|
+
WORKDIR /app
|
|
44
|
+
RUN addgroup -S app && adduser -S app -G app
|
|
45
|
+
COPY --from=builder /app/dist ./dist
|
|
46
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
47
|
+
USER app
|
|
48
|
+
EXPOSE 3000
|
|
49
|
+
ENTRYPOINT ["node"]
|
|
50
|
+
CMD ["dist/server.js"]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Layer caching is order-dependent. Place instructions that change infrequently (system packages, dependency manifests) before those that change often (application source). Use `COPY` over `ADD` unless tarball auto-extraction or remote URL fetching is specifically needed. Always include a `.dockerignore` to exclude `.git`, `node_modules`, build artifacts, and secrets from the build context.
|
|
54
|
+
|
|
55
|
+
Run the application as a non-root user. Create a dedicated user/group and switch with `USER` before the `ENTRYPOINT`. Separate `ENTRYPOINT` (the executable) from `CMD` (default arguments) — this allows `docker run <image> --custom-flag` to override arguments while preserving the entrypoint.
|
|
56
|
+
|
|
57
|
+
> **Deep dive:** See `references/dockerfile-patterns.md` for BuildKit cache mounts, `RUN --mount=type=secret`, layer ordering strategies, the ENTRYPOINT/CMD interaction matrix, common base images, security hardening patterns, and the security audit checklist.
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Compose Services
|
|
62
|
+
|
|
63
|
+
Define services with `build` (for local images) or `image` (for pre-built). Use `build.target` to select a specific Dockerfile stage and `build.args` for build-time variables:
|
|
64
|
+
|
|
65
|
+
```yaml
|
|
66
|
+
services:
|
|
67
|
+
api:
|
|
68
|
+
build:
|
|
69
|
+
context: .
|
|
70
|
+
dockerfile: Dockerfile
|
|
71
|
+
target: runtime
|
|
72
|
+
args:
|
|
73
|
+
NODE_ENV: production
|
|
74
|
+
ports:
|
|
75
|
+
- "3000:3000"
|
|
76
|
+
restart: unless-stopped
|
|
77
|
+
depends_on:
|
|
78
|
+
db:
|
|
79
|
+
condition: service_healthy
|
|
80
|
+
redis:
|
|
81
|
+
condition: service_started
|
|
82
|
+
|
|
83
|
+
db:
|
|
84
|
+
image: postgres:16-alpine
|
|
85
|
+
environment:
|
|
86
|
+
POSTGRES_DB: app
|
|
87
|
+
POSTGRES_USER: app
|
|
88
|
+
POSTGRES_PASSWORD_FILE: /run/secrets/db_password
|
|
89
|
+
volumes:
|
|
90
|
+
- pgdata:/var/lib/postgresql/data
|
|
91
|
+
healthcheck:
|
|
92
|
+
test: ["CMD-SHELL", "pg_isready -U app"]
|
|
93
|
+
interval: 10s
|
|
94
|
+
timeout: 5s
|
|
95
|
+
retries: 5
|
|
96
|
+
start_period: 30s
|
|
97
|
+
secrets:
|
|
98
|
+
- db_password
|
|
99
|
+
|
|
100
|
+
redis:
|
|
101
|
+
image: redis:7-alpine
|
|
102
|
+
healthcheck:
|
|
103
|
+
test: ["CMD", "redis-cli", "ping"]
|
|
104
|
+
interval: 10s
|
|
105
|
+
timeout: 3s
|
|
106
|
+
retries: 3
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Health checks on infrastructure services (databases, caches, message brokers) enable `depends_on` with `condition: service_healthy`, ensuring dependent services start only after their dependencies are ready to accept connections. The `service_completed_successfully` condition is for one-shot services like migrations.
|
|
110
|
+
|
|
111
|
+
> **Deep dive:** See `references/compose-services.md` for health check recipes across common services, `depends_on` conditions and `restart` flag, resource limits with `deploy.resources`, GPU reservations, build caching, and multi-platform builds.
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## Development Workflow
|
|
116
|
+
|
|
117
|
+
Compose Watch monitors local files and triggers actions on change, replacing manual rebuild cycles. Define watch rules under `develop.watch`:
|
|
118
|
+
|
|
119
|
+
```yaml
|
|
120
|
+
services:
|
|
121
|
+
app:
|
|
122
|
+
build: .
|
|
123
|
+
develop:
|
|
124
|
+
watch:
|
|
125
|
+
- path: ./src
|
|
126
|
+
action: sync
|
|
127
|
+
target: /app/src
|
|
128
|
+
|
|
129
|
+
- path: ./config
|
|
130
|
+
action: sync+restart
|
|
131
|
+
target: /app/config
|
|
132
|
+
|
|
133
|
+
- path: package.json
|
|
134
|
+
action: rebuild
|
|
135
|
+
|
|
136
|
+
- path: ./templates
|
|
137
|
+
action: sync+exec
|
|
138
|
+
target: /app/templates
|
|
139
|
+
exec:
|
|
140
|
+
command: app reload-templates
|
|
141
|
+
initial_sync: true
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
| Action | Behavior | Requires `target` |
|
|
145
|
+
|--------|----------|-------------------|
|
|
146
|
+
| `sync` | Copies changed files into the running container | Yes |
|
|
147
|
+
| `rebuild` | Rebuilds the image and recreates the container | No |
|
|
148
|
+
| `restart` | Restarts the container without rebuilding | No |
|
|
149
|
+
| `sync+restart` | Syncs files then restarts the container | Yes |
|
|
150
|
+
| `sync+exec` | Syncs files then runs a command inside the container | Yes |
|
|
151
|
+
|
|
152
|
+
Start watch mode with `docker compose watch` or `docker compose up --watch`. Use `ignore` patterns (`.dockerignore` syntax) to exclude generated files and build artifacts from triggering actions.
|
|
153
|
+
|
|
154
|
+
For simple cases where watch is unnecessary, bind mounts provide direct host-to-container file mapping:
|
|
155
|
+
|
|
156
|
+
```yaml
|
|
157
|
+
volumes:
|
|
158
|
+
- ./src:/app/src
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## Networking and Volumes
|
|
164
|
+
|
|
165
|
+
Compose creates a default bridge network per project. Services resolve each other by service name via built-in DNS. Define custom networks for isolation:
|
|
166
|
+
|
|
167
|
+
```yaml
|
|
168
|
+
networks:
|
|
169
|
+
frontend:
|
|
170
|
+
backend:
|
|
171
|
+
internal: true
|
|
172
|
+
|
|
173
|
+
services:
|
|
174
|
+
web:
|
|
175
|
+
networks:
|
|
176
|
+
- frontend
|
|
177
|
+
- backend
|
|
178
|
+
api:
|
|
179
|
+
networks:
|
|
180
|
+
backend:
|
|
181
|
+
aliases:
|
|
182
|
+
- api-service
|
|
183
|
+
db:
|
|
184
|
+
networks:
|
|
185
|
+
- backend
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The `internal: true` flag prevents containers on that network from reaching the external network — useful for isolating databases and internal services.
|
|
189
|
+
|
|
190
|
+
Named volumes persist data across container recreations. Bind mounts map host paths directly. Tmpfs mounts provide ephemeral in-memory storage:
|
|
191
|
+
|
|
192
|
+
```yaml
|
|
193
|
+
volumes:
|
|
194
|
+
pgdata:
|
|
195
|
+
uploads:
|
|
196
|
+
driver: local
|
|
197
|
+
|
|
198
|
+
services:
|
|
199
|
+
db:
|
|
200
|
+
volumes:
|
|
201
|
+
- pgdata:/var/lib/postgresql/data
|
|
202
|
+
app:
|
|
203
|
+
volumes:
|
|
204
|
+
- uploads:/app/uploads
|
|
205
|
+
tmpfs:
|
|
206
|
+
- /tmp
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
---
|
|
210
|
+
|
|
211
|
+
## Environment and Secrets
|
|
212
|
+
|
|
213
|
+
Environment variables follow a precedence chain (highest to lowest):
|
|
214
|
+
|
|
215
|
+
1. `docker compose run -e` overrides
|
|
216
|
+
2. `environment` attribute in Compose file
|
|
217
|
+
3. `--env-file` flag
|
|
218
|
+
4. `env_file` attribute in Compose file
|
|
219
|
+
5. `.env` file in project directory (for variable interpolation in the Compose file itself)
|
|
220
|
+
|
|
221
|
+
```yaml
|
|
222
|
+
services:
|
|
223
|
+
app:
|
|
224
|
+
environment:
|
|
225
|
+
NODE_ENV: production
|
|
226
|
+
DATABASE_URL: postgres://${DB_USER}:${DB_PASS}@db:5432/app
|
|
227
|
+
env_file:
|
|
228
|
+
- .env.defaults
|
|
229
|
+
- path: .env.local
|
|
230
|
+
required: false
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
The `.env` file provides values for `${VAR}` interpolation within the Compose file, not directly to containers. The `env_file` attribute loads variables into the container environment.
|
|
234
|
+
|
|
235
|
+
Secrets provide a secure alternative for sensitive values. Secrets are mounted as files under `/run/secrets/` by default:
|
|
236
|
+
|
|
237
|
+
```yaml
|
|
238
|
+
secrets:
|
|
239
|
+
db_password:
|
|
240
|
+
file: ./secrets/db_password.txt
|
|
241
|
+
api_key:
|
|
242
|
+
environment: API_KEY
|
|
243
|
+
|
|
244
|
+
services:
|
|
245
|
+
app:
|
|
246
|
+
secrets:
|
|
247
|
+
- db_password
|
|
248
|
+
- source: api_key
|
|
249
|
+
target: /run/secrets/external_api_key
|
|
250
|
+
mode: 0440
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
File-based secrets read from the host filesystem. Environment-based secrets read from the host environment at compose up time. Services can only access secrets explicitly listed in their `secrets` attribute.
|
|
254
|
+
|
|
255
|
+
---
|
|
256
|
+
|
|
257
|
+
## Profiles and Composition
|
|
258
|
+
|
|
259
|
+
Profiles conditionally include services. Services without a `profiles` attribute always start. Profiled services start only when their profile is activated:
|
|
260
|
+
|
|
261
|
+
```yaml
|
|
262
|
+
services:
|
|
263
|
+
app:
|
|
264
|
+
build: .
|
|
265
|
+
|
|
266
|
+
debug-tools:
|
|
267
|
+
image: busybox
|
|
268
|
+
profiles: [debug]
|
|
269
|
+
|
|
270
|
+
seed:
|
|
271
|
+
image: seed-data
|
|
272
|
+
profiles: [setup]
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Activate with `docker compose --profile debug up` or `COMPOSE_PROFILES=debug,setup docker compose up`.
|
|
276
|
+
|
|
277
|
+
Compose files merge and override using multiple `-f` flags or the `compose.override.yaml` convention. The `include` directive loads other Compose files as independent sub-applications:
|
|
278
|
+
|
|
279
|
+
```yaml
|
|
280
|
+
include:
|
|
281
|
+
- path: ../monitoring/compose.yaml
|
|
282
|
+
- path: ../shared/compose.yaml
|
|
283
|
+
env_file: ../.env
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
The `extends` attribute reuses service definitions from other files or services within the same file, applying merge rules for mappings, sequences, and scalars.
|
|
287
|
+
|
|
288
|
+
---
|
|
289
|
+
|
|
290
|
+
## Ambiguity Policy
|
|
291
|
+
|
|
292
|
+
These defaults apply when the user does not specify a preference. State the assumption when applying a default:
|
|
293
|
+
|
|
294
|
+
- **Compose filename:** `compose.yaml` (not `docker-compose.yml`)
|
|
295
|
+
- **Build strategy:** Multi-stage builds with separate builder and runtime stages
|
|
296
|
+
- **Base images:** Alpine variants for minimal size (`node:22-alpine`, `python:3.13-alpine`, `golang:1.23-alpine`)
|
|
297
|
+
- **Health checks:** Always define on infrastructure services (databases, caches, brokers)
|
|
298
|
+
- **Volume strategy:** Named volumes for persistent data; bind mounts for development source only
|
|
299
|
+
- **User:** Non-root with dedicated user/group in production images
|
|
300
|
+
- **Compose command:** `docker compose` (V2 plugin), not `docker-compose`
|
|
301
|
+
|
|
302
|
+
---
|
|
303
|
+
|
|
304
|
+
## Reference Files
|
|
305
|
+
|
|
306
|
+
| File | Contents |
|
|
307
|
+
|------|----------|
|
|
308
|
+
| `references/dockerfile-patterns.md` | Multi-stage deep dive, BuildKit cache mounts, `RUN --mount=type=secret`, layer ordering, ENTRYPOINT/CMD matrix, security hardening, common base images, `.dockerignore` patterns |
|
|
309
|
+
| `references/compose-services.md` | Health check recipes (Postgres, MySQL, Redis, RabbitMQ, HTTP), `depends_on` conditions, resource limits, GPU reservations, profiles, `include` and `extends`, build caching, environment variable precedence |
|