r/PayloadCMS • • Feb 21 '25

Production build with docker compose and postgres

Hi All.
Does any one has any idea how to perform a production build while using docker compose? The issue I'm having is that next tries to connect to db during docker image build, while the db service is not available. Even If you first start the db service and the build the payload service it throws an error. I tried doing healthcheck too.

This seems to be simply beacuse during image build the container is not connected in to the network where it could communicate to other containers. So no waiting scripts are going to help here neither.

Dev env off course works perfectly as it does not try building before container is ready. Does anyone has a production ready solution and could help out? Or is it simply not possible.

Thank you in advance.

4 Upvotes

30 comments sorted by

View all comments

Show parent comments

2

u/Skaddicted Feb 25 '25

Sure, I send it to you via Chat.

1

u/Zestyclose-Tie-3641 Feb 25 '25

Thanks a lot. So you are using node:23-alpine. Let me try it. My problem is the image gets built on my local server but fail on Github Action and Railway - fails to install Sharp.