You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi all! I'm trying to use PAYLOAD_PUBLIC variables with docker in production mode. In the examples of docker builds given in the documentation, everything works fine, but only in development mode.
Case:
Build docker image
Setting the date format from an environment variable for a container in production via docker-compose.
dateFormat: process.env.PAYLOAD_PUBLIC_DATE_FORMAT ||'MMMM do yyyy, h:mm a',
Problem: after building a docker image without variables PAYLOAD_PUBLIC is not applied
# DockerfileFROM node:18.8-alpine as base
WORKDIR /home/node/app
COPY . .
FROM base as dev
ENV NODE_ENV development
RUN yarn install
CMD ["yarn", "dev"]
FROM base as prod
ENV NODE_ENV production
RUN yarn install --frozen-lockfile --production
ENTRYPOINT ["sh", "entrypoint.sh"]
CMD ["node", "dist/server.js"]
How it works: Build docker image with target prod and run docker-compose with this image
The only thing that confuses me is that I have to build a project every time the container starts, maybe this is not critical.. what do you think about this?
# LOG
Build to update PAYLOAD_PUBLIC variables.
yarn run v1.22.19
$ cross-env NODE_ENV=production yarn build:payload && yarn build:server && yarn copyfiles
$ cross-env PAYLOAD_CONFIG_PATH=src/payload/payload.config.ts payload build
$ tsc --project tsconfig.server.json
$ copyfiles -u 1 "src/**/*.{html,css,scss,ttf,woff,woff2,eot,svg,jpg,png,js}" dist/
Done in 16.81s.
[23:24:18] INFO (payload): Connected to MongoDB server successfully!
[23:24:18] INFO (payload): Starting Payload...
[23:24:18] INFO (payload): Payload Admin URL:
[23:24:18] INFO (payload): Swagger URL: /api/doc/
[23:24:18] INFO (payload): App URL:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hi all! I'm trying to use PAYLOAD_PUBLIC variables with docker in production mode. In the examples of docker builds given in the documentation, everything works fine, but only in development mode.
Case:
Problem: after building a docker image without variables PAYLOAD_PUBLIC is not applied
How to solve:
Possible usage: docker-compose example
I would like to discuss an example implementation with you
How it works: Build docker image with target prod and run docker-compose with this image
The only thing that confuses me is that I have to build a project every time the container starts, maybe this is not critical.. what do you think about this?
--
refs:
#3758
#4892
Beta Was this translation helpful? Give feedback.
All reactions