Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

chore(Dockerfile): best practices #10708

Merged

Conversation

maxime1907
Copy link
Contributor

@maxime1907 maxime1907 commented Dec 11, 2023

What type of PR is this?

/kind cleanup

What this PR does / why we need it:
Apply best practices recommended by hadolint:

  • Lock dependencies for reproducible builds
  • Lock image with SHA for reproducible builds
  • Mount cache directories for faster builds
  • Separate RUN directives to avoid rebuilding every layer each time a python dependency changes
  • Put COPY directives at the end to avoid rebuilding every layer each time a playbook file changes

Does this PR introduce a user-facing change?:

Update dockerfile to follow best practices

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 11, 2023
@k8s-ci-robot
Copy link
Contributor

Hi @maxime1907. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 11, 2023
@MrFreezeex
Copy link
Member

MrFreezeex commented Dec 11, 2023

Hi! Thanks for your contribution. Indeed reproducibility is a good practice and we should aim to have the best reproducibility possible and I am all in team reproducibility in general. Although as you have noticed in your other PR we have failed to update a quite simple list of dependencies so I am not sure adding a bunch more of them is the right way to go.

Also I don't expect for the most of apt deps version to really affects kubespray/ansible in a significant way, so I would not be favorable to pin all of those. Kubespray is designed to run on many kinds of system and I don't think that the majority of our users even use the docker image so it shouldn't matter that much what the version of ssh is on the user's system for instance and pinning every apt deps will just put more strain on the maintainers of kubespray for, IMO, little added value.

Although the rest of the change about caching mounts and moving the RUN around to improve caching looks good indeed 👍

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 11, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2023
@maxime1907
Copy link
Contributor Author

Hi! Thanks for your contribution. Indeed reproducibility is a good practice and we should aim to have the best reproducibility possible and I am all in team reproducibility in general. Although as you have noticed in your other PR we have failed to update a quite simple list of dependencies so I am not sure adding a bunch more of them is the right way to go.

Also I don't expect for the most of apt deps version to really affects kubespray/ansible in a significant way, so I would not be favorable to pin all of those. Kubespray is designed to run on many kinds of system and I don't think that the majority of our users even use the docker image so it shouldn't matter that much what the version of ssh is on the user's system for instance and pinning every apt deps will just put more strain on the maintainers of kubespray for, IMO, little added value.

Although the rest of the change about caching mounts and moving the RUN around to improve caching looks good indeed 👍

Hi! Yes i understand your point of view so i have removed the pinned apt dependencies so should be good to go!

Copy link
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

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

Thanks!

One small comment about the dockerfile syntax pinning but outside of that it looks very good thanks! Although could you apply the same set of changes to pipeline.Dockerfile which is used intensively in the CI?

Dockerfile Outdated Show resolved Hide resolved
@maxime1907
Copy link
Contributor Author

Thanks!

One small comment about the dockerfile syntax pinning but outside of that it looks very good thanks! Although could you apply the same set of changes to pipeline.Dockerfile which is used intensively in the CI?

I will open another PR when these are merged:

Copy link
Member

@MrFreezeex MrFreezeex left a comment

Choose a reason for hiding this comment

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

Arf sorry for that the pipeline seems to be currently too busy (https://gitlab.com/kargo-ci/kubernetes-sigs-kubespray/-/pipelines)... Could you amend/push force in like ~2hours (or more).

Asides from that thank you very much for this contribution!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 12, 2023
@MrFreezeex
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Dec 12, 2023
@maxime1907
Copy link
Contributor Author

Arf sorry for that the pipeline seems to be currently too busy (https://gitlab.com/kargo-ci/kubernetes-sigs-kubespray/-/pipelines)... Could you amend/push force in like ~2hours (or more).

Asides from that thank you very much for this contribution! /lgtm

Oh i see but i think you can just close and reopen my PR and this will retrigger github pipelines!

@MrFreezeex
Copy link
Member

Arf sorry for that the pipeline seems to be currently too busy (https://gitlab.com/kargo-ci/kubernetes-sigs-kubespray/-/pipelines)... Could you amend/push force in like ~2hours (or more).
Asides from that thank you very much for this contribution! /lgtm

Oh i see but i think you can just close and reopen my PR and this will retrigger github pipelines!

I can't do that unfortunately :(

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Dec 12, 2023
Signed-off-by: Maxime Leroy <19607336+maxime1907@users.noreply.github.com>
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Dec 13, 2023
@MrFreezeex
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 13, 2023
Copy link
Member

@floryut floryut left a comment

Choose a reason for hiding this comment

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

@maxime1907 Thank you 👍

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: floryut, maxime1907, MrFreezeex

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 13, 2023
@floryut floryut added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 13, 2023
@k8s-ci-robot k8s-ci-robot merged commit 9a31f32 into kubernetes-sigs:master Dec 13, 2023
64 checks passed
@yankay yankay mentioned this pull request Dec 15, 2023
pedro-peter pushed a commit to pedro-peter/kubespray that referenced this pull request May 8, 2024
Signed-off-by: Maxime Leroy <19607336+maxime1907@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants