Skip to content

Commit 4582354

Browse files
committed
Update
1 parent 235f1ee commit 4582354

File tree

5 files changed

+48
-5
lines changed

5 files changed

+48
-5
lines changed

.github/workflows/release.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ jobs:
3939

4040
steps:
4141
- uses: actions/checkout@v2
42+
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
4243

4344
- name: Extract
4445
id: extract
@@ -66,6 +67,7 @@ jobs:
6667

6768
steps:
6869
- uses: actions/checkout@v2
70+
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
6971

7072
- name: Extract
7173
id: extract
@@ -81,7 +83,6 @@ jobs:
8183
- uses: ./action-dlc
8284
name: Run satackey/action-docker-layer-caching@${{ steps.extract.outputs.branch }}
8385
with:
84-
# repotag: test_project_node
8586
key: docker-layer-caching-test_project_node-sha:${{ github.sha }}-{hash}
8687
restore-keys: docker-layer-caching-test_project_node-sha:${{ github.sha }}-
8788

@@ -117,8 +118,6 @@ jobs:
117118
- build_and_push
118119

119120
steps:
120-
- uses: actions/checkout@v2
121-
122121
- name: Extract
123122
id: extract
124123
run: |

.github/workflows/test_readme.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ jobs:
1313

1414
steps:
1515
- uses: actions/checkout@v2
16+
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
1617
- uses: satackey/action-docker-layer-caching@v0.0
18+
- run: docker rmi $(docker image ls -q)
1719
- run: docker-compose -f test_project/docker-compose.yml -p test_project build --no-cache
1820

1921
cached_build:
@@ -23,6 +25,7 @@ jobs:
2325

2426
steps:
2527
- uses: actions/checkout@v2
28+
- run: docker-compose -f test_project/docker-compose.yml -p test_project pull
2629
- uses: satackey/action-docker-layer-caching@v0.0
2730

2831
- name: Get cached image ID

README.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# action-docker-layer-caching [![Readme Test](https://github.com/satackey/action-docker-layer-caching/workflows/Readme%20Test/badge.svg)](https://github.com/satackey/action-docker-layer-caching/actions?query=workflow%3A%22Readme+Test%22) [![CI](https://github.com/satackey/action-docker-layer-caching/workflows/CI/badge.svg)](https://github.com/satackey/action-docker-layer-caching/actions?query=workflow%3ACI)
22

3-
Enable docker layer caching by adding a single line.
3+
With only one additional line, you can enable Docker layer caching.
4+
5+
You can use `docker build` and `docker-compose build` with the cache without any special configuration,
6+
and there is also support for multi-stage builds.
47

58
```yaml
69
name: Readme Test
@@ -13,6 +16,26 @@ jobs:
1316

1417
steps:
1518
- uses: actions/checkout@v2
16-
- uses: satackey/action-docker-layer-caching@v0.0 # Images created after this action is called are cached.
19+
20+
# Avoid caching pull-only images.(docker pull is faster than caching.)
21+
- run: docker-compose pull
22+
23+
# Images created after this action is called are cached.
24+
- uses: satackey/action-docker-layer-caching@v0.0
1725
- run: docker-compose build
1826
```
27+
28+
---
29+
30+
By default, the cache is separated by the name of the workflow.
31+
You can configure manually cache keys.
32+
33+
```yaml
34+
- uses: satackey/action-docker-layer-caching@v0.0
35+
with:
36+
key: foo-docker-cache-{hash}
37+
restore-keys: |
38+
foo-docker-cache-
39+
```
40+
41+
**Note: You must include `{hash}` in the `key` input.** (`{hash}` will be replaced with the hash value of the docker image).

test_project/Dockerfile

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
1+
FROM node:12-alpine as curl-env
2+
RUN set -x \
3+
apk update && \
4+
apk add curl && \
5+
mkdir -p /src && \
6+
curl -o /src/install.sh -L https://yarnpkg.com/install.sh && \
7+
chmod +x /src/install.sh && \
8+
apk del curl
9+
110
FROM node:12-alpine
211

12+
COPY --from=curl-env /src/install.sh /tmp/install.sh
13+
RUN set -x \
14+
apk update && \
15+
apk add curl && \
16+
/tmp/install.sh && \
17+
apk del curl
18+
319
WORKDIR /app
420
COPY package.json yarn.lock ./
521
RUN yarn install --frozen-lockfile

test_project/docker-compose.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,5 @@ services:
55
build:
66
context: ../
77
dockerfile: ./test_project/Dockerfile
8+
mysql_pull_only:
9+
image: mysql:8.0

0 commit comments

Comments
 (0)