From b7e15be418a2e8b984df6e68ea358685ec43e589 Mon Sep 17 00:00:00 2001 From: Lucas Tonon <105813423+lucastononro@users.noreply.github.com> Date: Sun, 17 Nov 2024 11:36:12 -0300 Subject: [PATCH] Update docker-compose and .env.example Error: Database URL: Environment variables loaded from .env Prisma schema loaded from prisma/postgresql-schema.prisma Datasource "db": PostgreSQL database "evolution", schema "public" at "localhost:5432" Error: P1001: Can't reach database server at localhost:5432 Fix: Update `docker-compose.yaml` and `.env.example` files to configure PostgreSQL service and connection URI. * **docker-compose.yaml** - Add `listen_addresses=*` command to the `postgres` service. - Add environment variables: `POSTGRES_USER=user`, `POSTGRES_PASSWORD=pass`, `POSTGRES_DB=evolution`, `POSTGRES_HOST_AUTH_METHOD=trust`. * **.env.example** - Update `DATABASE_CONNECTION_URI` to `postgresql://user:pass@postgres:5432/evolution?schema=public`. --- For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/EvolutionAPI/evolution-api?shareId=XXXX-XXXX-XXXX-XXXX). --- .env.example | 2 +- docker-compose.yaml | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index d6412fec..f5b7cde3 100644 --- a/.env.example +++ b/.env.example @@ -26,7 +26,7 @@ DEL_INSTANCE=false # Provider: postgresql | mysql DATABASE_PROVIDER=postgresql -DATABASE_CONNECTION_URI='postgresql://user:pass@localhost:5432/evolution?schema=public' +DATABASE_CONNECTION_URI='postgresql://user:pass@postgres:5432/evolution?schema=public' # Client name for the database connection # It is used to separate an API installation from another that uses the same database. DATABASE_CONNECTION_CLIENT_NAME=evolution_exchange diff --git a/docker-compose.yaml b/docker-compose.yaml index b286919c..9a60a9a9 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -34,12 +34,15 @@ services: image: postgres:15 networks: - evolution-net - command: ["postgres", "-c", "max_connections=1000"] + command: ["postgres", "-c", "max_connections=1000", "-c", "listen_addresses=*"] restart: always ports: - 5432:5432 environment: - - POSTGRES_PASSWORD=PASSWORD + - POSTGRES_USER=user + - POSTGRES_PASSWORD=pass + - POSTGRES_DB=evolution + - POSTGRES_HOST_AUTH_METHOD=trust volumes: - postgres_data:/var/lib/postgresql/data expose: