Next.js Discord

Discord Forum

Vercel/postgres and NextJs dockerization problem

Unanswered
Polish posted this in #help-forum
Open in Discord
PolishOP
I was using the vercel/postgres locally with the help of docker
services:
  postgres:
    image: postgres
    environment:
      POSTGRES_PASSWORD: password
    # Expose the Postgres port to the host machine,
    # so you can inspect and administrate it
    ports:
      - '54320:5432'
  pg_proxy:
    image: ghcr.io/neondatabase/wsproxy:latest
    environment:
      APPEND_PORT: 'postgres:5432'
      ALLOW_ADDR_REGEX: '.*'
      LOG_TRAFFIC: 'true'
    ports:
      # Expose the WebSocket proxy port to the host machine,
      # this is where @vercel/postgres will connect
      - '54330:80'
    depends_on:
      - postgres

everthing works find with i use db from docker and npm run dev locally

but when i try to dockerize the whole app like this by adding

...................
  next_js:
    build:
      context: .
      dockerfile: Dockerfile
    env_file:
        - .env.development
        - .env.local
    environment:
      VERCEL_ENV: .env.development
      POSTGRES_URL: postgresql://postgres:password@postgres:5432/postgres
    ports:
      - '3000:3000'
    depends_on:
      - pg_proxy
    volumes:
      - .:/home/app


It shows an error for every sql.query()

Error: VercelPostgresError - 'invalid_connection_string': This connection string is meant to be used with a direct connection. Make sure to use a pooled connection string or try createClient() instead.

Source
db/controller/usercontroller.ts (22:28) @ query

20 | //check if the email already exists
21 | export async function checkUserEmail(email: string) {
22 | const result = await sql.query(`
| ^

0 Replies