Skip to content

Optimize Dockerfile for faster rebuilds#808

Merged
scragly merged 2 commits into
python-discord:masterfrom
spyoungtech:master
Mar 1, 2020
Merged

Optimize Dockerfile for faster rebuilds#808
scragly merged 2 commits into
python-discord:masterfrom
spyoungtech:master

Conversation

@spyoungtech
Copy link
Copy Markdown
Contributor

@spyoungtech spyoungtech commented Mar 1, 2020

This change optimizes the docker build so that a cached layer for installing dependencies can be used, instead of installing dependencies every build.

@spyoungtech spyoungtech requested a review from a team as a code owner March 1, 2020 14:49
@spyoungtech spyoungtech requested review from GhostofGoes and kwzrd and removed request for a team March 1, 2020 14:49
@Akarys42
Copy link
Copy Markdown
Contributor

Akarys42 commented Mar 1, 2020

And what if the dependencies changed? I had to rebuild the image earlier today because new dependencies were added, maybe that's not the intended way, is it?

@spyoungtech
Copy link
Copy Markdown
Contributor Author

If the dependencies change, the pipfile/pipfile.lock file needs to change. When either of those files change, the cached layer will not be used and the layer will be built the same way it is today.

Copy link
Copy Markdown
Contributor

@MarkKoz MarkKoz left a comment

Choose a reason for hiding this comment

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

This has no benefits in CI because the agent is new for every build, thus does not have previous layers cached. Furthermore, contributors using Docker would only need to build this image if dependencies change (cause their source code on the host gets mounted inside the container), so this change doesn't benefit them.

Still, I don't see why not. Maybe it will save someone time somehow.

@spyoungtech
Copy link
Copy Markdown
Contributor Author

Yeah, I'm pretty sure CI won't leverage caching. GitLab can do that, but not sure about ADO.

Mostly it's beneficial for local development :)

@scragly scragly merged commit 9d9b703 into python-discord:master Mar 1, 2020
@MarkKoz MarkKoz added a: CI Related to continuous intergration and deployment t: feature New feature or request labels Mar 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: CI Related to continuous intergration and deployment t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants