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

Add NO_CACHE to build.sh #1404

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open

Conversation

mattg66
Copy link

@mattg66 mattg66 commented Feb 17, 2025

Add the ability to disable Docker build cache

New Behavior

Add the ability to disable the Docker build cache

Contrast to Current Behavior

If source code is changed, sometimes it is difficult to rebuild Docker images.

Discussion: Benefits and Drawbacks

Makes building custom images easier

Changes to the Wiki

None required

Proposed Release Note Entry

Adds the ability to disable Docker build cache

Double Check

  • I have read the comments and followed the PR template.
  • I have explained my PR according to the information in the comments.
  • My PR targets the develop branch.

Add the ability to disable Docker build cache
@cimnine
Copy link
Collaborator

cimnine commented Feb 17, 2025

If source code is changed, sometimes it is difficult to rebuild Docker images.

Could you explain or do you have an example when that's the case?

@mattg66
Copy link
Author

mattg66 commented Feb 17, 2025

I can probably provide screenshots of this if needed, but the build process sometimes skips past the container rebuild if you are doing in quick succession as it caches the results of the build

@cimnine
Copy link
Collaborator

cimnine commented Feb 18, 2025

I'm doing a lot of Docker builds and I never had this problem. So that's why I'm curious. Docker is extremely good at caching and cache invalidation. If the input doesn't change, then the output won't change. I therefore suspect a situation, where something goes wrong with the inputs. This could be due to one of the following reasons, and possibly more:

  • dockerignore file is too generous
  • build step order isn't optimal
  • something unfortunate in your Dockerfile

I'd like to find out if it's either of the first two. Then we have a problem in our build that we need to solve. Otherwise, it's probably an oversight in your Dockerfile.

Since the build script is used in CI/CD mostly, and since caching improves the build speed, I'd like to be sure that there's no problem with caching. Therefore, please bring forward an example where the build does not work as expected, so that we can investigate.

@mattg66
Copy link
Author

mattg66 commented Feb 18, 2025

Hi, Another case where this has gotten in the way is if a package has been recently updated on PyPI. I have wanted to test new plugin updates a few hours after release but the cache just skips past the stage where it pulls the packages. I'll try and work on some other examples that I have encountered

@cimnine
Copy link
Collaborator

cimnine commented Feb 18, 2025

if a package has been recently updated on PyPI

This should usually not be a problem. The currently best practice here is to specify the exact version of the plugin when building the container, because it's the only way to ensure that you get the same result everytime. So, when you update the version in the input file, then Docker will invalidate the cache.

@cimnine
Copy link
Collaborator

cimnine commented Feb 18, 2025

The downside is that this flag, once in, must be carried over and tested whenever we change the build process in the future. So if we can get away with not having the functionality, we'd rather not have it.

@mattg66
Copy link
Author

mattg66 commented Feb 18, 2025

Yeah that's understandable although I can't see how having the option to disable the cache will impact the build functionality

@cimnine
Copy link
Collaborator

cimnine commented Feb 22, 2025

although I can't see how having the option to disable the cache will impact the build functionality

It doesn't right now. But it will increase the maintenance down the road. E.g. when supporting another build system one day, like Podman. So if this flag is not absolutely needed, then we'd rather not have it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants