简体   繁体   English

使用 Dockerfile 中的两个 COPY 语句复制依赖项,以便创建一个新层

[英]copy dependencies using two COPY statement in Dockerfile so it creates a new layer

I have a 'lib' folder containing product and third party dependencies.我有一个包含产品和第三方依赖项的“lib”文件夹。 I want to copy all dependencies to a same location using two COPY statements so that first layer will have third party dependencies and second layer will have internal dependencies.我想使用两个 COPY 语句将所有依赖项复制到同一位置,以便第一层将具有第三方依赖项,第二层将具有内部依赖项。

Current code:当前代码:

COPY XXX/BOOT-INF/lib /app/lib复制 XXX/BOOT-INF/lib /app/lib

Something I am seeking for:我正在寻找的东西:

COPY XXX/BOOT_INF/lib/[internal-dependencies] /app/lib/复制 XXX/BOOT_INF/lib/[内部依赖项] /app/lib/

COPY XXX/BOOT_INF/lib/[remaining-dependencies] /app/lib/复制 XXX/BOOT_INF/lib/[剩余依赖项] /app/lib/

Internal dependencies starts with a common prefix 'abc'.内部依赖项以公共前缀“abc”开头。

From Dockerfile reference: https://docs.docker.com/engine/reference/builder/#copy来自 Dockerfile 参考: https ://docs.docker.com/engine/reference/builder/#copy

You can copy specific files starting with a pattern with:您可以复制以模式开头的特定文件:

COPY abc* /app/lib

More info about how Docker matches files in COPY operations: https://pkg.go.dev/path/filepath#Match有关 Docker 如何在 COPY 操作中匹配文件的更多信息: https ://pkg.go.dev/path/filepath#Match

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM