Open william-abboud opened 1 month ago
I'm on next 14, and I can' get serverComponentsExternalPackages
to work.
Do you need to copy next-logger
and pino
from node_modules
into the resulting Docker-container for this to work?
COPY --from=deps --chown=nextjs:nodejs /node_modules/pino ./
Or similar.
After struggling for a few hours I finally got
next-logger
andpino
to work within Docker but the docs here need to be improved. I hope by raising this issue it saves people time. Here are the necessary steps I took in order to get it to work correctly.next-logger.config.js
file is located in the root of the project (alongside package.json for example)NEXT_RUNTIME=nodejs
ENV variable in Docker - Sincenext-logger
is required ininstrumentation.ts|js
file typically the library will only be loaded if the runtime isnodejs
. This variable is set by Vercel automatically but if you are not deploying on Vercel you have to do it manually.Add
next-logger
andpino
toserverComponentsExternalPackages
property in Next configuration -Copy the
next-logger.config.js
file from the root of the project and place it in the runtime image in the same folder asserver.js
. Thank you: https://github.com/sainsburys-tech/next-logger/issues/26#issuecomment-2224101208 for thisThank you to all the developers making this project!