I have a nextjs react app, which runs in a docker container. It was working few days back now I see a random docker build error
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 9125c105-47b0-4d56-8450-36f7dd9aa68d::2kg5012vpvayjscu47vims02t: "/app/.next/static": not found
The issue i see here is docker keeps using cached resources for everything from copying source files (even though i changed them) to npm installs and builds
Dockerfile
FROM node:22-alpine
ENV NEXT_TELEMETRY_DISABLED 1
ENV APP_ENV production
ENV NODE_ENV production
WORKDIR /app
COPY . .
RUN npm ci --omit=dev
RUN npm run build
COPY /app/.next/standalone /app
COPY /app/public /app/public
COPY /app/.next/static /app/.next/static
# CMD ["/app/scripts/run.sh"]
CMD ["node", "/app/server.js"]
Buildlog
➜ repo git:(main) ✗ PROGRESS_NO_TRUNC=1 docker build --no-cache --progress plain -t tmp:tmp .
#0 building with "desktop-linux" instance using docker driver
#1 [internal] load build definition from Dockerfile
#1 transferring dockerfile: 366B done
#1 DONE 0.0s
#2 [internal] load metadata for docker.io/library/node:22-alpine
#2 DONE 0.4s
#3 [internal] load .dockerignore
#3 transferring context: 2B done
#3 DONE 0.0s
#4 [1/8] FROM docker.io/library/node:22-alpine@sha256:415f3219943ef82fa45988acdaa7df05a0b52cabd3502095c59d34cbe28c1bc1
#4 DONE 0.0s
#5 [2/8] WORKDIR /app
#5 CACHED
#6 [internal] load build context
#6 transferring context: 59.52kB 0.0s done
#6 DONE 0.0s
#7 [5/8] RUN npm run build
#7 CACHED
#8 [4/8] RUN npm ci --omit=dev
#8 CACHED
#9 [8/8] COPY /app/.next/static /app/.next/static
#9 ERROR: failed to calculate checksum of ref 9125c105-47b0-4d56-8450-36f7dd9aa68d::knwbuedqsipon8v7qwkk9a6pn: "/app/.next/static": not found
#10 [7/8] COPY /app/public /app/public
#10 ERROR: failed to calculate checksum of ref 9125c105-47b0-4d56-8450-36f7dd9aa68d::knwbuedqsipon8v7qwkk9a6pn: "/app/public": not found
#11 [6/8] COPY /app/.next/standalone /app
#11 ERROR: failed to calculate checksum of ref 9125c105-47b0-4d56-8450-36f7dd9aa68d::knwbuedqsipon8v7qwkk9a6pn: "/app/.next/standalone": not found
#12 [3/8] COPY . .
#12 CANCELED
------
> [6/8] COPY /app/.next/standalone /app:
------
------
> [7/8] COPY /app/public /app/public:
------
------
> [8/8] COPY /app/.next/static /app/.next/static:
------
Dockerfile:15
--------------------
13 | COPY /app/.next/standalone /app
14 | COPY /app/public /app/public
15 | >>> COPY /app/.next/static /app/.next/static
16 |
17 | # CMD ["/app/scripts/run.sh"]
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref 9125c105-47b0-4d56-8450-36f7dd9aa68d::knwbuedqsipon8v7qwkk9a6pn: "/app/.next/static": not found
View build details: docker-desktop://dashboard/build/desktop-linux/desktop-linux/vtugiztotdf5bm7ygu9ecc06u
There is no dockerignore file and have already tried running docker system prune -a