payloadcms / payload

Payload is the open-source, fullstack Next.js framework, giving you instant backend superpowers. Get a full TypeScript backend and admin panel instantly. Use Payload as a headless CMS or for building powerful applications.
https://payloadcms.com
MIT License
24.48k stars 1.55k forks source link

Errors when build and deploy #6798

Open wyxcoder opened 4 months ago

wyxcoder commented 4 months ago

Link to reproduction

No response

Describe the Bug

I tried to deploy the code to Cloud Run, but encountered strange errors. I then tried to build local docker image. I did the below steps: 1, docker build . --tag able-wso , this step completed fine 2, docker run -e PAYLOAD_SECRET=thisisatest -e PAYLOAD_PUBLIC_SERVER_URL=http://localhost:8080 -e http://localhost:8080 -e DATABASE_URI=mongodb://127.0.0.1/payload-template-ecommerce able-wso

I got error unhandledRejection Error: Cannot find module '/home/node/app/dist/payload.config.js' I tried to solve this error by copying payload.config.js over, but then I got another error and more errors.

I wonder if this Dockerfile was tested. Or simply I did someone wrong?

To Reproduce

npx create-payload-app@latest to create a website named able-wso docker build . --tag able-wso docker run -e PAYLOAD_SECRET=thisisatest -e PAYLOAD_PUBLIC_SERVER_URL=http://localhost:8080 -e http://localhost:8080 -e DATABASE_URI=mongodb://127.0.0.1/payload-template-ecommerce able-wso

Payload Version

v2

Adapters and Plugins

db-mongodb

aklos commented 3 months ago

The issue seems to be specific to the ecommerce template.

Line 15 in the Dockerfile is wrong: ENV PAYLOAD_CONFIG_PATH=dist/payload.config.js. Build actually outputs the config to dist/payload/.

Even if you fix that, the app fails to launch because of missing .next folder (if you're using the ecommerce template frontend), so here are the Dockerfile edits to hopefully get it running: