@enjoys/context-engine 1.5.0 → 1.5.1

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 (95) hide show
  1. package/data/codeActions/css.json +119 -111
  2. package/data/codeActions/dart.json +190 -31
  3. package/data/codeActions/nestjs.json +124 -124
  4. package/data/codeActions/r.json +69 -71
  5. package/data/codeActions/sb.json +2 -2
  6. package/data/codeActions/scala.json +154 -26
  7. package/data/codeActions/shadcn.json +112 -112
  8. package/data/codeActions/shell.json +2 -2
  9. package/data/codeActions/tailwindcss.json +83 -76
  10. package/data/codeLens/abap.json +4 -2
  11. package/data/codeLens/angular.json +141 -22
  12. package/data/codeLens/apex.json +4 -2
  13. package/data/codeLens/awk.json +2 -2
  14. package/data/codeLens/azcli.json +4 -3
  15. package/data/codeLens/bicep.json +4 -2
  16. package/data/codeLens/c.json +4 -4
  17. package/data/codeLens/caddy.json +2 -2
  18. package/data/codeLens/cameligo.json +4 -2
  19. package/data/codeLens/clojure.json +4 -2
  20. package/data/codeLens/coffee.json +4 -2
  21. package/data/codeLens/crontab.json +2 -2
  22. package/data/codeLens/doctest.json +4 -3
  23. package/data/codeLens/ecl.json +4 -2
  24. package/data/codeLens/elixir.json +4 -2
  25. package/data/codeLens/flow9.json +4 -2
  26. package/data/codeLens/freemarker2.json +4 -2
  27. package/data/codeLens/hcl.json +4 -4
  28. package/data/codeLens/html.json +4 -4
  29. package/data/codeLens/julia.json +4 -2
  30. package/data/codeLens/less.json +4 -2
  31. package/data/codeLens/lexon.json +4 -2
  32. package/data/codeLens/liquid.json +4 -2
  33. package/data/codeLens/lua.json +4 -4
  34. package/data/codeLens/m3.json +4 -2
  35. package/data/codeLens/mdx.json +4 -2
  36. package/data/codeLens/mips.json +4 -2
  37. package/data/codeLens/msdax.json +4 -2
  38. package/data/codeLens/mysql.json +4 -2
  39. package/data/codeLens/nginx.json +4 -4
  40. package/data/codeLens/objective-c.json +4 -2
  41. package/data/codeLens/pascal.json +4 -2
  42. package/data/codeLens/pascaligo.json +4 -2
  43. package/data/codeLens/pgsql.json +4 -2
  44. package/data/codeLens/pla.json +4 -3
  45. package/data/codeLens/postiats.json +4 -2
  46. package/data/codeLens/powerquery.json +4 -2
  47. package/data/codeLens/qsharp.json +4 -2
  48. package/data/codeLens/razor.json +4 -2
  49. package/data/codeLens/redshift.json +4 -2
  50. package/data/codeLens/restructuredtext.json +4 -2
  51. package/data/codeLens/sb.json +4 -2
  52. package/data/codeLens/scheme.json +4 -2
  53. package/data/codeLens/scss.json +4 -2
  54. package/data/codeLens/shadcn.json +117 -89
  55. package/data/codeLens/shell.json +4 -2
  56. package/data/codeLens/sol.json +4 -2
  57. package/data/codeLens/sparql.json +4 -2
  58. package/data/codeLens/st.json +4 -2
  59. package/data/codeLens/systemverilog.json +4 -2
  60. package/data/codeLens/tcl.json +4 -2
  61. package/data/codeLens/twig.json +4 -2
  62. package/data/codeLens/vb.json +4 -2
  63. package/data/codeLens/wgsl.json +4 -2
  64. package/data/codeLens/xml.json +4 -4
  65. package/data/completion/redis-cli.json +3465 -3405
  66. package/data/documentHighlight/nextjs.json +270 -212
  67. package/data/documentSymbol/azcli.json +6 -3
  68. package/data/documentSymbol/caddy.json +7 -4
  69. package/data/documentSymbol/crontab.json +6 -3
  70. package/data/documentSymbol/css.json +14 -14
  71. package/data/documentSymbol/doctest.json +6 -3
  72. package/data/documentSymbol/dotenv.json +6 -3
  73. package/data/documentSymbol/flow9.json +8 -4
  74. package/data/documentSymbol/graphql.json +1 -1
  75. package/data/documentSymbol/ini.json +6 -3
  76. package/data/documentSymbol/json.json +6 -3
  77. package/data/documentSymbol/lexon.json +6 -3
  78. package/data/documentSymbol/mips.json +6 -3
  79. package/data/documentSymbol/msdax.json +6 -3
  80. package/data/documentSymbol/pla.json +6 -3
  81. package/data/documentSymbol/powerquery.json +6 -3
  82. package/data/documentSymbol/restructuredtext.json +6 -3
  83. package/data/documentSymbol/sb.json +6 -3
  84. package/data/documentSymbol/sparql.json +6 -3
  85. package/data/documentSymbol/ssh_config.json +6 -3
  86. package/data/documentSymbol/systemd.json +6 -3
  87. package/data/documentSymbol/xml.json +6 -3
  88. package/data/hover/caddy.json +530 -458
  89. package/data/hover/dockerfile.json +355 -283
  90. package/data/hover/lua.json +1391 -971
  91. package/data/hover/nginx.json +957 -891
  92. package/data/hover/redis-cli.json +2168 -1088
  93. package/data/hover/sql.json +1405 -1273
  94. package/data/manifest.json +4 -6
  95. package/package.json +1 -1
@@ -1,283 +1,355 @@
1
- {
2
- "language": "dockerfile",
3
- "hovers": {
4
- "FROM": {
5
- "contents": [
6
- {
7
- "value": "```dockerfile\nFROM node:20-alpine AS builder\nFROM python:3.12-slim\nFROM --platform=linux/amd64 ubuntu:22.04\nFROM scratch\n```\n**FROM** initializes a new build stage and sets the base image. Every Dockerfile must begin with a `FROM` instruction (only `ARG` may precede it). Multiple `FROM` instructions create multi-stage builds. Use `AS name` to reference the stage later with `COPY --from=name`."
8
- }
9
- ]
10
- },
11
- "RUN": {
12
- "contents": [
13
- {
14
- "value": "```dockerfile\n# Shell form\nRUN apt-get update && apt-get install -y curl\n\n# Exec form\nRUN [\"apt-get\", \"install\", \"-y\", \"curl\"]\n\n# BuildKit cache mount\nRUN --mount=type=cache,target=/var/cache/apt \\\n apt-get update && apt-get install -y gcc\n\n# Heredoc\nRUN <<EOF\n#!/bin/bash\nset -e\napt-get update\napt-get install -y curl\nEOF\n```\n**RUN** executes a command in a new layer. Combine related commands with `&&` and clean up in the same `RUN` to reduce layer size. Use `--mount=type=cache` for package manager caches."
15
- }
16
- ]
17
- },
18
- "CMD": {
19
- "contents": [
20
- {
21
- "value": "```dockerfile\n# Exec form (preferred)\nCMD [\"node\", \"server.js\"]\n\n# Shell form\nCMD node server.js\n\n# As ENTRYPOINT default params\nENTRYPOINT [\"python\"]\nCMD [\"app.py\"]\n```\n**CMD** sets the default command for the container. Only the last `CMD` takes effect. Exec form is preferred because it does not invoke a shell. When used with `ENTRYPOINT`, `CMD` provides default arguments."
22
- }
23
- ]
24
- },
25
- "ENTRYPOINT": {
26
- "contents": [
27
- {
28
- "value": "```dockerfile\n# Exec form (preferred)\nENTRYPOINT [\"python\", \"-m\", \"flask\"]\n\n# With CMD defaults\nENTRYPOINT [\"python\"]\nCMD [\"app.py\"]\n\n# With tini for signal handling\nENTRYPOINT [\"tini\", \"--\"]\nCMD [\"node\", \"server.js\"]\n```\n**ENTRYPOINT** configures a container to run as an executable. Exec form is preferred. `CMD` arguments are appended. Override at runtime with `--entrypoint`. Use tini or dumb-init as PID 1 for proper signal handling."
29
- }
30
- ]
31
- },
32
- "LABEL": {
33
- "contents": [
34
- {
35
- "value": "```dockerfile\nLABEL maintainer=\"dev@example.com\"\nLABEL version=\"1.0\"\n\n# OCI annotations\nLABEL org.opencontainers.image.title=\"My App\" \\\n org.opencontainers.image.version=\"1.0.0\" \\\n org.opencontainers.image.authors=\"dev@example.com\"\n```\n**LABEL** adds metadata to the image. Use OCI annotation keys (`org.opencontainers.image.*`) for interoperability. View labels with `docker inspect`."
36
- }
37
- ]
38
- },
39
- "MAINTAINER": {
40
- "contents": [
41
- {
42
- "value": "```dockerfile\n# Deprecated\nMAINTAINER dev@example.com\n\n# Use instead:\nLABEL org.opencontainers.image.authors=\"dev@example.com\"\n```\n**MAINTAINER** is deprecated. Use `LABEL org.opencontainers.image.authors` instead for setting the image author."
43
- }
44
- ]
45
- },
46
- "EXPOSE": {
47
- "contents": [
48
- {
49
- "value": "```dockerfile\nEXPOSE 8080\nEXPOSE 80 443\nEXPOSE 53/udp\nEXPOSE 8080/tcp 8443/tcp\n```\n**EXPOSE** documents which ports the container listens on. It does not actually publish ports — use `-p` or `-P` flags at runtime. Protocol defaults to TCP if not specified."
50
- }
51
- ]
52
- },
53
- "ENV": {
54
- "contents": [
55
- {
56
- "value": "```dockerfile\nENV NODE_ENV=production\nENV APP_HOME=/app PATH=\"/app/bin:$PATH\"\n\n# Python best practice\nENV PYTHONDONTWRITEBYTECODE=1 \\\n PYTHONUNBUFFERED=1\n```\n**ENV** sets environment variables that persist in the image and running containers. Values can be overridden with `docker run --env`. Use `ARG` for build-time-only variables to avoid leaking secrets."
57
- }
58
- ]
59
- },
60
- "ADD": {
61
- "contents": [
62
- {
63
- "value": "```dockerfile\n# Local file\nADD app.tar.gz /opt/app\n\n# Remote URL\nADD https://example.com/file.txt /tmp/\n\n# With checksum verification\nADD --checksum=sha256:abc123... https://example.com/bin /usr/local/bin/\n```\n**ADD** copies files into the image. Unlike COPY, ADD supports remote URLs and auto-extracts tar archives. Prefer `COPY` for simple file operations. Use `ADD` when you need tar extraction or remote downloads."
64
- }
65
- ]
66
- },
67
- "COPY": {
68
- "contents": [
69
- {
70
- "value": "```dockerfile\nCOPY . /app\nCOPY --chown=1001:1001 . /app\nCOPY --chmod=755 entrypoint.sh /entrypoint.sh\nCOPY --from=builder /app/dist /usr/share/nginx/html\nCOPY --link package.json ./\n```\n**COPY** copies files from the build context into the image. Use `--from` to copy from another build stage (multi-stage). `--link` enables layer-independent copying for better cache reuse. Preferred over `ADD` for simple file copying."
71
- }
72
- ]
73
- },
74
- "VOLUME": {
75
- "contents": [
76
- {
77
- "value": "```dockerfile\nVOLUME /data\nVOLUME [\"/data\", \"/logs\"]\n```\n**VOLUME** creates a mount point for externally mounted volumes. Data written to volumes persists independently of the container. Note: you cannot change volume contents during build after the VOLUME instruction."
78
- }
79
- ]
80
- },
81
- "USER": {
82
- "contents": [
83
- {
84
- "value": "```dockerfile\n# By name\nUSER appuser\n\n# By UID:GID\nUSER 1001:1001\n\n# Best practice: create user first\nRUN groupadd -r appuser && useradd -r -g appuser appuser\nUSER appuser\n```\n**USER** sets the user for subsequent `RUN`, `CMD`, and `ENTRYPOINT` instructions. Always run production containers as non-root for security. Create the user with `RUN` before switching."
85
- }
86
- ]
87
- },
88
- "WORKDIR": {
89
- "contents": [
90
- {
91
- "value": "```dockerfile\nWORKDIR /app\nWORKDIR src\nWORKDIR /app/config\n```\n**WORKDIR** sets the working directory for `RUN`, `CMD`, `ENTRYPOINT`, `COPY`, and `ADD`. Creates the directory if it does not exist. Can be used multiple times; relative paths build on the previous `WORKDIR`. Prefer `WORKDIR` over `RUN cd`."
92
- }
93
- ]
94
- },
95
- "ARG": {
96
- "contents": [
97
- {
98
- "value": "```dockerfile\n# With default\nARG VERSION=latest\nARG NODE_ENV=production\n\n# Before FROM (scoped to FROM)\nARG BASE_IMAGE=node:20-alpine\nFROM $BASE_IMAGE\n\n# Re-declare after FROM to use\nARG VERSION\nRUN echo $VERSION\n```\n**ARG** defines a build-time variable. Pass values with `--build-arg`. ARGs defined before `FROM` are only available in `FROM`. After `FROM`, re-declare to use in subsequent instructions. ARGs do not persist in the running container (use `ENV` for that)."
99
- }
100
- ]
101
- },
102
- "ONBUILD": {
103
- "contents": [
104
- {
105
- "value": "```dockerfile\nONBUILD COPY . /app\nONBUILD RUN npm install\n```\n**ONBUILD** registers a trigger instruction that fires when the image is used as a base. Useful for language-specific base images. The trigger runs before any instruction in the child Dockerfile."
106
- }
107
- ]
108
- },
109
- "STOPSIGNAL": {
110
- "contents": [
111
- {
112
- "value": "```dockerfile\nSTOPSIGNAL SIGTERM\nSTOPSIGNAL SIGQUIT\nSTOPSIGNAL 9\n```\n**STOPSIGNAL** sets the signal sent to the container on `docker stop`. Default is SIGTERM. Use SIGQUIT for graceful shutdown with core dump, or SIGINT for applications expecting Ctrl+C."
113
- }
114
- ]
115
- },
116
- "HEALTHCHECK": {
117
- "contents": [
118
- {
119
- "value": "```dockerfile\nHEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \\\n CMD curl -f http://localhost:8080/health || exit 1\n\n# Using wget (Alpine)\nHEALTHCHECK CMD wget --quiet --tries=1 --spider http://localhost:8080/ || exit 1\n\n# Disable inherited health check\nHEALTHCHECK NONE\n```\n**HEALTHCHECK** defines how Docker tests if a container is working. The command exit code indicates health: 0 = healthy, 1 = unhealthy. Only the last `HEALTHCHECK` takes effect. Use `NONE` to disable checks inherited from a base image."
120
- }
121
- ]
122
- },
123
- "SHELL": {
124
- "contents": [
125
- {
126
- "value": "```dockerfile\n# Linux: switch to bash\nSHELL [\"/bin/bash\", \"-c\"]\n\n# Windows: switch to PowerShell\nSHELL [\"powershell\", \"-Command\"]\n```\n**SHELL** overrides the default shell for shell-form commands. Affects all subsequent `RUN`, `CMD`, and `ENTRYPOINT` instructions in shell form. Use to switch from sh to bash for better scripting features."
127
- }
128
- ]
129
- },
130
- "syntax": {
131
- "contents": [
132
- {
133
- "value": "```dockerfile\n# syntax=docker/dockerfile:1\n# syntax=docker/dockerfile:1.7\n# syntax=docker/dockerfile:labs\n```\n**syntax** is a parser directive that sets the BuildKit frontend. Must be the very first line of the Dockerfile. Using `docker/dockerfile:1` ensures the latest stable Dockerfile syntax. The `labs` channel provides experimental features."
134
- }
135
- ]
136
- },
137
- "escape": {
138
- "contents": [
139
- {
140
- "value": "```dockerfile\n# escape=\\\n# escape=`\n```\n**escape** is a parser directive that changes the escape character. Default is backslash (`\\`). On Windows, use backtick (`` ` ``) since backslash is a path separator. Must appear before any instruction or comment."
141
- }
142
- ]
143
- },
144
- "--mount": {
145
- "contents": [
146
- {
147
- "value": "```dockerfile\n# Cache mount (package manager cache)\nRUN --mount=type=cache,target=/root/.cache/pip \\\n pip install -r requirements.txt\n\n# Bind mount (read files without copying)\nRUN --mount=type=bind,source=config.json,target=/tmp/config.json \\\n cat /tmp/config.json\n\n# Secret mount (never persisted)\nRUN --mount=type=secret,id=npmrc,target=/root/.npmrc \\\n npm install\n\n# SSH mount\nRUN --mount=type=ssh git clone git@github.com:org/repo.git\n```\n**--mount** (BuildKit) attaches additional filesystems during `RUN`. Types: cache (persistent cache), bind (read context files), secret (sensitive data), ssh (agent forwarding), tmpfs (temp storage). Mounts are not committed to the image layer."
148
- }
149
- ]
150
- },
151
- "--link": {
152
- "contents": [
153
- {
154
- "value": "```dockerfile\nCOPY --link package.json ./\nCOPY --link --from=builder /app/dist ./dist\n```\n**--link** flag for `COPY`/`ADD` creates a layer independent of previous layers. When the base image changes, linked layers can be reused without rebuilding. Significantly improves cache hit rates in multi-stage builds."
155
- }
156
- ]
157
- },
158
- "--checksum": {
159
- "contents": [
160
- {
161
- "value": "```dockerfile\nADD --checksum=sha256:24454f830cdb571e2c4ad15481119c43b3cafd48dd869a9b2015d0c... \\\n https://example.com/binary /usr/local/bin/\n```\n**--checksum** verifies the SHA256 hash of a remote file added with `ADD`. Ensures the downloaded file has not been tampered with. Only supported with URL sources."
162
- }
163
- ]
164
- },
165
- "--chmod": {
166
- "contents": [
167
- {
168
- "value": "```dockerfile\nCOPY --chmod=755 entrypoint.sh /entrypoint.sh\nCOPY --chmod=644 config.yaml /etc/app/\nADD --chmod=755 https://example.com/binary /usr/local/bin/\n```\n**--chmod** sets file permissions on `COPY`/`ADD` operations. Uses octal notation. Avoids needing a separate `RUN chmod` layer, which saves space and build time."
169
- }
170
- ]
171
- },
172
- "--chown": {
173
- "contents": [
174
- {
175
- "value": "```dockerfile\nCOPY --chown=node:node package.json ./\nCOPY --chown=1001:1001 . /app\nADD --chown=www-data:www-data files/ /var/www/\n```\n**--chown** sets ownership on `COPY`/`ADD` operations. Accepts user/group names or UID/GID numbers. Avoids a separate `RUN chown` layer. Names are resolved from the image `/etc/passwd` and `/etc/group`."
176
- }
177
- ]
178
- },
179
- "--platform": {
180
- "contents": [
181
- {
182
- "value": "```dockerfile\nFROM --platform=linux/amd64 node:20-alpine\nFROM --platform=$BUILDPLATFORM golang:1.22 AS builder\nFROM --platform=$TARGETPLATFORM debian:bookworm-slim\n```\n**--platform** in `FROM` sets the target platform for that build stage. Use `$BUILDPLATFORM` for stages that run native tools (compilers). Use `$TARGETPLATFORM` or explicit values for the final image. Essential for cross-compilation workflows."
183
- }
184
- ]
185
- },
186
- "--network": {
187
- "contents": [
188
- {
189
- "value": "```dockerfile\nRUN --network=none pip install --no-deps -r requirements.txt\nRUN --network=host curl http://host-service:8080/\n```\n**--network** controls network access during `RUN`. `none` disables all networking (security hardening). `host` uses the host network stack. Default provides normal container networking."
190
- }
191
- ]
192
- },
193
- "--security": {
194
- "contents": [
195
- {
196
- "value": "```dockerfile\nRUN --security=insecure apt-get install -y privileged-package\n```\n**--security=insecure** runs the command with elevated privileges. Requires the `security.insecure` entitlement to be enabled. Use sparingly and only when absolutely necessary."
197
- }
198
- ]
199
- },
200
- "build stage": {
201
- "contents": [
202
- {
203
- "value": "```dockerfile\nFROM node:20-alpine AS deps\nRUN npm ci\n\nFROM node:20-alpine AS builder\nCOPY --from=deps /app/node_modules ./node_modules\nRUN npm run build\n\nFROM nginx:alpine\nCOPY --from=builder /app/dist /usr/share/nginx/html\n```\n**Build stages** are created by each `FROM` instruction. Name them with `AS` and reference with `COPY --from`. Each stage starts fresh. Only the last stage (or `--target` stage) produces the final image."
204
- }
205
- ]
206
- },
207
- "multi-stage build": {
208
- "contents": [
209
- {
210
- "value": "```dockerfile\n# Build stage: has all tools\nFROM golang:1.22 AS builder\nCOPY . .\nRUN go build -o /app\n\n# Final stage: minimal\nFROM gcr.io/distroless/static-debian12\nCOPY --from=builder /app /app\nENTRYPOINT [\"/app\"]\n```\n**Multi-stage builds** use multiple `FROM` statements. Build stages contain compilers and tools; the final stage contains only the application. This can reduce image size by 90%+. Use `--target` to build a specific stage."
211
- }
212
- ]
213
- },
214
- "build cache": {
215
- "contents": [
216
- {
217
- "value": "```dockerfile\n# Good: dependencies first (cached), source second\nCOPY package.json package-lock.json ./\nRUN npm ci\nCOPY . .\n\n# Bad: any source change invalidates npm ci cache\nCOPY . .\nRUN npm ci\n```\n**Build cache** reuses layers when instructions and their inputs are unchanged. Order instructions from least to most frequently changing. Mount caches for package managers with `--mount=type=cache`. Use `.dockerignore` to exclude files that cause unnecessary cache invalidation."
218
- }
219
- ]
220
- },
221
- "build context": {
222
- "contents": [
223
- {
224
- "value": "```dockerfile\n# .dockerignore\nnode_modules\n.git\n*.md\nDockerfile\n```\n**Build context** is the set of files sent to the Docker daemon. Defined by the path in `docker build <path>`. Use `.dockerignore` to exclude large or sensitive files. A smaller context means faster builds. The build context is the root for `COPY` and `ADD` source paths."
225
- }
226
- ]
227
- },
228
- "layer": {
229
- "contents": [
230
- {
231
- "value": "```dockerfile\n# Each instruction creates a layer:\nFROM ubuntu:22.04 # Layer 1: base\nRUN apt-get update # Layer 2: package index\nCOPY . /app # Layer 3: app files\nRUN npm install # Layer 4: dependencies\n\n# Combine to reduce layers:\nRUN apt-get update && apt-get install -y curl \\\n && rm -rf /var/lib/apt/lists/*\n```\n**Layers** are filesystem diffs stacked to form an image. Each `RUN`, `COPY`, and `ADD` creates a layer. Layers are cached and shared. Minimize layer count by combining related commands. Clean up temporary files in the same layer to reduce size."
232
- }
233
- ]
234
- },
235
- "BUILDPLATFORM": {
236
- "contents": [
237
- {
238
- "value": "```dockerfile\nFROM --platform=$BUILDPLATFORM golang:1.22 AS builder\nARG TARGETPLATFORM\nARG TARGETOS\nARG TARGETARCH\nRUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /app\n```\n**BUILDPLATFORM** is an automatic build arg containing the platform of the node performing the build (e.g., `linux/amd64`). Use it with `FROM --platform=$BUILDPLATFORM` to run build tools natively, then cross-compile for the target platform."
239
- }
240
- ]
241
- },
242
- "TARGETPLATFORM": {
243
- "contents": [
244
- {
245
- "value": "```dockerfile\nFROM --platform=$TARGETPLATFORM debian:bookworm-slim\nARG TARGETPLATFORM\nRUN echo \"Building for $TARGETPLATFORM\"\n```\n**TARGETPLATFORM** is the target platform specified by `--platform` (e.g., `linux/arm64`). Automatically set by BuildKit. Use it to download platform-specific binaries or configure builds."
246
- }
247
- ]
248
- },
249
- "TARGETOS": {
250
- "contents": [
251
- {
252
- "value": "```dockerfile\nARG TARGETOS\nARG TARGETARCH\nRUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /app\n```\n**TARGETOS** contains the OS component of the target platform (e.g., `linux`, `windows`). Used for cross-compilation, especially with Go."
253
- }
254
- ]
255
- },
256
- "TARGETARCH": {
257
- "contents": [
258
- {
259
- "value": "```dockerfile\nARG TARGETARCH\nRUN curl -L https://example.com/binary-${TARGETARCH} -o /usr/local/bin/binary\n```\n**TARGETARCH** contains the architecture component (e.g., `amd64`, `arm64`, `arm`). Use to download or build platform-specific binaries."
260
- }
261
- ]
262
- },
263
- "TARGETVARIANT": {
264
- "contents": [
265
- {
266
- "value": "```dockerfile\nARG TARGETARCH\nARG TARGETVARIANT\nRUN echo \"arch=$TARGETARCH variant=$TARGETVARIANT\"\n```\n**TARGETVARIANT** contains the variant component (e.g., `v7` for `arm/v7`). Useful for ARM variant-specific builds."
267
- }
268
- ]
269
- },
270
- "--mount=type=bind": "## --mount=type=bind\n\n```dockerfile\nRUN --mount=type=bind,source=<src>,target=<dest>[,from=<stage>] <command>\n```\n\nBind mount a directory from the build context or another stage.\n\n```dockerfile\n# Mount source code read-only\nRUN --mount=type=bind,target=/src go build -o /app /src/cmd/server\n\n# Mount from another stage\nFROM build AS deps\nRUN --mount=type=bind,from=deps,source=/go/pkg,target=/go/pkg go build\n```\n\n**Key options:**\n- `source` — path in context/stage (default: root)\n- `target` — mount point in container\n- `from` — source stage name\n- `rw` — read-write (default: read-only)",
271
- "--mount=type=cache": "## --mount=type=cache\n\n```dockerfile\nRUN --mount=type=cache,target=<path>[,id=<id>][,sharing=shared] <command>\n```\n\nPersistent cache directory across builds. Dramatically speeds up package installs.\n\n```dockerfile\n# Go module cache\nRUN --mount=type=cache,target=/go/pkg/mod \\\n go build -o /app .\n\n# npm cache\nRUN --mount=type=cache,target=/root/.npm \\\n npm ci\n\n# pip cache\nRUN --mount=type=cache,target=/root/.cache/pip \\\n pip install -r requirements.txt\n\n# apt cache\nRUN --mount=type=cache,target=/var/cache/apt \\\n --mount=type=cache,target=/var/lib/apt \\\n apt-get update && apt-get install -y curl\n```\n\n**Options:**\n- `id` — unique cache ID (default: target path)\n- `sharing` — `shared` (default), `private`, `locked`",
272
- "--mount=type=secret": "## --mount=type=secret\n\n```dockerfile\nRUN --mount=type=secret,id=<id>[,target=<path>] <command>\n```\n\nMount a secret file without baking it into the image layer.\n\n```dockerfile\n# Access secret during build\nRUN --mount=type=secret,id=npmrc,target=/root/.npmrc \\\n npm ci\n\nRUN --mount=type=secret,id=aws,target=/root/.aws/credentials \\\n aws s3 cp s3://bucket/file .\n```\n\n**Pass secret at build time:**\n```bash\ndocker build --secret id=npmrc,src=$HOME/.npmrc .\ndocker build --secret id=aws,src=$HOME/.aws/credentials .\n```\n\n**Note:** Secret is never saved in image layers.",
273
- "--mount=type=ssh": "## --mount=type=ssh\n\n```dockerfile\nRUN --mount=type=ssh <command>\n```\n\nForward SSH agent to access private repos during build.\n\n```dockerfile\nRUN --mount=type=ssh \\\n git clone git@github.com:private/repo.git /app\n\nRUN --mount=type=ssh \\\n pip install git+ssh://git@github.com/private/package.git\n```\n\n**Build with SSH:**\n```bash\ndocker build --ssh default .\n# or specific key:\ndocker build --ssh default=$HOME/.ssh/id_rsa .\n```\n\n**Prerequisite:** `ssh-add` your key before building.",
274
- "--mount=type=tmpfs": "## --mount=type=tmpfs\n\n```dockerfile\nRUN --mount=type=tmpfs,target=<path>[,size=<bytes>] <command>\n```\n\nMount a tmpfs (RAM-backed) filesystem.\n\n```dockerfile\nRUN --mount=type=tmpfs,target=/tmp \\\n compile-something --temp-dir=/tmp\n```\n\nUseful for build steps that need fast temporary storage.",
275
- "BUILDARCH": "## BUILDARCH\n\n```dockerfile\nARG BUILDARCH\n```\n\nAutomatic build argument containing the CPU architecture of the build machine.\n\n**Values:** `amd64`, `arm64`, `arm`, `386`, `ppc64le`, `s390x`\n\n```dockerfile\nFROM golang:1.22\nARG BUILDARCH\nRUN echo \"Building on: $BUILDARCH\"\n```\n\n**Related:** `BUILDOS`, `BUILDPLATFORM`, `BUILDVARIANT`",
276
- "BUILDOS": "## BUILDOS\n\n```dockerfile\nARG BUILDOS\n```\n\nAutomatic build argument containing the OS of the build machine.\n\n**Values:** `linux`, `windows`, `darwin`\n\n```dockerfile\nARG BUILDOS\nRUN echo \"Build OS: $BUILDOS\"\n```",
277
- "BUILDVARIANT": "## BUILDVARIANT\n\n```dockerfile\nARG BUILDVARIANT\n```\n\nAutomatic build argument for the CPU variant (e.g., `v7` for ARMv7).\n\n```dockerfile\nARG BUILDVARIANT\nRUN echo \"Variant: ${BUILDVARIANT:-none}\"\n```",
278
- ".dockerignore": "## .dockerignore\n\nFile that controls what gets sent to the Docker daemon as build context.\n\n```\n# .dockerignore\n.git\n.gitignore\nnode_modules\nnpm-debug.log\nDockerfile*\ndocker-compose*\n.dockerignore\n.env\n*.md\n.vscode\n__pycache__\n*.pyc\ndist\nbuild\n.tox\ncoverage\n.nyc_output\n```\n\n**Pattern syntax:**\n- `*` matches any sequence (excluding path separators)\n- `**` matches any number of directories\n- `!` excludes from ignore (re-include)\n- `#` comment line\n\n**Example with exception:**\n```\n*.md\n!README.md\n```\n\n**Why it matters:** Large build contexts slow down builds. Always exclude `node_modules`, `.git`, etc.",
279
- "heredoc": "## Heredoc Syntax\n\nInline multi-line content in Dockerfile (BuildKit 1.4+).\n\n**Inline files:**\n```dockerfile\n# syntax=docker/dockerfile:1\nCOPY <<EOF /app/config.json\n{\"port\": 3000}\nEOF\n```\n\n**Multi-line RUN:**\n```dockerfile\nRUN <<EOF\napt-get update\napt-get install -y curl git\nrm -rf /var/lib/apt/lists/*\nEOF\n```\n\n**With interpreter:**\n```dockerfile\nRUN <<EOF python3\nimport os\nprint(os.environ)\nEOF\n```\n\n**Multiple files:**\n```dockerfile\nCOPY <<app.py <<requirements.txt /app/\nfrom flask import Flask\napp = Flask(__name__)\napp.py\nflask>=3.0\nrequirements.txt\n```\n\n**Requires:** `# syntax=docker/dockerfile:1` or BuildKit >= 0.10",
280
- "--parents": "## --parents (COPY flag)\n\n```dockerfile\nCOPY --parents <src> <dest>\n```\n\nPreserve the parent directory structure when copying.\n\n```dockerfile\n# Without --parents:\nCOPY src/app/config.json /dest/\n# Result: /dest/config.json\n\n# With --parents:\nCOPY --parents src/app/config.json /dest/\n# Result: /dest/src/app/config.json\n```\n\n**Requires:** BuildKit",
281
- "--keep-git-dir": "## --keep-git-dir\n\n```dockerfile\nADD --keep-git-dir=true <git-url> <dest>\n```\n\nKeep the .git directory when adding from a Git repository URL.\n\n```dockerfile\nADD --keep-git-dir=true https://github.com/user/repo.git#main /src\n```\n\nBy default, .git is stripped. Useful when build needs Git metadata (version, commit hash)."
282
- }
283
- }
1
+ {
2
+ "language": "dockerfile",
3
+ "hovers": {
4
+ "FROM": {
5
+ "contents": [
6
+ {
7
+ "value": "```dockerfile\nFROM node:20-alpine AS builder\nFROM python:3.12-slim\nFROM --platform=linux/amd64 ubuntu:22.04\nFROM scratch\n```\n**FROM** initializes a new build stage and sets the base image. Every Dockerfile must begin with a `FROM` instruction (only `ARG` may precede it). Multiple `FROM` instructions create multi-stage builds. Use `AS name` to reference the stage later with `COPY --from=name`."
8
+ }
9
+ ]
10
+ },
11
+ "RUN": {
12
+ "contents": [
13
+ {
14
+ "value": "```dockerfile\n# Shell form\nRUN apt-get update && apt-get install -y curl\n\n# Exec form\nRUN [\"apt-get\", \"install\", \"-y\", \"curl\"]\n\n# BuildKit cache mount\nRUN --mount=type=cache,target=/var/cache/apt \\\n apt-get update && apt-get install -y gcc\n\n# Heredoc\nRUN <<EOF\n#!/bin/bash\nset -e\napt-get update\napt-get install -y curl\nEOF\n```\n**RUN** executes a command in a new layer. Combine related commands with `&&` and clean up in the same `RUN` to reduce layer size. Use `--mount=type=cache` for package manager caches."
15
+ }
16
+ ]
17
+ },
18
+ "CMD": {
19
+ "contents": [
20
+ {
21
+ "value": "```dockerfile\n# Exec form (preferred)\nCMD [\"node\", \"server.js\"]\n\n# Shell form\nCMD node server.js\n\n# As ENTRYPOINT default params\nENTRYPOINT [\"python\"]\nCMD [\"app.py\"]\n```\n**CMD** sets the default command for the container. Only the last `CMD` takes effect. Exec form is preferred because it does not invoke a shell. When used with `ENTRYPOINT`, `CMD` provides default arguments."
22
+ }
23
+ ]
24
+ },
25
+ "ENTRYPOINT": {
26
+ "contents": [
27
+ {
28
+ "value": "```dockerfile\n# Exec form (preferred)\nENTRYPOINT [\"python\", \"-m\", \"flask\"]\n\n# With CMD defaults\nENTRYPOINT [\"python\"]\nCMD [\"app.py\"]\n\n# With tini for signal handling\nENTRYPOINT [\"tini\", \"--\"]\nCMD [\"node\", \"server.js\"]\n```\n**ENTRYPOINT** configures a container to run as an executable. Exec form is preferred. `CMD` arguments are appended. Override at runtime with `--entrypoint`. Use tini or dumb-init as PID 1 for proper signal handling."
29
+ }
30
+ ]
31
+ },
32
+ "LABEL": {
33
+ "contents": [
34
+ {
35
+ "value": "```dockerfile\nLABEL maintainer=\"dev@example.com\"\nLABEL version=\"1.0\"\n\n# OCI annotations\nLABEL org.opencontainers.image.title=\"My App\" \\\n org.opencontainers.image.version=\"1.0.0\" \\\n org.opencontainers.image.authors=\"dev@example.com\"\n```\n**LABEL** adds metadata to the image. Use OCI annotation keys (`org.opencontainers.image.*`) for interoperability. View labels with `docker inspect`."
36
+ }
37
+ ]
38
+ },
39
+ "MAINTAINER": {
40
+ "contents": [
41
+ {
42
+ "value": "```dockerfile\n# Deprecated\nMAINTAINER dev@example.com\n\n# Use instead:\nLABEL org.opencontainers.image.authors=\"dev@example.com\"\n```\n**MAINTAINER** is deprecated. Use `LABEL org.opencontainers.image.authors` instead for setting the image author."
43
+ }
44
+ ]
45
+ },
46
+ "EXPOSE": {
47
+ "contents": [
48
+ {
49
+ "value": "```dockerfile\nEXPOSE 8080\nEXPOSE 80 443\nEXPOSE 53/udp\nEXPOSE 8080/tcp 8443/tcp\n```\n**EXPOSE** documents which ports the container listens on. It does not actually publish ports — use `-p` or `-P` flags at runtime. Protocol defaults to TCP if not specified."
50
+ }
51
+ ]
52
+ },
53
+ "ENV": {
54
+ "contents": [
55
+ {
56
+ "value": "```dockerfile\nENV NODE_ENV=production\nENV APP_HOME=/app PATH=\"/app/bin:$PATH\"\n\n# Python best practice\nENV PYTHONDONTWRITEBYTECODE=1 \\\n PYTHONUNBUFFERED=1\n```\n**ENV** sets environment variables that persist in the image and running containers. Values can be overridden with `docker run --env`. Use `ARG` for build-time-only variables to avoid leaking secrets."
57
+ }
58
+ ]
59
+ },
60
+ "ADD": {
61
+ "contents": [
62
+ {
63
+ "value": "```dockerfile\n# Local file\nADD app.tar.gz /opt/app\n\n# Remote URL\nADD https://example.com/file.txt /tmp/\n\n# With checksum verification\nADD --checksum=sha256:abc123... https://example.com/bin /usr/local/bin/\n```\n**ADD** copies files into the image. Unlike COPY, ADD supports remote URLs and auto-extracts tar archives. Prefer `COPY` for simple file operations. Use `ADD` when you need tar extraction or remote downloads."
64
+ }
65
+ ]
66
+ },
67
+ "COPY": {
68
+ "contents": [
69
+ {
70
+ "value": "```dockerfile\nCOPY . /app\nCOPY --chown=1001:1001 . /app\nCOPY --chmod=755 entrypoint.sh /entrypoint.sh\nCOPY --from=builder /app/dist /usr/share/nginx/html\nCOPY --link package.json ./\n```\n**COPY** copies files from the build context into the image. Use `--from` to copy from another build stage (multi-stage). `--link` enables layer-independent copying for better cache reuse. Preferred over `ADD` for simple file copying."
71
+ }
72
+ ]
73
+ },
74
+ "VOLUME": {
75
+ "contents": [
76
+ {
77
+ "value": "```dockerfile\nVOLUME /data\nVOLUME [\"/data\", \"/logs\"]\n```\n**VOLUME** creates a mount point for externally mounted volumes. Data written to volumes persists independently of the container. Note: you cannot change volume contents during build after the VOLUME instruction."
78
+ }
79
+ ]
80
+ },
81
+ "USER": {
82
+ "contents": [
83
+ {
84
+ "value": "```dockerfile\n# By name\nUSER appuser\n\n# By UID:GID\nUSER 1001:1001\n\n# Best practice: create user first\nRUN groupadd -r appuser && useradd -r -g appuser appuser\nUSER appuser\n```\n**USER** sets the user for subsequent `RUN`, `CMD`, and `ENTRYPOINT` instructions. Always run production containers as non-root for security. Create the user with `RUN` before switching."
85
+ }
86
+ ]
87
+ },
88
+ "WORKDIR": {
89
+ "contents": [
90
+ {
91
+ "value": "```dockerfile\nWORKDIR /app\nWORKDIR src\nWORKDIR /app/config\n```\n**WORKDIR** sets the working directory for `RUN`, `CMD`, `ENTRYPOINT`, `COPY`, and `ADD`. Creates the directory if it does not exist. Can be used multiple times; relative paths build on the previous `WORKDIR`. Prefer `WORKDIR` over `RUN cd`."
92
+ }
93
+ ]
94
+ },
95
+ "ARG": {
96
+ "contents": [
97
+ {
98
+ "value": "```dockerfile\n# With default\nARG VERSION=latest\nARG NODE_ENV=production\n\n# Before FROM (scoped to FROM)\nARG BASE_IMAGE=node:20-alpine\nFROM $BASE_IMAGE\n\n# Re-declare after FROM to use\nARG VERSION\nRUN echo $VERSION\n```\n**ARG** defines a build-time variable. Pass values with `--build-arg`. ARGs defined before `FROM` are only available in `FROM`. After `FROM`, re-declare to use in subsequent instructions. ARGs do not persist in the running container (use `ENV` for that)."
99
+ }
100
+ ]
101
+ },
102
+ "ONBUILD": {
103
+ "contents": [
104
+ {
105
+ "value": "```dockerfile\nONBUILD COPY . /app\nONBUILD RUN npm install\n```\n**ONBUILD** registers a trigger instruction that fires when the image is used as a base. Useful for language-specific base images. The trigger runs before any instruction in the child Dockerfile."
106
+ }
107
+ ]
108
+ },
109
+ "STOPSIGNAL": {
110
+ "contents": [
111
+ {
112
+ "value": "```dockerfile\nSTOPSIGNAL SIGTERM\nSTOPSIGNAL SIGQUIT\nSTOPSIGNAL 9\n```\n**STOPSIGNAL** sets the signal sent to the container on `docker stop`. Default is SIGTERM. Use SIGQUIT for graceful shutdown with core dump, or SIGINT for applications expecting Ctrl+C."
113
+ }
114
+ ]
115
+ },
116
+ "HEALTHCHECK": {
117
+ "contents": [
118
+ {
119
+ "value": "```dockerfile\nHEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \\\n CMD curl -f http://localhost:8080/health || exit 1\n\n# Using wget (Alpine)\nHEALTHCHECK CMD wget --quiet --tries=1 --spider http://localhost:8080/ || exit 1\n\n# Disable inherited health check\nHEALTHCHECK NONE\n```\n**HEALTHCHECK** defines how Docker tests if a container is working. The command exit code indicates health: 0 = healthy, 1 = unhealthy. Only the last `HEALTHCHECK` takes effect. Use `NONE` to disable checks inherited from a base image."
120
+ }
121
+ ]
122
+ },
123
+ "SHELL": {
124
+ "contents": [
125
+ {
126
+ "value": "```dockerfile\n# Linux: switch to bash\nSHELL [\"/bin/bash\", \"-c\"]\n\n# Windows: switch to PowerShell\nSHELL [\"powershell\", \"-Command\"]\n```\n**SHELL** overrides the default shell for shell-form commands. Affects all subsequent `RUN`, `CMD`, and `ENTRYPOINT` instructions in shell form. Use to switch from sh to bash for better scripting features."
127
+ }
128
+ ]
129
+ },
130
+ "syntax": {
131
+ "contents": [
132
+ {
133
+ "value": "```dockerfile\n# syntax=docker/dockerfile:1\n# syntax=docker/dockerfile:1.7\n# syntax=docker/dockerfile:labs\n```\n**syntax** is a parser directive that sets the BuildKit frontend. Must be the very first line of the Dockerfile. Using `docker/dockerfile:1` ensures the latest stable Dockerfile syntax. The `labs` channel provides experimental features."
134
+ }
135
+ ]
136
+ },
137
+ "escape": {
138
+ "contents": [
139
+ {
140
+ "value": "```dockerfile\n# escape=\\\n# escape=`\n```\n**escape** is a parser directive that changes the escape character. Default is backslash (`\\`). On Windows, use backtick (`` ` ``) since backslash is a path separator. Must appear before any instruction or comment."
141
+ }
142
+ ]
143
+ },
144
+ "--mount": {
145
+ "contents": [
146
+ {
147
+ "value": "```dockerfile\n# Cache mount (package manager cache)\nRUN --mount=type=cache,target=/root/.cache/pip \\\n pip install -r requirements.txt\n\n# Bind mount (read files without copying)\nRUN --mount=type=bind,source=config.json,target=/tmp/config.json \\\n cat /tmp/config.json\n\n# Secret mount (never persisted)\nRUN --mount=type=secret,id=npmrc,target=/root/.npmrc \\\n npm install\n\n# SSH mount\nRUN --mount=type=ssh git clone git@github.com:org/repo.git\n```\n**--mount** (BuildKit) attaches additional filesystems during `RUN`. Types: cache (persistent cache), bind (read context files), secret (sensitive data), ssh (agent forwarding), tmpfs (temp storage). Mounts are not committed to the image layer."
148
+ }
149
+ ]
150
+ },
151
+ "--link": {
152
+ "contents": [
153
+ {
154
+ "value": "```dockerfile\nCOPY --link package.json ./\nCOPY --link --from=builder /app/dist ./dist\n```\n**--link** flag for `COPY`/`ADD` creates a layer independent of previous layers. When the base image changes, linked layers can be reused without rebuilding. Significantly improves cache hit rates in multi-stage builds."
155
+ }
156
+ ]
157
+ },
158
+ "--checksum": {
159
+ "contents": [
160
+ {
161
+ "value": "```dockerfile\nADD --checksum=sha256:24454f830cdb571e2c4ad15481119c43b3cafd48dd869a9b2015d0c... \\\n https://example.com/binary /usr/local/bin/\n```\n**--checksum** verifies the SHA256 hash of a remote file added with `ADD`. Ensures the downloaded file has not been tampered with. Only supported with URL sources."
162
+ }
163
+ ]
164
+ },
165
+ "--chmod": {
166
+ "contents": [
167
+ {
168
+ "value": "```dockerfile\nCOPY --chmod=755 entrypoint.sh /entrypoint.sh\nCOPY --chmod=644 config.yaml /etc/app/\nADD --chmod=755 https://example.com/binary /usr/local/bin/\n```\n**--chmod** sets file permissions on `COPY`/`ADD` operations. Uses octal notation. Avoids needing a separate `RUN chmod` layer, which saves space and build time."
169
+ }
170
+ ]
171
+ },
172
+ "--chown": {
173
+ "contents": [
174
+ {
175
+ "value": "```dockerfile\nCOPY --chown=node:node package.json ./\nCOPY --chown=1001:1001 . /app\nADD --chown=www-data:www-data files/ /var/www/\n```\n**--chown** sets ownership on `COPY`/`ADD` operations. Accepts user/group names or UID/GID numbers. Avoids a separate `RUN chown` layer. Names are resolved from the image `/etc/passwd` and `/etc/group`."
176
+ }
177
+ ]
178
+ },
179
+ "--platform": {
180
+ "contents": [
181
+ {
182
+ "value": "```dockerfile\nFROM --platform=linux/amd64 node:20-alpine\nFROM --platform=$BUILDPLATFORM golang:1.22 AS builder\nFROM --platform=$TARGETPLATFORM debian:bookworm-slim\n```\n**--platform** in `FROM` sets the target platform for that build stage. Use `$BUILDPLATFORM` for stages that run native tools (compilers). Use `$TARGETPLATFORM` or explicit values for the final image. Essential for cross-compilation workflows."
183
+ }
184
+ ]
185
+ },
186
+ "--network": {
187
+ "contents": [
188
+ {
189
+ "value": "```dockerfile\nRUN --network=none pip install --no-deps -r requirements.txt\nRUN --network=host curl http://host-service:8080/\n```\n**--network** controls network access during `RUN`. `none` disables all networking (security hardening). `host` uses the host network stack. Default provides normal container networking."
190
+ }
191
+ ]
192
+ },
193
+ "--security": {
194
+ "contents": [
195
+ {
196
+ "value": "```dockerfile\nRUN --security=insecure apt-get install -y privileged-package\n```\n**--security=insecure** runs the command with elevated privileges. Requires the `security.insecure` entitlement to be enabled. Use sparingly and only when absolutely necessary."
197
+ }
198
+ ]
199
+ },
200
+ "build stage": {
201
+ "contents": [
202
+ {
203
+ "value": "```dockerfile\nFROM node:20-alpine AS deps\nRUN npm ci\n\nFROM node:20-alpine AS builder\nCOPY --from=deps /app/node_modules ./node_modules\nRUN npm run build\n\nFROM nginx:alpine\nCOPY --from=builder /app/dist /usr/share/nginx/html\n```\n**Build stages** are created by each `FROM` instruction. Name them with `AS` and reference with `COPY --from`. Each stage starts fresh. Only the last stage (or `--target` stage) produces the final image."
204
+ }
205
+ ]
206
+ },
207
+ "multi-stage build": {
208
+ "contents": [
209
+ {
210
+ "value": "```dockerfile\n# Build stage: has all tools\nFROM golang:1.22 AS builder\nCOPY . .\nRUN go build -o /app\n\n# Final stage: minimal\nFROM gcr.io/distroless/static-debian12\nCOPY --from=builder /app /app\nENTRYPOINT [\"/app\"]\n```\n**Multi-stage builds** use multiple `FROM` statements. Build stages contain compilers and tools; the final stage contains only the application. This can reduce image size by 90%+. Use `--target` to build a specific stage."
211
+ }
212
+ ]
213
+ },
214
+ "build cache": {
215
+ "contents": [
216
+ {
217
+ "value": "```dockerfile\n# Good: dependencies first (cached), source second\nCOPY package.json package-lock.json ./\nRUN npm ci\nCOPY . .\n\n# Bad: any source change invalidates npm ci cache\nCOPY . .\nRUN npm ci\n```\n**Build cache** reuses layers when instructions and their inputs are unchanged. Order instructions from least to most frequently changing. Mount caches for package managers with `--mount=type=cache`. Use `.dockerignore` to exclude files that cause unnecessary cache invalidation."
218
+ }
219
+ ]
220
+ },
221
+ "build context": {
222
+ "contents": [
223
+ {
224
+ "value": "```dockerfile\n# .dockerignore\nnode_modules\n.git\n*.md\nDockerfile\n```\n**Build context** is the set of files sent to the Docker daemon. Defined by the path in `docker build <path>`. Use `.dockerignore` to exclude large or sensitive files. A smaller context means faster builds. The build context is the root for `COPY` and `ADD` source paths."
225
+ }
226
+ ]
227
+ },
228
+ "layer": {
229
+ "contents": [
230
+ {
231
+ "value": "```dockerfile\n# Each instruction creates a layer:\nFROM ubuntu:22.04 # Layer 1: base\nRUN apt-get update # Layer 2: package index\nCOPY . /app # Layer 3: app files\nRUN npm install # Layer 4: dependencies\n\n# Combine to reduce layers:\nRUN apt-get update && apt-get install -y curl \\\n && rm -rf /var/lib/apt/lists/*\n```\n**Layers** are filesystem diffs stacked to form an image. Each `RUN`, `COPY`, and `ADD` creates a layer. Layers are cached and shared. Minimize layer count by combining related commands. Clean up temporary files in the same layer to reduce size."
232
+ }
233
+ ]
234
+ },
235
+ "BUILDPLATFORM": {
236
+ "contents": [
237
+ {
238
+ "value": "```dockerfile\nFROM --platform=$BUILDPLATFORM golang:1.22 AS builder\nARG TARGETPLATFORM\nARG TARGETOS\nARG TARGETARCH\nRUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /app\n```\n**BUILDPLATFORM** is an automatic build arg containing the platform of the node performing the build (e.g., `linux/amd64`). Use it with `FROM --platform=$BUILDPLATFORM` to run build tools natively, then cross-compile for the target platform."
239
+ }
240
+ ]
241
+ },
242
+ "TARGETPLATFORM": {
243
+ "contents": [
244
+ {
245
+ "value": "```dockerfile\nFROM --platform=$TARGETPLATFORM debian:bookworm-slim\nARG TARGETPLATFORM\nRUN echo \"Building for $TARGETPLATFORM\"\n```\n**TARGETPLATFORM** is the target platform specified by `--platform` (e.g., `linux/arm64`). Automatically set by BuildKit. Use it to download platform-specific binaries or configure builds."
246
+ }
247
+ ]
248
+ },
249
+ "TARGETOS": {
250
+ "contents": [
251
+ {
252
+ "value": "```dockerfile\nARG TARGETOS\nARG TARGETARCH\nRUN GOOS=$TARGETOS GOARCH=$TARGETARCH go build -o /app\n```\n**TARGETOS** contains the OS component of the target platform (e.g., `linux`, `windows`). Used for cross-compilation, especially with Go."
253
+ }
254
+ ]
255
+ },
256
+ "TARGETARCH": {
257
+ "contents": [
258
+ {
259
+ "value": "```dockerfile\nARG TARGETARCH\nRUN curl -L https://example.com/binary-${TARGETARCH} -o /usr/local/bin/binary\n```\n**TARGETARCH** contains the architecture component (e.g., `amd64`, `arm64`, `arm`). Use to download or build platform-specific binaries."
260
+ }
261
+ ]
262
+ },
263
+ "TARGETVARIANT": {
264
+ "contents": [
265
+ {
266
+ "value": "```dockerfile\nARG TARGETARCH\nARG TARGETVARIANT\nRUN echo \"arch=$TARGETARCH variant=$TARGETVARIANT\"\n```\n**TARGETVARIANT** contains the variant component (e.g., `v7` for `arm/v7`). Useful for ARM variant-specific builds."
267
+ }
268
+ ]
269
+ },
270
+ "--mount=type=bind": {
271
+ "contents": [
272
+ {
273
+ "value": "## --mount=type=bind\n\n```dockerfile\nRUN --mount=type=bind,source=<src>,target=<dest>[,from=<stage>] <command>\n```\n\nBind mount a directory from the build context or another stage.\n\n```dockerfile\n# Mount source code read-only\nRUN --mount=type=bind,target=/src go build -o /app /src/cmd/server\n\n# Mount from another stage\nFROM build AS deps\nRUN --mount=type=bind,from=deps,source=/go/pkg,target=/go/pkg go build\n```\n\n**Key options:**\n- `source` path in context/stage (default: root)\n- `target` mount point in container\n- `from` — source stage name\n- `rw` read-write (default: read-only)"
274
+ }
275
+ ]
276
+ },
277
+ "--mount=type=cache": {
278
+ "contents": [
279
+ {
280
+ "value": "## --mount=type=cache\n\n```dockerfile\nRUN --mount=type=cache,target=<path>[,id=<id>][,sharing=shared] <command>\n```\n\nPersistent cache directory across builds. Dramatically speeds up package installs.\n\n```dockerfile\n# Go module cache\nRUN --mount=type=cache,target=/go/pkg/mod \\\n go build -o /app .\n\n# npm cache\nRUN --mount=type=cache,target=/root/.npm \\\n npm ci\n\n# pip cache\nRUN --mount=type=cache,target=/root/.cache/pip \\\n pip install -r requirements.txt\n\n# apt cache\nRUN --mount=type=cache,target=/var/cache/apt \\\n --mount=type=cache,target=/var/lib/apt \\\n apt-get update && apt-get install -y curl\n```\n\n**Options:**\n- `id` — unique cache ID (default: target path)\n- `sharing` — `shared` (default), `private`, `locked`"
281
+ }
282
+ ]
283
+ },
284
+ "--mount=type=secret": {
285
+ "contents": [
286
+ {
287
+ "value": "## --mount=type=secret\n\n```dockerfile\nRUN --mount=type=secret,id=<id>[,target=<path>] <command>\n```\n\nMount a secret file without baking it into the image layer.\n\n```dockerfile\n# Access secret during build\nRUN --mount=type=secret,id=npmrc,target=/root/.npmrc \\\n npm ci\n\nRUN --mount=type=secret,id=aws,target=/root/.aws/credentials \\\n aws s3 cp s3://bucket/file .\n```\n\n**Pass secret at build time:**\n```bash\ndocker build --secret id=npmrc,src=$HOME/.npmrc .\ndocker build --secret id=aws,src=$HOME/.aws/credentials .\n```\n\n**Note:** Secret is never saved in image layers."
288
+ }
289
+ ]
290
+ },
291
+ "--mount=type=ssh": {
292
+ "contents": [
293
+ {
294
+ "value": "## --mount=type=ssh\n\n```dockerfile\nRUN --mount=type=ssh <command>\n```\n\nForward SSH agent to access private repos during build.\n\n```dockerfile\nRUN --mount=type=ssh \\\n git clone git@github.com:private/repo.git /app\n\nRUN --mount=type=ssh \\\n pip install git+ssh://git@github.com/private/package.git\n```\n\n**Build with SSH:**\n```bash\ndocker build --ssh default .\n# or specific key:\ndocker build --ssh default=$HOME/.ssh/id_rsa .\n```\n\n**Prerequisite:** `ssh-add` your key before building."
295
+ }
296
+ ]
297
+ },
298
+ "--mount=type=tmpfs": {
299
+ "contents": [
300
+ {
301
+ "value": "## --mount=type=tmpfs\n\n```dockerfile\nRUN --mount=type=tmpfs,target=<path>[,size=<bytes>] <command>\n```\n\nMount a tmpfs (RAM-backed) filesystem.\n\n```dockerfile\nRUN --mount=type=tmpfs,target=/tmp \\\n compile-something --temp-dir=/tmp\n```\n\nUseful for build steps that need fast temporary storage."
302
+ }
303
+ ]
304
+ },
305
+ "BUILDARCH": {
306
+ "contents": [
307
+ {
308
+ "value": "## BUILDARCH\n\n```dockerfile\nARG BUILDARCH\n```\n\nAutomatic build argument containing the CPU architecture of the build machine.\n\n**Values:** `amd64`, `arm64`, `arm`, `386`, `ppc64le`, `s390x`\n\n```dockerfile\nFROM golang:1.22\nARG BUILDARCH\nRUN echo \"Building on: $BUILDARCH\"\n```\n\n**Related:** `BUILDOS`, `BUILDPLATFORM`, `BUILDVARIANT`"
309
+ }
310
+ ]
311
+ },
312
+ "BUILDOS": {
313
+ "contents": [
314
+ {
315
+ "value": "## BUILDOS\n\n```dockerfile\nARG BUILDOS\n```\n\nAutomatic build argument containing the OS of the build machine.\n\n**Values:** `linux`, `windows`, `darwin`\n\n```dockerfile\nARG BUILDOS\nRUN echo \"Build OS: $BUILDOS\"\n```"
316
+ }
317
+ ]
318
+ },
319
+ "BUILDVARIANT": {
320
+ "contents": [
321
+ {
322
+ "value": "## BUILDVARIANT\n\n```dockerfile\nARG BUILDVARIANT\n```\n\nAutomatic build argument for the CPU variant (e.g., `v7` for ARMv7).\n\n```dockerfile\nARG BUILDVARIANT\nRUN echo \"Variant: ${BUILDVARIANT:-none}\"\n```"
323
+ }
324
+ ]
325
+ },
326
+ ".dockerignore": {
327
+ "contents": [
328
+ {
329
+ "value": "## .dockerignore\n\nFile that controls what gets sent to the Docker daemon as build context.\n\n```\n# .dockerignore\n.git\n.gitignore\nnode_modules\nnpm-debug.log\nDockerfile*\ndocker-compose*\n.dockerignore\n.env\n*.md\n.vscode\n__pycache__\n*.pyc\ndist\nbuild\n.tox\ncoverage\n.nyc_output\n```\n\n**Pattern syntax:**\n- `*` matches any sequence (excluding path separators)\n- `**` matches any number of directories\n- `!` excludes from ignore (re-include)\n- `#` comment line\n\n**Example with exception:**\n```\n*.md\n!README.md\n```\n\n**Why it matters:** Large build contexts slow down builds. Always exclude `node_modules`, `.git`, etc."
330
+ }
331
+ ]
332
+ },
333
+ "heredoc": {
334
+ "contents": [
335
+ {
336
+ "value": "## Heredoc Syntax\n\nInline multi-line content in Dockerfile (BuildKit 1.4+).\n\n**Inline files:**\n```dockerfile\n# syntax=docker/dockerfile:1\nCOPY <<EOF /app/config.json\n{\"port\": 3000}\nEOF\n```\n\n**Multi-line RUN:**\n```dockerfile\nRUN <<EOF\napt-get update\napt-get install -y curl git\nrm -rf /var/lib/apt/lists/*\nEOF\n```\n\n**With interpreter:**\n```dockerfile\nRUN <<EOF python3\nimport os\nprint(os.environ)\nEOF\n```\n\n**Multiple files:**\n```dockerfile\nCOPY <<app.py <<requirements.txt /app/\nfrom flask import Flask\napp = Flask(__name__)\napp.py\nflask>=3.0\nrequirements.txt\n```\n\n**Requires:** `# syntax=docker/dockerfile:1` or BuildKit >= 0.10"
337
+ }
338
+ ]
339
+ },
340
+ "--parents": {
341
+ "contents": [
342
+ {
343
+ "value": "## --parents (COPY flag)\n\n```dockerfile\nCOPY --parents <src> <dest>\n```\n\nPreserve the parent directory structure when copying.\n\n```dockerfile\n# Without --parents:\nCOPY src/app/config.json /dest/\n# Result: /dest/config.json\n\n# With --parents:\nCOPY --parents src/app/config.json /dest/\n# Result: /dest/src/app/config.json\n```\n\n**Requires:** BuildKit"
344
+ }
345
+ ]
346
+ },
347
+ "--keep-git-dir": {
348
+ "contents": [
349
+ {
350
+ "value": "## --keep-git-dir\n\n```dockerfile\nADD --keep-git-dir=true <git-url> <dest>\n```\n\nKeep the .git directory when adding from a Git repository URL.\n\n```dockerfile\nADD --keep-git-dir=true https://github.com/user/repo.git#main /src\n```\n\nBy default, .git is stripped. Useful when build needs Git metadata (version, commit hash)."
351
+ }
352
+ ]
353
+ }
354
+ }
355
+ }