next.js icon indicating copy to clipboard operation
next.js copied to clipboard

Fix with-docker example Dockerfile

Open aradhell opened this issue 2 years ago • 2 comments

Build fails if you have a local node_modules folder which doesn't match with container runtime.

also fixes https://github.com/getsentry/sentry-cli/issues/1317

Bug

  • [ ] Related issues linked using fixes #number
  • [ ] Integration tests added
  • [ ] Errors have a helpful link attached, see contributing.md

Feature

  • [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR.
  • [ ] Related issues linked using fixes #number
  • [ ] Integration tests added
  • [ ] Documentation added
  • [ ] Telemetry added. In case of a feature if it's used or not.
  • [ ] Errors have a helpful link attached, see contributing.md

Documentation / Examples

  • [x] Make sure the linting passes by running pnpm build && pnpm lint
  • [x] The "examples guidelines" are followed from our contributing doc

aradhell avatar Nov 07 '22 12:11 aradhell

How about ignoring local node_modules folder instead? Copying files over it helps avoid runtime issues, but local node_modules still end up in one of the image layers and thus increase total image size.

Hmm it’s there already:

https://github.com/vercel/next.js/blob/b1932b081a95bf535d82faef1c4d7d7ca3de2940/examples/with-docker/.dockerignore#L3

kachkaev avatar Nov 07 '22 15:11 kachkaev

I'm not totally convinced the builder step is even necessary. The with-docker-compose Dockerfile gets away without doing a full copy of node_modules.

If it is actually an optimization, I'd love to apply the fixed version to the other Docker examples as well.

maxproske avatar Nov 07 '22 16:11 maxproske

@leerob man you are good.

maxproske avatar Jun 15 '23 03:06 maxproske