Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Dockerfile: go mod cache #3142

Merged
merged 1 commit into from
Jan 26, 2024
Merged

Dockerfile: go mod cache #3142

merged 1 commit into from
Jan 26, 2024

Conversation

7sunarni
Copy link
Contributor

@7sunarni 7sunarni commented Sep 26, 2023

@volcano-sh-bot
Copy link
Contributor

Welcome @7sunarni!

It looks like this is your first PR to volcano-sh/volcano 馃帀.

Thank you, and welcome to Volcano. 😃

@volcano-sh-bot volcano-sh-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Sep 26, 2023
@7sunarni
Copy link
Contributor Author

assign @Thor-wl

@7sunarni 7sunarni closed this Oct 27, 2023
@7sunarni 7sunarni reopened this Oct 31, 2023
@7sunarni
Copy link
Contributor Author

Hi~ Can you take minutes review this, it could speed up CI stage
@william-wang

@hwdef
Copy link
Member

hwdef commented Oct 31, 2023

please make the DCO CI happy first

@7sunarni
Copy link
Contributor Author

please make the DCO CI happy first

Done

@hwdef
Copy link
Member

hwdef commented Oct 31, 2023

/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Oct 31, 2023
@7sunarni
Copy link
Contributor Author

7sunarni commented Nov 3, 2023

It seems both of reviewers not active any more, how about assign new reviewer?

@volcano-sh-bot volcano-sh-bot removed the lgtm Indicates that a PR is ready to be merged. label Dec 18, 2023
@volcano-sh-bot volcano-sh-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jan 18, 2024
@7sunarni
Copy link
Contributor Author

7sunarni commented Jan 18, 2024

Update: this commit use alpine mirror to speed up building webhook-manager docker image. I think most of Volcano's user in mainland. This mirror could be useful in improving building container image.

@7sunarni
Copy link
Contributor Author

@Monokaix Hi~ Sorry to tag you. It looks like that two reviewers assigned not active in this project. Do you know how and who to assign new reviewers?

@Monokaix
Copy link
Member

Update: this commit use alpine mirror to speed up building webhook-manager docker image. I think most of Volcano's user in mainland. This mirror could be useful in improving building container image.

It's a good intention here. But volcano is used all over the world, we should not specify cdn url in a hard code way, my opinion is that set a parameter like env to let user specify custom cdn url or just disable it: )

@Monokaix
Copy link
Member

Welcome! A little doubt here. Does this cache optimization you mentioned only take effect when building multiple binaries? Seems that when we execute make vc-controller-manager, the go mod download will be executed, and after your pr, this step has been moved to the front, so what's the difference here?

@7sunarni
Copy link
Contributor Author

Does this cache optimization you mentioned only take effect when building multiple binaries?

I think when your change not including go.mod and go.sum file and just including some go file, in docker building stage, this will not download dependency. Not only in building multiple binaries, and in local develop/test stage building image.

Seems that when we execute make vc-controller-manager, the go mod download will be executed, and after your pr, this step has been moved to the front, so what's the difference here?

As I know, docker will use the cache if the file don't change. In most case, go.mod and go.sum will not change, so docker will use cache in step3 and step4 . This is also what Docker document recommend us to do. And if we just copy .volcano to the build, this step has file change, docker will not use cache from this.

@volcano-sh-bot volcano-sh-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Jan 25, 2024
ADD . volcano
RUN cd volcano && make vc-webhook-manager

FROM alpine:latest
ARG KUBE_VERSION="1.27.0"
ARG TARGETARCH
RUN apk add --update ca-certificates && \
ARG APK_MIRROR
RUN if [[ -n "$APK_MIRROR" ]]; then sed -i "s@https://dl-cdn.alpinelinux.org@${APK_MIRROR}@g" /etc/apk/repositories ; fi && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should also add --build-args includes this env in docker build command: )

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right.

@Monokaix
Copy link
Member

Monokaix commented Jan 25, 2024

Does this cache optimization you mentioned only take effect when building multiple binaries?

I think when your change not including go.mod and go.sum file and just including some go file, in docker building stage, this will not download dependency. Not only in building multiple binaries, and in local develop/test stage building image.

Seems that when we execute make vc-controller-manager, the go mod download will be executed, and after your pr, this step has been moved to the front, so what's the difference here?

As I know, docker will use the cache if the file don't change. In most case, go.mod and go.sum will not change, so docker will use cache in step3 and step4 . This is also what Docker document recommend us to do. And if we just copy .volcano to the build, this step has file change, docker will not use cache from this.

Got that! And please rebase and make a clean pr.

@7sunarni
Copy link
Contributor Author

Update: this commit use alpine mirror to speed up building webhook-manager docker image. I think most of Volcano's user in mainland. This mirror could be useful in improving building container image.

It's a good intention here. But volcano is used all over the world, we should not specify cdn url in a hard code way, my opinion is that set a parameter like env to let user specify custom cdn url or just disable it: )

You are right. I add a argument like --build-arg APK_MIRROR="https://mirrors.huaweicloud.com" to let users do their choice, default will not do anything.

By the way, it seems you are from Huawei. And the usage in this official article seems have a little mistake. The config command should be sed -i "s@https://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories . The comments in this article had point out this mistake, but not correct yet. :-(

@Monokaix
Copy link
Member

Update: this commit use alpine mirror to speed up building webhook-manager docker image. I think most of Volcano's user in mainland. This mirror could be useful in improving building container image.

It's a good intention here. But volcano is used all over the world, we should not specify cdn url in a hard code way, my opinion is that set a parameter like env to let user specify custom cdn url or just disable it: )

You are right. I add a argument like --build-arg APK_MIRROR="https://mirrors.huaweicloud.com" to let users do their choice, default will not do anything.

By the way, it seems you are from Huawei. And the usage in this official article seems have a little mistake. The config command should be sed -i "s@https://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories . The comments in this article had point out this mistake, but not correct yet. :-(

Thanks, I will convey the mistake but I'm not responsible for that article actually: )

@Monokaix
Copy link
Member

Update: this commit use alpine mirror to speed up building webhook-manager docker image. I think most of Volcano's user in mainland. This mirror could be useful in improving building container image.

It's a good intention here. But volcano is used all over the world, we should not specify cdn url in a hard code way, my opinion is that set a parameter like env to let user specify custom cdn url or just disable it: )

You are right. I add a argument like --build-arg APK_MIRROR="https://mirrors.huaweicloud.com" to let users do their choice, default will not do anything.

By the way, it seems you are from Huawei. And the usage in this official article seems have a little mistake. The config command should be sed -i "s@https://dl-cdn.alpinelinux.org/@https://repo.huaweicloud.com/@g" /etc/apk/repositories . The comments in this article had point out this mistake, but not correct yet. :-(

You can also make suggestions in the forum https://bbs.huaweicloud.com/suggestion/new directly.

@hwdef hwdef removed their assignment Jan 25, 2024
@7sunarni
Copy link
Contributor Author

Does this cache optimization you mentioned only take effect when building multiple binaries?

I think when your change not including go.mod and go.sum file and just including some go file, in docker building stage, this will not download dependency. Not only in building multiple binaries, and in local develop/test stage building image.

Seems that when we execute make vc-controller-manager, the go mod download will be executed, and after your pr, this step has been moved to the front, so what's the difference here?

As I know, docker will use the cache if the file don't change. In most case, go.mod and go.sum will not change, so docker will use cache in step3 and step4 . This is also what Docker document recommend us to do. And if we just copy .volcano to the build, this step has file change, docker will not use cache from this.

Got that! And please rebase and make a clean pr.

Done

@Monokaix
Copy link
Member

--build-arg APK_MIRROR="https://mirrors.huaweicloud.com"

Is "--build-arg APK_MIRROR="https://mirrors.huaweicloud.com" updated? I didn't see that yet: )

@william-wang
Copy link
Member

retrigger the ci.

@7sunarni
Copy link
Contributor Author

--build-arg APK_MIRROR="https://mirrors.huaweicloud.com"

Is "--build-arg APK_MIRROR="https://mirrors.huaweicloud.com" updated? I didn't see that yet: )

I don't add this parameter in Makefile. If this parameter is missing, it will not change the alpine mirror.

@Monokaix
Copy link
Member

--build-arg APK_MIRROR="https://mirrors.huaweicloud.com"

Is "--build-arg APK_MIRROR="https://mirrors.huaweicloud.com" updated? I didn't see that yet: )

I don't add this parameter in Makefile. If this parameter is missing, it will not change the alpine mirror.

Can the env transfer to docker image context?Seems that the env should be transferred through build-arg.

…t allow using alpine mirror

Signed-off-by: 7sunarni <710720732@qq.com>
@7sunarni
Copy link
Contributor Author

--build-arg APK_MIRROR="https://mirrors.huaweicloud.com"

Is "--build-arg APK_MIRROR="https://mirrors.huaweicloud.com" updated? I didn't see that yet: )

I don't add this parameter in Makefile. If this parameter is missing, it will not change the alpine mirror.

Can the env transfer to docker image context?Seems that the env should be transferred through build-arg.

It can. I add parameter to the Makefile.

@Monokaix
Copy link
Member

/lgtm

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Jan 26, 2024
Copy link
Member

@william-wang william-wang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: william-wang

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 26, 2024
@7sunarni
Copy link
Contributor Author

@volcano-sh-bot CI

@volcano-sh-bot volcano-sh-bot merged commit a566d48 into volcano-sh:master Jan 26, 2024
14 checks passed
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants