Skip to content

Commit

Permalink
Problems problems
Browse files Browse the repository at this point in the history
  • Loading branch information
cgreening committed Feb 18, 2021
0 parents commit be02841
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM node

RUN mkdir /app
COPY . /app

WORKDIR /app
RUN yarn

ENTRYPOINT ["yarn", "start"]
49 changes: 49 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
This project recreates the issues with layers disappearing from images when using the `cache-from` argument.

To recreate run the following steps:

```
DOCKER_BUILDKIT=1 docker build -t cgreening/cache_problem:1 . --build-arg BUILDKIT_INLINE_CACHE=1
docker push cgreening/cache_problem:1
docker run -it --entrypoint /bin/bash cgreening/cache_problem:1
root@f3b83bd929e6:/app# ls
Dockerfile README.md index.js node_modules package.json yarn.lock
```

Clean up just like on the build machine:

```
docker system prune -a
```

Build again

```
DOCKER_BUILDKIT=1 docker build -t cgreening/cache_problem:2 . --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from cgreening/cache_problem:1
docker push cgreening/cache_problem:2
docker run -it --entrypoint /bin/bash cgreening/cache_problem:2
root@f3b83bd929e6:/app# ls
Dockerfile README.md index.js node_modules package.json yarn.lock
```

Clean up again:

```
docker system prune -a
```

Build again

```
DOCKER_BUILDKIT=1 docker build -t cgreening/cache_problem:3 . --build-arg BUILDKIT_INLINE_CACHE=1 --cache-from cgreening/cache_problem:2
docker push cgreening/cache_problem:3
docker run -it --entrypoint /bin/bash cgreening/cache_problem:3
root@462e81ea94e4:/app# ls
Dockerfile README.md index.js package.json
```

You will see that there is no `node_modules` folder. This folder should have been created by the step:

```
RUN yarn
```
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
console.log("It works!");
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "docker-cache-issue",
"version": "1.0.0",
"main": "index.js",
"author": "Chris Greening <[email protected]>",
"license": "MIT"
}

0 comments on commit be02841

Please sign in to comment.