Next.js Discord

Discord Forum

Next/Image components fail to compile during Docker build stage

Unanswered
Philippine Crocodile posted this in #help-forum
Open in Discord
Philippine CrocodileOP
I get an error when running my GH Action script to build and deploy my docker image:

./src/app/lib/data.ts
#15 21.83 Module not found: Can't resolve '@/../public/siteimg1.png'


I can't seem to get the public folder copied prior to the build stage, either:

21 | >>> COPY --from=base /app/public ./public
  22 |     COPY . .
  23 |     
--------------------
ERROR: failed to solve: failed to compute cache key: failed to calculate checksum of ref .....: "/app/public": not found


I'm using the standalone configuration setting and can get this same project to build locally no issues, but on production it's not building.

Anyone seen this before?

1 Reply

Philippine CrocodileOP
I ended up replacing Image imports with hardcoded URLs which seemed to build fine, I got it to deploy but now getting 404 on EVERYTHING on the site. THe only image that loads is external, LOL.

I think this is due to the copy command I did in docker and the default path it's searching for the chunks exported to standalone.

To give an idea of my path problem currently:

Files are stored at: app/.next/static/chunks/
Next app running is searching: site.com/public/_next/static/chunks/...

Stuck trying to resolve this.