Replies: 1 comment
-
Ehy I remember I had a similar issue with docker and nextjs standalone output. Take a look at the official example of dockerfile https://github.com/vercel/next.js/blob/canary/examples/with-docker/Dockerfile from nextjs repository. I tweaked that a bit to accept some custom args I use and make it work with monorepo, anyway the lines that copy files are already in the dockerfile: # Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static However I saw my setup and I only have APP_DIR=/apps/mypayloadapp # this is the folder of the app I want to build
CI_BUILD_COMMAND=ci:myapp:build # this command is from the root /package.json And so I changed the Dockerfile a bit like the following: # Automatically leverage output traces to reduce image size
# https://nextjs.org/docs/advanced-features/output-file-tracing
COPY --from=builder --chown=nextjs:nodejs /app${APP_DIR}/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app${APP_DIR}/.next/static .${APP_DIR}/.next/static |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I'm running Payload CMS in a Next.js monorepo,
using the recommended build and deploying via Docker. The build and container start without errors, and all static assets (CSS, JS) are present in
/app/.next/static
inside the container.this is the
next.config.mjs
However, when accessing the app running in container (Docker, mapped port), all requests to
/_next/static/*
(e.g. CSS, JS) return404
, even though the files exist and are not empty. This happens for all assets, not just CSS.-p 9035:3000
)..next/static
to the container root.apps/cms/server.js
.basePath
orassetPrefix
is set innext.config.mjs
.Payload CMS UI loads, but without styles/scripts when running in docker.
What could cause Next.js standalone to return 404 for all static assets in Docker, despite the files being present? Is there a known issue or required config for Payload CMS + Next.js in monorepo/standalone builds?
Any help or pointers appreciated!
Beta Was this translation helpful? Give feedback.
All reactions