Skip to content

Commit ee00176

Browse files
committed
Provide dockerfile/cache-dir example in README
Signed-off-by: Curtis Vogt <[email protected]>
1 parent 4e6d40f commit ee00176

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

README.md

Lines changed: 28 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ This action be used for "non-reproducible" containers too.
1919
### apt-get GitHub Actions
2020

2121
Dockerfile:
22+
2223
```dockerfile
2324
FROM ubuntu:22.04
2425
ENV DEBIAN_FRONTEND=noninteractive
@@ -32,6 +33,7 @@ RUN \
3233
```
3334

3435
Action:
36+
3537
```yaml
3638
---
3739
name: Build
@@ -51,23 +53,18 @@ jobs:
5153
images: Build
5254

5355
- name: Cache
54-
uses: actions/cache@v3
56+
uses: actions/cache@v4
5557
id: cache
5658
with:
57-
path: |
58-
var-cache-apt
59-
var-lib-apt
60-
key: cache-${{ hashFiles('.github/workflows/test/Dockerfile') }}
59+
path: cache-mount
60+
key: cache-mount-${{ hashFiles('Dockerfile') }}
6161

62-
- name: inject cache into docker
63-
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
62+
- name: Restore Docker cache mounts
63+
uses: reproducible-containers/buildkit-cache-dance@v3
6464
with:
6565
builder: ${{ steps.setup-buildx.outputs.name }}
66-
cache-map: |
67-
{
68-
"var-cache-apt": "/var/cache/apt",
69-
"var-lib-apt": "/var/lib/apt"
70-
}
66+
cache-dir: cache-mount
67+
dockerfile: Dockerfile
7168
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
7269

7370
- name: Build and push
@@ -89,12 +86,28 @@ Real-world examples:
8986

9087
## CacheMap Options
9188

92-
Optionally, instead of a single string for the `target`, you can provide an object with additional options that should be passed to `--mount=type=cache` in the values `cache-map` JSON. The `target` path must be present in the object as a property.
89+
If you require more fine grained control you can manually specify a JSON formatted `cache-map`. The keys specify the paths on the Docker builder host to use as the bind source and the string value provides the cache mount `target` within the Docker build:
90+
91+
```yaml
92+
- name: Restore Docker cache mounts
93+
uses: reproducible-containers/buildkit-cache-dance@v3
94+
with:
95+
builder: ${{ steps.setup-buildx.outputs.name }}
96+
cache-map: |
97+
{
98+
"var-cache-apt": "/var/cache/apt",
99+
"var-lib-apt": "/var/lib/apt"
100+
}
101+
skip-extraction: ${{ steps.cache.outputs.cache-hit }}
102+
```
103+
104+
Alternatively, you can provide a JSON object with additional options that should be passed to `--mount=type=cache` in the values `cache-map` JSON. The `target` path must be present in the object as a property.
93105

94106
```yaml
95-
- name: inject cache into docker
96-
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
107+
- name: Restore Docker cache mounts
108+
uses: reproducible-containers/buildkit-cache-dance@v3
97109
with:
110+
builder: ${{ steps.setup-buildx.outputs.name }}
98111
cache-map: |
99112
{
100113
"var-cache-apt": {

0 commit comments

Comments
 (0)