Payload doesn't start in docker

default discord avatar
Maxim Kobylinsky
3 months ago

Please help to launch payload in dockerfile.

My command start:

 "start": "cross-env PAYLOAD_CONFIG_PATH=dist/payload.config.js NODE_ENV=production node dist/server.js",

My Errors

  • default discord avatar
    3 months ago

    You can run de server.js directly with node. Like this:

    FROM node:18.16.0-bullseye-slim as base
    # Build container with dev dependencies
    FROM base as builder
    WORKDIR /home/node
    COPY package*.json ./
    COPY . .
    # Public env variables are added to the react frontend at build time by webpack.
    RUN npm install -g npm@latest && npm install && npm run build
    # Build production container
    FROM base as runtime
    ENV NODE_ENV=production
    ENV PAYLOAD_CONFIG_PATH=dist/payload.config.js
    ENV APP_PORT=8080
    WORKDIR /home/node
    COPY package*.json ./
    RUN npm install -g npm@latest && npm install --production --legacy-peer-deps && npm cache clean --force
    COPY --from=builder /home/node/dist ./dist
    COPY --from=builder /home/node/build ./build
    COPY --from=builder /home/node/public ./public
    EXPOSE 8080
    CMD ["node", "dist/server.js"]

    But you should have a look at your build logs, it looks like some dependencies are missing.

  • discord user avatar
    Payload Team
    3 months ago

    It's possible this is related to peer dependencies as well since you're using npm

    I would see if the example in the docs that uses yarn works any different:
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!


Connect with the Payload Community on Discord



Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.