go-kratos / kratos-layout

Kratos Project Template
http://go-kratos.dev
MIT License
402 stars 205 forks source link

Dockerfile 中是否可以添加先下载依赖的逻辑? #135

Closed kvii closed 10 months ago

kvii commented 1 year ago

可以在 Dockerfile 中添加下面的逻辑:

# 先下载依赖。
COPY go.mod .
COPY go.sum .
RUN go mod download

# 然后再拷贝工程文件并打包。
COPY . .
RUN go build ...
...

加上这样一段逻辑后,如果工程的依赖版本没有变动的话,再次构建镜像时就会跳过下载依赖的步骤。这样就能减少下载依赖的时间。减少本地调试或频繁发板时的等待时间。

dosubot[bot] commented 10 months ago

Hi, @kvii. I'm Dosu, and I'm helping the kratos-layout team manage their backlog. I wanted to let you know that we are marking this issue as stale.

From what I understand, you suggested adding logic to the Dockerfile to skip downloading dependencies if their versions haven't changed. This would save time during local debugging or frequent image builds. However, there hasn't been any activity or comments on the issue since you created it.

Could you please let us know if this issue is still relevant to the latest version of the kratos-layout repository? If it is, please comment on the issue to let us know. Otherwise, feel free to close the issue yourself, or the issue will be automatically closed in 7 days.

Thank you for your contribution!