curveball / a12n-server

An open source lightweight OAuth2 server
Apache License 2.0
447 stars 49 forks source link

[Docker image] Postgres - no schema has been selected to create in #494

Closed elaugier closed 2 months ago

elaugier commented 5 months ago

Hello,

I'm trying to setup a12n-server by using the official docker image in docker compose but i get the following error when the container starts:

2024-03-25 11:18:37 Could not start a12n-server
2024-03-25 11:18:37 error: create table "knex_migrations" ("id" serial primary key, "name" varchar(255), "batch" integer, "migration_time" timestamptz) - no schema has been selected to create in
2024-03-25 11:18:37     at Parser.parseErrorMessage (/opt/app/node_modules/pg-protocol/dist/parser.js:287:98)
2024-03-25 11:18:37     at Parser.handlePacket (/opt/app/node_modules/pg-protocol/dist/parser.js:126:29)
2024-03-25 11:18:37     at Parser.parse (/opt/app/node_modules/pg-protocol/dist/parser.js:39:38)
2024-03-25 11:18:37     at Socket.<anonymous> (/opt/app/node_modules/pg-protocol/dist/index.js:11:42)
2024-03-25 11:18:37     at Socket.emit (node:events:518:28)
2024-03-25 11:18:37     at addChunk (node:internal/streams/readable:559:12)
2024-03-25 11:18:37     at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)
2024-03-25 11:18:37     at Readable.push (node:internal/streams/readable:390:5)
2024-03-25 11:18:37     at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
2024-03-25 11:18:37   length: 120,
2024-03-25 11:18:37   severity: 'ERROR',
2024-03-25 11:18:37   code: '3F000',
2024-03-25 11:18:37   detail: undefined,
2024-03-25 11:18:37   hint: undefined,
2024-03-25 11:18:37   position: '14',
2024-03-25 11:18:37   internalPosition: undefined,
2024-03-25 11:18:37   internalQuery: undefined,
2024-03-25 11:18:37   where: undefined,
2024-03-25 11:18:37   schema: undefined,
2024-03-25 11:18:37   table: undefined,
2024-03-25 11:18:37   column: undefined,
2024-03-25 11:18:37   dataType: undefined,
2024-03-25 11:18:37   constraint: undefined,
2024-03-25 11:18:37   file: 'namespace.c',
2024-03-25 11:18:37   line: '500',
2024-03-25 11:18:37 ⚾ @curveball/a12n-server 0.25.4

I took a look in the code and in the Knex.js documentation and seems all is good. If I'm not wrong Knex uses a parameter 'searchPath' with 'knex' and 'public' by default for the schema selection.

There is 'public' schema in my postgres database, so I don't understand why the server fails when it tried to create the KnexMigrations table.

Did I forget something ?

Thank you for your help.

below the docker compose file

version: "3.9"

services:
  osdb:
    image: "postgres"
    ports:
      - 5432:5432
    volumes:
      - oauth_server_postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=osdb
      - POSTGRES_PASSWORD_FILE=/run/secrets/postgres_password
      - POSTGRES_USER_FILE=/run/secrets/postgres_user
    secrets:
      - postgres_user
      - postgres_password
    networks:
      - backend

  os:
    image: ghcr.io/curveball/a12n-server/a12nserver:main
    env_file: ./apps/oauth-server/.env.local
    networks:
      - frontend
      - backend
    depends_on:
      - osdb

volumes:
  oauth_server_postgres_data:
  maildata:

secrets:
  postgres_password:
    file: ./secrets/postgres_password
  postgres_user:
    file: ./secrets/postgres_user

networks:
  frontend:
  backend:

./apps/oauth-server/.env.local content

PORT=8531
KEEP_ALIVE_TIMEOUT_MS=
PUBLIC_URI="http://localhost:8531/"
DB_DRIVER=pg
DB_HOST=osdb
DB_PASSWORD=************
DB_USER=ospguser
DB_DATABASE=osdb
SMTP_URL=smtp://username:*****@****.example:9025
SMTP_EMAIL_FROM=noreply@*****.example
REGISTRATION_ENABLED=1
evert commented 2 months ago

Fixed with #495