Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't get build to connect to postgres #134

Open
moekify opened this issue Jun 22, 2022 · 6 comments
Open

Can't get build to connect to postgres #134

moekify opened this issue Jun 22, 2022 · 6 comments
Assignees

Comments

@moekify
Copy link

moekify commented Jun 22, 2022

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

@finaldzn
Copy link

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 ?

@krumware
Copy link
Member

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.

@brunoamaral
Copy link

brunoamaral commented Jun 23, 2022

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

@moekify
Copy link
Author

moekify commented Jun 23, 2022

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.

@brunoamaral
Copy link

@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.

@moekify
Copy link
Author

moekify commented Jun 27, 2022

@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 🤷

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants