Can't get build to connect to postgres
I verified that the connection works with pg_isready, however during the build step it fails to connect to localhost (and the provided db url)
@calcom/prisma:build: Prisma schema loaded from schema.prisma
@calcom/prisma:build: Datasource "db": PostgreSQL database "calcom", schema "public" at "localhost:5432"
@calcom/prisma:build:
@calcom/prisma:build: Error: P1001: Can't reach database server at `localhost`:`5432`
@calcom/prisma:build:
@calcom/prisma:build: Please make sure your database server is running at `localhost`:`5432`.
@calcom/prisma:build: error Command failed with exit code 1.
@calcom/prisma:build: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
@calcom/prisma:build: error Command failed with exit code 1.
@calcom/prisma:build: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Any hints? I spent quite some time to debug this
Is Postgres in the same container as cal.com ? If not then your postgresql instance is not reachable on local host.
Do you have a docked-compose or something like that ?
Localhost to the container, during the build, is the container itself and not your local development machine.
The docker compose build steps are provided because it creates a network bridge which allows you to reference a postgres container to build against.
It's worth mentioning that the build does not need to reference the same database as it will reference in runtime.
I'm having the same issue, but in my case I had setup container_name: database on docker-compose.yaml and the build still fails. Also tried to replace the container name for the IP and it also fails.
#0 8.862 @calcom/prisma:db-deploy: Error: P1001: Can't reach database server at `172.20.0.2`:`5432`
#0 8.862 @calcom/prisma:db-deploy:
#0 8.863 @calcom/prisma:db-deploy: Please make sure your database server is running at `172.20.0.2`:`5432`.
#0 8.896 @calcom/prisma:db-deploy: error Command failed with exit code 1.
#0 8.896 @calcom/prisma:db-deploy: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#0 8.926 @calcom/prisma:db-deploy: error Command failed with exit code 1.
#0 8.926 @calcom/prisma:db-deploy: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#0 8.939 @calcom/prisma:db-deploy: ERROR: command finished with error: command (packages/prisma) yarn run db-deploy exited (1)
#0 8.959 command (packages/prisma) yarn run db-deploy exited (1)
#0 8.959
#0 8.959 Tasks: 2 successful, 3 total
#0 8.960 Cached: 1 cached, 3 total
#0 8.960 Time: 8.208s
#0 8.960
#0 8.994 error Command failed with exit code 1.
#0 8.995 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
failed to solve: executor failed running [/bin/sh -c yarn build]: exit code: 1
It didn't work using the default network created by compose. However, once I added a dedicated network it worked out by running the container on its own. FWIW, I have it running behind a reverse proxy (traefik) that requires my own custom docker-compose setup.
@moekify what do you mean by a dedicated network? As far as I know, the one in docker-compose is already shared by the three containers.
@brunoamaral I wrote my own docker-compose as I have a lot of custom properties for traefik (reverse-proxy) to work correctly with calcom :) I usually use the default network that gets created by docker-compose instead of specifying a new network inside the compose file. However, with the default network it didn't work in calcoms case. Why, I don't know 🤷