calcom / docker

The Docker configuration for Cal.com is an effort powered by people within the community. Cal.com, Inc. does not provide official support for Docker, but we will accept fixes and documentation. Use at your own risk.
MIT License
663 stars 345 forks source link

build fails with Can't reach database server at `localhost`:`5432` #163

Closed drwb closed 1 year ago

drwb commented 2 years ago

Every time I sit down to try and get this running I seem to take a step backwards.

A new pull, from scratch, on a cleaned-out docker.

DOCKER_BUILDKIT=0 docker compose build calcom

Fails with

@calcom/prisma:build: Prisma schema loaded from schema.prisma
@calcom/prisma:build: Datasource "db": PostgreSQL database "calcom", schema "public" at "localhost:5450"
@calcom/prisma:build: 
@calcom/prisma:build: Error: P1001: Can't reach database server at `localhost`:`5450`
@calcom/prisma:build: 
@calcom/prisma:build: Please make sure your database server is running at `localhost`:`5450`.
@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.

The docker compose up -d database command created:

90638b40ac21   postgres                    "docker-entrypoint.s…"   18 minutes ago   Up 18 minutes            5432/tcp   database

Port 5432 is confirmed in docker container inspect 90638b40ac21

"Ports": {
                "5432/tcp": null
            },

But even if I change the DATABASE_URL in .env to :5432 it fails with the same error.

h1k3rr commented 1 year ago

have you check they're both on the same docker network ?

krumware commented 1 year ago

(I think we might have addressed this one slack, but some time has passed)

If anyone else has this issue, double check the DATABASE_URL in your .env using localhost:5432 (like in this example here) won't work without some additional configuration, because localhost to the container is not the same address as the machine hosting the containers nor the database container. DATABASE_URL needs to reference the database container via the {database container name}:5432, or a different available database address. (The example .env uses database:5432 for this reason) localhost:5432 doesn't exist because there is no database running inside the calcom web frontend container.

krumware commented 1 year ago

@drwb can you please retry with the latest instructions, following the Run steps without the build?

rwakcjr commented 1 year ago

I have managed to get it working.

Workaround:

krumware commented 1 year ago

👍 just fyi for others, the docker-compose up -d database command addresses this

ctqctq commented 1 year ago

if you want to use localhost:5450, then you need to map the ports of your postgres db out to the host

ports:
  -  5450:5432

or else you should just use the service name, whether it is "db" or "database" or "postgres" etc., use docker ps to check the name of your running postgres container

krumware commented 1 year ago

closing for inactivity

satoshinotdead commented 1 year ago

+1 just fyi for others, the docker-compose up -d database command addresses this

Still not working, there is no localhost:5432 but a container from Calcom with 5432 port without IP related.

Can you share a complete docker-compose.yml or point what we need to add into it for use the app like many others on Docker?

Thanks.

krumware commented 1 year ago

The provided docker-compose.yml is complete. Can you please advise on what is missing?