style: apply global formatting fixes (struct, spacing, zhlint)

This commit is contained in:
Baohua Yang
2026-02-21 11:08:52 -08:00
parent ad68b2d973
commit 79ac9c639a
159 changed files with 1708 additions and 882 deletions

View File

@@ -48,7 +48,7 @@ COPY --from=builder /app/dist /app/dist
使用多阶段构建构建的镜像中只包含了目标文件夹 `dist`但仍然存在一些问题 `package.json` 文件变动时`RUN npm i && rm -rf ~/.npm` 这一层会重新执行变更多次后生成了大量的中间层镜像
为解决这个问题进一步的我们可以设想一个类似 **数据卷** 的功能在镜像构建时把 `node_modules` 文件夹挂载上去在构建完成后这个 `node_modules` 文件夹会自动卸载实际的镜像中并不包含 `node_modules` 这个文件夹这样我们就省去了每次获取依赖的时间大大增加了镜像构建效率同时也避免了生成了大量的中间层镜像
为解决这个问题进一步的我们可以设想一个类似**数据卷**的功能在镜像构建时把 `node_modules` 文件夹挂载上去在构建完成后这个 `node_modules` 文件夹会自动卸载实际的镜像中并不包含 `node_modules` 这个文件夹这样我们就省去了每次获取依赖的时间大大增加了镜像构建效率同时也避免了生成了大量的中间层镜像
`BuildKit` 提供了 `RUN --mount=type=cache` 指令可以实现上边的设想
@@ -104,7 +104,7 @@ RUN --mount=type=cache,target=/tmp/dist,from=builder,source=/app/dist \
#### `RUN --mount=type=bind`
该指令可以将一个镜像或上一构建阶段的文件挂载到指定位置
该指令可以将一个镜像 (或上一构建阶段) 的文件挂载到指定位置
```docker
## syntax=docker/dockerfile:1
@@ -126,7 +126,7 @@ RUN --mount=type=tmpfs,target=/temp \
#### `RUN --mount=type=secret`
该指令可以将一个文件(例如密钥)挂载到指定位置
该指令可以将一个文件 (例如密钥) 挂载到指定位置
```docker
## syntax=docker/dockerfile:1