-
Notifications
You must be signed in to change notification settings - Fork 2
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 support for docker build caching, disabled by default #313
Changes from all commits
e4847a6
845eb9f
b5ba9dc
34cf7e9
9e26b7e
b7a9a3c
49d2f33
f572f09
c76acc4
7521945
92e73cd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,13 +63,9 @@ inputs: | |
default: 'false' | ||
description: 'Generate tag only.' | ||
required: false | ||
CACHE_FROM: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are not used by any consuming repos and not exposed in the ci workflows so removing them |
||
default: 'type=gha' | ||
description: 'Cache from.' | ||
required: false | ||
CACHE_TO: | ||
default: 'type=gha,mode=max' | ||
description: 'Cache to.' | ||
ENABLE_CACHE: | ||
default: 'false' | ||
description: 'Whether to use cache when building the image' | ||
required: false | ||
outputs: | ||
IMAGE_TAG: | ||
|
@@ -126,15 +122,31 @@ runs: | |
run: echo BUILD_ARGS=${{inputs.BUILD_ARGS}} >> $GITHUB_ENV | ||
shell: bash | ||
|
||
- name: Build and export to Docker | ||
- name: Build and export to Docker without cache | ||
uses: docker/build-push-action@v6 | ||
if: inputs.TAG_ONLY == 'false' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TAG_ONLY is never used as far as I can tell, in any consuming repos, so removing to simplify the flag logic There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
if: inputs.ENABLE_CACHE == 'false' | ||
with: | ||
load: true | ||
tags: | | ||
${{ steps.meta.outputs.tags }} | ||
no-cache: true | ||
file: ${{ inputs.FILE }} | ||
context: ${{ inputs.CONTEXT }} | ||
# cannot use multiple platforms with `load`, build a single arch image for validation purposes in CI | ||
platforms: linux/amd64 | ||
build-args: ${{ env.BUILD_ARGS }} | ||
secrets: ${{ env.DOCKER_SECRETS }} | ||
|
||
- name: Build and export to Docker with cache | ||
uses: docker/build-push-action@v6 | ||
if: inputs.ENABLE_CACHE == 'true' | ||
with: | ||
load: true | ||
tags: | | ||
${{ steps.meta.outputs.tags }} | ||
# cache-from: type=gha | ||
# cache-to: type=gha,mode=max | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
no-cache: false | ||
file: ${{ inputs.FILE }} | ||
context: ${{ inputs.CONTEXT }} | ||
# cannot use multiple platforms with `load`, build a single arch image for validation purposes in CI | ||
|
@@ -155,16 +167,31 @@ runs: | |
docker logs test | ||
${{ inputs.CONTAINER_TEST_COMMAND }} | ||
|
||
- name: Build and push | ||
if: inputs.PUSH == 'true' # && inputs.TAG_ONY == 'false' | ||
- name: Build and push with cache | ||
if: inputs.PUSH == 'true' && inputs.ENABLE_CACHE == 'true' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: | | ||
${{ steps.meta.outputs.tags }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
no-cache: false | ||
file: ${{ inputs.FILE }} | ||
context: ${{ inputs.CONTEXT }} | ||
platforms: ${{ inputs.PLATFORMS }} | ||
build-args: ${{ env.BUILD_ARGS }} | ||
secrets: ${{ env.DOCKER_SECRETS }} | ||
|
||
- name: Build and push without cache | ||
if: inputs.PUSH == 'true' && inputs.ENABLE_CACHE == 'false' | ||
uses: docker/build-push-action@v6 | ||
with: | ||
push: true | ||
tags: | | ||
${{ steps.meta.outputs.tags }} | ||
cache-from: ${{ inputs.CACHE_FROM }} | ||
cache-to: ${{ inputs.CACHE_TO }}} | ||
file: ${{ inputs.FILE }} | ||
no-cache: true | ||
context: ${{ inputs.CONTEXT }} | ||
platforms: ${{ inputs.PLATFORMS }} | ||
build-args: ${{ env.BUILD_ARGS }} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This input should be removed as well if we're eliminating
TAG_ONLY
entirely.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i can keep it if we think it is or should be used? would need to understand the use case that led to it being added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From what I can see, the only use I've seen so far is in the cd-retag workflow, which tags an existing image with another tag and pushes it. Let's keep things as-is for now.