Payload doesn't start in docker

default discord avatar
Maxim Kobylinsky
3 months ago
6

Please help to launch payload in dockerfile.



https://gist.github.com/kobylinsky-m/0a1d7aa64bc0a04d2bce2121b09c13dc#file-dockerfile-for-payload-cms

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
    mvdve
    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.
    ARG PAYLOAD_PUBLIC_FRONTEND_URL
    
    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
    denolfe
    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:

    https://payloadcms.com/docs/production/deployment#docker
Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

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