Payload CMS Deploy With Docker On Digital Ocean App Platform Fails To Pick Up Secret ENV Var

131 Views Asked by At

I'm trying to run the base website template of the payload CMS on Digital Ocean's App Platform. My build currently fails with the following error:

"a secret key is needed to secure payload"

Which points to it not picking the PAYLOAD_SECRET env var. I do have this set in the environment variables section of my app, and can see it is getting picked up in the logs along with my database connection:

configuring build-time app environment variables:
DATABASE_URI PAYLOAD_SECRET 

I'm not very familiar with docker so I'm not sure why this isn't getting picked up during the build.

For reference, here's the Dockerfile:

FROM node:18.8-alpine as base

FROM base as builder

WORKDIR /home/node/app
COPY package*.json ./

COPY . .
RUN yarn install
RUN yarn build

FROM base as runtime

ENV NODE_ENV=production
ENV PAYLOAD_CONFIG_PATH=dist/payload.config.js

WORKDIR /home/node/app
COPY package*.json  ./
COPY yarn.lock ./

RUN yarn install --production
COPY --from=builder /home/node/app/dist ./dist
COPY --from=builder /home/node/app/build ./build

EXPOSE 3000

CMD ["node", "dist/server.js"]
0

There are 0 best solutions below