-
Notifications
You must be signed in to change notification settings - Fork 545
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
GHA Cache intermittent - Ignoring npm install
/ node_modules
#1023
Comments
I am facing same issue that the |
I'm think also seeing (something like?) this, but surprisingly only for 1 app out of 6. Can't figure out what's different about it.
|
Confirmed, same problem on my CI. |
Same problem for me. Strangely when bypassing the |
The same problem happens to me. Is there any solution? FROM node:18.15-alpine AS base
RUN apk add tzdata && ln -snf /usr/share/zoneinfo/Asia/Seoul /etc/localtime
FROM base AS builder
WORKDIR /app
COPY package-lock.json package.json tsconfig.build.json tsconfig.json ./
RUN npm install
COPY src ./src
RUN npm run build
FROM base AS runner
WORKDIR /app
COPY --from=builder /app/package*.json /app/tsconfig*.json ./
COPY --from=builder /app/node_modules ./node_modules
COPY --from=builder /app/dist ./dist
EXPOSE 3000
CMD [ "npm", "run", "start" ] name: Docker Cache Test
on:
push:
branches: main
jobs:
docker-cache-test:
runs-on: ubuntu-22.04
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Set Up Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64
- name: Build & Push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: '${{ steps.login-ecr.outputs.registry }}/actions_test:latest'
cache-from: type=gha
cache-to: type=gha, mode=max
provenance: false ...
#10 [builder 2/5] COPY package-lock.json package.json tsconfig.build.json tsconfig.json ./
#10 DONE 1.2s
#11 [builder 3/5] RUN npm install
#11 10.91
#11 10.91 added 714 packages, and audited 715 packages in 10s
#11 10.91
#11 10.91 116 packages are looking for funding
#11 10.91 run `npm fund` for details
#11 10.92
#11 10.92 found 0 vulnerabilities
#11 10.92 npm notice
#11 10.92 npm notice New major version of npm available! 9.5.0 -> 10.5.2
#11 10.92 npm notice Changelog: <https://github.com/npm/cli/releases/tag/v10.5.2>
#11 10.92 npm notice Run `npm install -g npm@10.5.2` to update!
#11 10.92 npm notice
#11 DONE 11.0s
#12 [builder 4/5] COPY src ./src
#12 DONE 1.1s
#13 [builder 5/5] RUN npm run build
#13 0.536
#13 0.536 > docker_cache@0.0.1 build
#13 0.536 > nest build
#13 0.536
#13 DONE 4.8s
#14 [runner 2/4] COPY --from=builder /app/package*.json /app/tsconfig*.json ./
#14 CACHED
#15 [runner 3/4] COPY --from=builder /app/node_modules ./node_modules
#15 CACHED
#15 [runner 3/4] COPY --from=builder /app/node_modules ./node_modules
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 0B / 31.17MB 0.2s
#15 sha256:546c24b708c7d128e445c9a0461c7072e0d3d0c0abbaea7abc4e9d8f760303f1 81.60kB / 81.60kB 0.2s done
#15 extracting sha256:546c24b708c7d128e445c9a0461c7072e0d3d0c0abbaea7abc4e9d8f760303f1 done
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 4.19MB / 31.17MB 0.5s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 6.29MB / 31.17MB 0.6s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 9.44MB / 31.17MB 0.8s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 13.63MB / 31.17MB 0.9s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 17.83MB / 31.17MB 1.1s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 22.02MB / 31.17MB 1.2s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 26.21MB / 31.17MB 1.4s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 30.41MB / 31.17MB 1.5s
#15 sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 31.17MB / 31.17MB 1.6s done
#15 extracting sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4
#15 extracting sha256:47368dd19a5d423d64f17607c08d29e7fc545064a8e1322a88937fbc7aeb74f4 3.3s done
#15 DONE 5.0s
... |
I am having the same issue, it also happens with |
Maybe cache is being evicted because you exceed storage limit: https://docs.github.com/en/actions/using-workflows/caching-dependencies-to-speed-up-workflows#usage-limits-and-eviction-policy
You can check that at |
Have the same behavior with the registry cache (using AWS ECR) |
Contributing guidelines
I've found a bug, and:
Description
SO Link here:
https://stackoverflow.com/questions/77623949/docker-caching-on-github-actions-npm-install-is-not-cached
I am using the documented examples for caching Docker build layers via the GitHub Actions cache described here.
It appears to be working mostly as intended. It does successfully create a cache - and seems to pull many layers from it - but it does not cache arguably the most important layer:
npm-modules
No changes to the dependency files are occurring during/prior to the builds below. Theoretically, these layers should be 100% reusable unless we make changes to the
package.json
- and it would save my build time ~1.5minMy setup in the workflow:
Relevant stage of the Dockerfile:
Some steps are caching, from logs e.g.:
However, the next steps seemingly fail to cache - especially the
npm ci
step:Weirdly, later in the Dockerfile I reference these modules:
...which pulls from the cache, apparently.
Expected behaviour
GHA Cache should cache all layers which are unchanged between builds.
Actual behaviour
GHA Cache is caching only some layers, and not the
node_modules
- which is arguably the most important layer to cache.IMPORTANT NOTE: Layer caching with this Dockerfile works as expected locally. That is to say, the
npm ci
step is cached/reused on my local machine usingdocker build
when no changes to the dependencies are present.YAML workflow
The text was updated successfully, but these errors were encountered: