mirror of
https://github.com/yeasy/docker_practice.git
synced 2026-03-29 13:15:24 +00:00
Add blank lines before headers
This commit is contained in:
@@ -15,6 +15,7 @@ BuildKit 引入了多项新指令,旨在优化构建缓存和安全性。以
|
||||
要使用最新的 Dockerfile 语法特性,建议在 Dockerfile 开头添加语法指令:
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
```
|
||||
@@ -53,6 +54,7 @@ COPY --from=builder /app/dist /app/dist
|
||||
`BuildKit` 提供了 `RUN --mount=type=cache` 指令,可以实现上边的设想。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
FROM node:alpine as builder
|
||||
@@ -68,6 +70,7 @@ RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=loc
|
||||
COPY src /app/src
|
||||
|
||||
RUN --mount=type=cache,target=/app/node_modules,id=my_app_npm_module,sharing=locked \
|
||||
|
||||
## --mount=type=cache,target=/app/dist,id=my_app_dist,sharing=locked \
|
||||
|
||||
npm run build
|
||||
@@ -107,6 +110,7 @@ RUN --mount=type=cache,target=/tmp/dist,from=builder,source=/app/dist \
|
||||
该指令可以将一个镜像 (或上一构建阶段) 的文件挂载到指定位置。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
RUN --mount=type=bind,from=php:alpine,source=/usr/local/bin/docker-php-entrypoint,target=/docker-php-entrypoint \
|
||||
@@ -118,6 +122,7 @@ RUN --mount=type=bind,from=php:alpine,source=/usr/local/bin/docker-php-entrypoin
|
||||
该指令可以将一个 `tmpfs` 文件系统挂载到指定位置。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
RUN --mount=type=tmpfs,target=/temp \
|
||||
@@ -129,6 +134,7 @@ RUN --mount=type=tmpfs,target=/temp \
|
||||
该指令可以将一个文件 (例如密钥) 挂载到指定位置。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
RUN --mount=type=secret,id=aws,target=/root/.aws/credentials \
|
||||
@@ -144,6 +150,7 @@ $ docker build -t test --secret id=aws,src=$HOME/.aws/credentials .
|
||||
该指令可以挂载 `ssh` 密钥。
|
||||
|
||||
```docker
|
||||
|
||||
## syntax=docker/dockerfile:1
|
||||
|
||||
FROM alpine
|
||||
|
||||
Reference in New Issue
Block a user