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

Track injected files when caching Docker builds #273

Closed
nbraud opened this issue Apr 25, 2019 · 6 comments
Closed

Track injected files when caching Docker builds #273

nbraud opened this issue Apr 25, 2019 · 6 comments
Labels

Comments

@nbraud
Copy link

nbraud commented Apr 25, 2019

Description

Currently, Docker image builds are cached based on (a hash of) the Dockerfile's contents.
By opposition, Docker's canonical cache recognise ADD instructions, and will only reuse a built layer if the same file is being added.

Please consider aligning the behaviour with Docker's.
This can be done by tracking ADDed files and directory during the build, hashing them, and making that manifest part of the hash that identifies a specific build.

Context

When using Dockerfiles as CI environments, it is common to inject files that describe dependencies (Python's requirements files, Maven project files, ...) and preinstall all necessary dependencies.

With the current behaviour, Cirrus doesn't invalidate the cached build, resulting in CI environments that do not have the correct dependencies installed.

@nbraud nbraud added the feature label Apr 25, 2019
nbraud added a commit to nbraud/pursuedpybear that referenced this issue Apr 25, 2019
Pro: Works around an issue with the way Cirrus caches containers:
     cirruslabs/cirrus-ci-docs#273

Con:
- Requires regenerating/recommiting Dockerfiles whenever requirements change.
- This will break if the character `'` is used in requirements*.txt
@fkorotkov
Copy link
Contributor

Yeah. I've though about it and that might be a bit tricky. The solution I came up comes to the following new flow: when a Dockerfile contains COPY or ADD always try to build the container with a Docker builder that supports caching. I'm thinking about one of these options:

  1. https://github.com/uber/makisu with HTTP cache
  2. https://github.com/GoogleContainerTools/kaniko if Remote KV caching GoogleContainerTools/kaniko#463 will be implemented.

@fkorotkov
Copy link
Contributor

Created cirruslabs/cirrus-cli#222 to track implementation of this feature.

@fkorotkov
Copy link
Contributor

BTW there is a potential danger or using COPY and ADD instruction at the moment. See #760 for details.

@edigaryev
Copy link
Contributor

Implemented in cirruslabs/cirrus-cli#452.

@nbraud
Copy link
Author

nbraud commented Nov 28, 2021

Thanks a bunch! I look forward to using that, and/or the new Skylark support, to speed up our CI dramatically.

Back when I tested this, I could get Linux & Windows CI times below 5s w/ prebuilt containers, and the issue was that we had no good way to make it work properly when dependencies changed (either updates in PyPI, or changes in the requirements files)

@fkorotkov
Copy link
Contributor

@nbraud under 5 seconds!? Wow! Would love to see your confit if it will be public. 💪

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

No branches or pull requests

3 participants