Replies: 3 comments
-
@jacobsfletch @jmikrut The pnpm build command in the build stage of Dockerfile requires a connection to the Database_URI so it can create pages, read collection schemas and configs, etc. This means it needs a postgres container up and running to which it can connect to when the Dockerfile is being built. When I run the Dockerfile as a standalone with a postgres container running and it's hostname specified as host.docker.internal, it is able to connect to the db and the image is successfully built. But the twist comes in the compose file. The compose file provided by payload in their documentation uses the node:18 alpine image to build the payload service along with a depends on postgres container to start the compose file. But, since we specified a Dockerfile, we want cms service to be built from it, instead of the node image, but that would require a postgres instance running. This all seems a bit confusing. The database must be accessible during both the image build process and the container runtime complicates the setup. Any help regarding this would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
I also have this issue—it's not possible or desirable to expose the production database to my CI system. I can create an ephemeral postgres in CI so that at least the empty schema can be created.... going to try that but it's unclear if that will lead to issues. |
Beta Was this translation helpful? Give feedback.
-
Yes this are a similar problem on our side. Not possible to build a production docker image without database connection. Doen't matter which kind of database do you use. I use mongo. I try to use sqllite for build only but this break other steps in the pipeline. Any idea? |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
I'm trying to Dockerize my Payload CMS application, but the build process fails with an error stating it couldn't connect to PostgreSQL. Here's an overview of my setup and the issue:
Context
build
stage in my.Dockerfile
looks like this:The .env.docker file contains the following environment variables needed at build time:
Reference
I’m following guidance from this blog: Next.js Runtime Variables, which recommends using environment variables for build-time configuration.
Question
Why is the Payload application trying to connect to PostgreSQL during the build process? Is there a way to bypass the connection step at build time? Or is my approach to handling environment variables for the Payload application in Docker incorrect?
Any guidance or best practices would be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions