Dockerfile COPY 跳过 git 子模块

问题描述 投票:0回答:1

有没有办法让

Dockerfile
COPY
命令跳过 Git 子模块?

我知道我可以设置

.dockerignore
,但我想知道是否可以在没有
.dockerignore
的情况下跳过 Git 子模块。

docker dockerfile git-submodules
1个回答
0
投票

您可能会考虑多阶段构建

# First Stage: Clone repository without submodules FROM alpine AS clone-stage RUN apk add --no-cache git \ && git clone --recurse-submodules=no https://github.com/your-repo.git /temp-dir # Second Stage: Copy the cloned data FROM your-base-image COPY --from=clone-stage /temp-dir /your-destination-dir
最终图像中没有子模块。

© www.soinside.com 2019 - 2024. All rights reserved.