Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Payload doesn't start in docker

default discord avatar
wg9002 years ago
2

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
    mvdve2 years 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
    2 years 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
Star on GitHub

Star

Chat on Discord

Discord

online

Can't find what you're looking for?

Get dedicated engineering support directly from the Payload team.