From c497e895ba28983eca753dedd896478f5fa9ecdc Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 13 Sep 2024 09:32:14 +0800 Subject: [PATCH] Dockerfile action: README.md add build_context example Signed-off-by: Ash --- actions/dockerfile/1.0/README.md | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/actions/dockerfile/1.0/README.md b/actions/dockerfile/1.0/README.md index 5d6cb4b6..cef532db 100644 --- a/actions/dockerfile/1.0/README.md +++ b/actions/dockerfile/1.0/README.md @@ -4,7 +4,7 @@ #### 使用 -dockerfile 位于应用根目录: +1. dockerfile 位于应用根目录: ```yml - dockerfile: @@ -16,7 +16,7 @@ dockerfile 位于应用根目录: NODE_OPTIONS: --max_old_space_size=3040 ``` -dockerfile 位于应用子目录下: +2. dockerfile 位于应用子目录下: ```yml - dockerfile: @@ -24,3 +24,30 @@ dockerfile 位于应用子目录下: workdir: ${git-checkout} path: subdir/Dockerfile ``` + +3. 构建上下文配置 + +```yml +- stage: + - git-checkout: + alias: git-checkout + version: "1.0" + ... + - git-checkout: + alias: other-repo + version: "1.0" + ... +- stage: + - dockerfile: + params: + build_context: + other-resource: ${other-repo} + workdir: ${git-checkout} + path: subdir/Dockerfile +``` + +在 `Dockerfile` 中,使用 `COPY` 指令从不同的构建上下文(如 other-resource)中复制资源: + +```Dockerfile +COPY --from=other-resource +``` \ No newline at end of file