Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/build-push-docker-cache-map-docs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"build-push-docker": patch
---

Fix cache-map input description: recommend the object form with an explicit id
matching the Dockerfile cache mount id. The simple string form omits id, so
BuildKit keys the cache on the target path and never matches mounts that
define an explicit id.
9 changes: 9 additions & 0 deletions .changeset/docker-cache-map-input.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
"reusable-docker-build-publish": minor
---

Add `docker-cache-map` input, passed through to build-push-docker's `cache-map`.
Set it to restrict buildkit-cache-dance to specific cache mounts (e.g.
`'{"cache-mount/go-build-cache": {"id": "go-build-cache", "target": "/var/cache-target"}}'`)
instead of auto-discovering all cache mounts in the Dockerfile. Omit to keep
auto-discovery.
18 changes: 15 additions & 3 deletions .github/workflows/reusable-docker-build-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,17 @@
required: false
type: string
default: "write-on-trunk"
docker-cache-map:
description: |
JSON string mapping cache mount paths/names for buildkit-cache-dance, passed
through to build-push-docker's cache-map. Use the object form with an explicit
id matching the Dockerfile's cache mount id, e.g.
'{"cache-mount/go-build-cache": {"id": "go-build-cache", "target": "/var/cache-target"}}'.
Restricts cache-dance to only the listed mounts; if omitted, all cache mounts
are discovered from the Dockerfile.
required: false
type: string
default: ""
docker-build-context:
description: "Path to Docker build context."
required: true
Expand Down Expand Up @@ -437,12 +448,12 @@
docker-build-cache-from: ${{ steps.should-cache.outputs.docker-build-cache-from }}
docker-cache-suffix: ${{ steps.should-cache.outputs.docker-cache-suffix }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
persist-credentials: false
fetch-depth: 1
ref: ${{ inputs.git-sha }}
- name: Get Date

Check warning

Code scanning / CodeQL

Checkout of untrusted code in a non-privileged context Medium

Potential unsafe checkout of untrusted pull request on non-privileged workflow.
id: get-date
run: |
echo "Getting today's date..."
Expand Down Expand Up @@ -616,16 +627,16 @@
uses: smartcontractkit/.github/actions/free-disk-space@free-disk-space/v1

- name: Enable S3 Cache for Self-Hosted Runners
uses: runs-on/action@4e5f72399b6b17f2e79c511c1b38a315a64d22dc # v2.2.0
uses: runs-on/action@efac073ea2507ec18797de3a81704201ade11d9d # v2.3.1

- uses: actions/checkout@v6
- uses: actions/checkout@v7
id: checkout
with:
persist-credentials: false
fetch-depth: 1
ref: ${{ inputs.git-sha }}

- name: Compute per-architecture cache scope

Check warning

Code scanning / CodeQL

Checkout of untrusted code in a non-privileged context Medium

Potential unsafe checkout of untrusted pull request on non-privileged workflow.
id: compute-cache-scope
env:
RUNNER_OS: ${{ runner.os }}
Expand Down Expand Up @@ -780,6 +791,7 @@
docker-save-cache: ${{ needs.init.outputs.docker-save-cache }}
docker-build-cache-to: ${{ needs.init.outputs.docker-build-cache-to }},scope=${{ steps.compute-cache-scope.outputs.scope }}
docker-build-cache-from: ${{ needs.init.outputs.docker-build-cache-from }},scope=${{ steps.compute-cache-scope.outputs.scope }}
cache-map: ${{ inputs.docker-cache-map }}
context: ${{ inputs.docker-build-context }}
docker-build-contexts: ${{ inputs.docker-build-contexts }}
docker-push: ${{ inputs.docker-push }}
Expand Down
14 changes: 9 additions & 5 deletions actions/build-push-docker/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,11 @@ inputs:
default: "auto"
cache-map:
description: |
JSON string mapping cache mount paths/names for buildkit-cache-dance (e.g. '{"go-mod-cache": "/go/pkg/mod"}').
JSON string mapping cache mount paths/names for buildkit-cache-dance.
Use the object form with an explicit id matching the Dockerfile's cache mount id
(e.g. '{"cache-mount/go-build-cache": {"id": "go-build-cache", "target": "/var/cache-target"}}').
The simple string form omits id; BuildKit then keys the cache on the target path,
which will not match mounts that define an explicit id.
If omitted, buildkit-cache-dance automatically discovers mounts from the Dockerfile.
See: https://github.com/reproducible-containers/buildkit-cache-dance
See: https://docs.docker.com/build/ci/github-actions/cache/#cache-mounts
Expand Down Expand Up @@ -223,7 +227,7 @@ runs:
if:
${{ steps.dockerfile-ecr-parse.outputs.needs-ecr-login == 'true' ||
inputs.docker-push == 'true' }}
uses: aws-actions/configure-aws-credentials@e6de054238d6b7531b4efff3b6587d9aade6a06c # v6.2.3
uses: aws-actions/configure-aws-credentials@cbe3b392738ccf3f987d68400dafcf4b0624a56c # v6.2.4
with:
role-to-assume: ${{ inputs.aws-role-arn }}
role-duration-seconds: 900
Expand All @@ -232,14 +236,14 @@ runs:

- name: Login to private ECR registries for base images
if: ${{ steps.dockerfile-ecr-parse.outputs.needs-ecr-login == 'true' }}
uses: aws-actions/amazon-ecr-login@d539f0932e70871a027e9d5a9d8fc38589180a64 # v2.1.6
uses: aws-actions/amazon-ecr-login@03f1aad4c6c7ffd436567f42f9384779290529bd # v2.1.7
with:
registries: ${{ steps.dockerfile-ecr-parse.outputs.ecr-registries }}

- name: Login to ECR for publishing
if: ${{ inputs.docker-push == 'true' }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@d539f0932e70871a027e9d5a9d8fc38589180a64 # v2.1.6
uses: aws-actions/amazon-ecr-login@03f1aad4c6c7ffd436567f42f9384779290529bd # v2.1.7
with:
registry-type: >-
${{
Expand All @@ -251,7 +255,7 @@ runs:

- name: Set up Docker Buildx
id: setup-buildx
uses: docker/setup-buildx-action@bb05f3f5519dd87d3ba754cc423b652a5edd6d2c # v4.2.0
uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0
with:
# https://github.com/docker/buildx/tags
version: v0.35.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,17 @@ on:
required: false
type: string
default: "write-on-trunk"
docker-cache-map:
description: |
JSON string mapping cache mount paths/names for buildkit-cache-dance, passed
through to build-push-docker's cache-map. Use the object form with an explicit
id matching the Dockerfile's cache mount id, e.g.
'{"cache-mount/go-build-cache": {"id": "go-build-cache", "target": "/var/cache-target"}}'.
Restricts cache-dance to only the listed mounts; if omitted, all cache mounts
are discovered from the Dockerfile.
required: false
type: string
default: ""
docker-build-context:
description: "Path to Docker build context."
required: true
Expand Down Expand Up @@ -433,7 +444,7 @@ jobs:
docker-build-cache-from: ${{ steps.should-cache.outputs.docker-build-cache-from }}
docker-cache-suffix: ${{ steps.should-cache.outputs.docker-cache-suffix }}
steps:
- uses: actions/checkout@v6
- uses: actions/checkout@v7
with:
persist-credentials: false
fetch-depth: 1
Expand Down Expand Up @@ -612,9 +623,9 @@ jobs:
uses: smartcontractkit/.github/actions/free-disk-space@free-disk-space/v1

- name: Enable S3 Cache for Self-Hosted Runners
uses: runs-on/action@4e5f72399b6b17f2e79c511c1b38a315a64d22dc # v2.2.0
uses: runs-on/action@efac073ea2507ec18797de3a81704201ade11d9d # v2.3.1

- uses: actions/checkout@v6
- uses: actions/checkout@v7
id: checkout
with:
persist-credentials: false
Expand Down Expand Up @@ -776,6 +787,7 @@ jobs:
docker-save-cache: ${{ needs.init.outputs.docker-save-cache }}
docker-build-cache-to: ${{ needs.init.outputs.docker-build-cache-to }},scope=${{ steps.compute-cache-scope.outputs.scope }}
docker-build-cache-from: ${{ needs.init.outputs.docker-build-cache-from }},scope=${{ steps.compute-cache-scope.outputs.scope }}
cache-map: ${{ inputs.docker-cache-map }}
context: ${{ inputs.docker-build-context }}
docker-build-contexts: ${{ inputs.docker-build-contexts }}
docker-push: ${{ inputs.docker-push }}
Expand Down
Loading