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

Cache docker layers in CI build #628

Closed
wants to merge 2 commits into from

Conversation

kentbull
Copy link
Contributor

@kentbull kentbull commented Dec 8, 2023

This should speed up successive Docker image builds.

Copy link
Member

@pfeairheller pfeairheller left a comment

Choose a reason for hiding this comment

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

We don't deploy using this workflow so I have no way to test this.

path: /tmp/.buildx-cache
key: keri-${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
keri-${{ runner.os }}-buildx-
Copy link
Member

Choose a reason for hiding this comment

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

Is something missing from the end of this line?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, it's just a match prefix.

The reason it doesn't make sense to include the ${{ github.sha }} value in match line (restore-keys) the line is because you only want to invalidate the Docker cache when the internals of the Docker Build command detect a change needed.

The ${{ github.sha }} value changes on every new commit which would mean an entirely new cache folder on every commit which defeats the purpose of caching. The value you can gain with caching only comes from the intermediary Docker image layers prior to the COPY command for copying source code in.

Typically this only happens when you make a change to the Dockerfile or when something copied in with a COPY command changes.

@kentbull
Copy link
Contributor Author

kentbull commented Dec 8, 2023

Which workflow is used for deployment? I'll copy this over.

@kentbull
Copy link
Contributor Author

kentbull commented Dec 8, 2023

I see the python-app-ci.yaml

It's not too much different to integrate it into a docker build command though you do have to change it to use docker buildx rather than docker build, which is pretty much the same.

I see the --no-cache option in the docker build command though:

docker build -f .github/workflows/interop/Dockerfile --no-cache -t ${{ env.GITHUB_REPOSITORY_NAME }}/keripy-interop:${{ env.CACHE_KEY_INTEROP }} .

Is the --no-cache necessary? If so then we can close this PR as caching would be irrelevant.

@m00sey m00sey requested a review from pfeairheller January 18, 2024 15:08
@kentbull kentbull closed this Feb 22, 2024
@kentbull kentbull deleted the cache-docker-layers branch May 15, 2024 22:34
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