nhost / hasura-backend-plus

🔑Auth and 📦Storage for Hasura. The quickest way to get Auth and Storage working for your next app based on Hasura.
https://nhost.github.io/hasura-backend-plus/
MIT License
1.17k stars 187 forks source link

Problems getting started with v2.5.0(latest) #578

Closed migsar closed 3 years ago

migsar commented 3 years ago

I am trying to do a fresh install of HBP with auth but without storage. I've read about the problems in v2.5.0, here #529 and #542

Here is my docker-compose file:

version: '3.6'
services:
  postgres:
    image: postgres:12
    restart: always
    environment:
      POSTGRES_PASSWORD: postgrespassword
    volumes:
      - db_nhost_data:/var/lib/postgresql/data
  graphql-engine:
    image: hasura/graphql-engine:v1.2.1
    ports:
      - '8080:8080'
    depends_on:
      - 'postgres'
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
      HASURA_GRAPHQL_ADMIN_SECRET: 'aSecretPassword'
      HASURA_GRAPHQL_JWT_SECRET: '{"type": "RS256", "jwk_url": "http://hasura-backend-plus:5000/auth/jwks"}'
      HASURA_GRAPHQL_ENABLE_CONSOLE: 'true'
  hasura-backend-plus:
    image: nhost/hasura-backend-plus:latest
    ports:
      - '5000:3000'
    restart: always
    environment:
      SERVER_URL: http://localhost:5000
      HASURA_ENDPOINT: http://graphql-engine:8080/v1/graphql
      HASURA_GRAPHQL_ADMIN_SECRET: 'aSecretPassword'
      JWT_ALGORITHM: RS256
      DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/postgres
      STORAGE_ENABLE: 'false'
      # S3_ENDPOINT: http://minio:9000
      # S3_BUCKET: hasura-backend-plus
      # S3_ACCESS_KEY_ID: minio_access_key
      # S3_SECRET_ACCESS_KEY: '${S3_SECRET_ACCESS_KEY:?S3_SECRET_ACCESS_KEY}'
  # minio:
  #   image: minio/minio
  #   restart: always
  #   environment:
  #     S3_BUCKET: hasura-backend-plus
  #     MINIO_ACCESS_KEY: minio_access_key
  #     MINIO_SECRET_KEY: '${S3_SECRET_ACCESS_KEY:?S3_SECRET_ACCESS_KEY}' ## min 8 character
  #   entrypoint: sh
  #   command: "-c 'mkdir -p /export/hasura-backend-plus && /usr/bin/minio server /export'"
  #   volumes:
  #     - 'minio_data:/data'
volumes:
  db_nhost_data:
  # minio_data:

And the db error I am getting:

hasura-backend-plus_1  | Applying migrations
postgres_1             | 2021-06-08 07:14:37.571 UTC [33] ERROR:  no schema has been selected to create in at character 28
postgres_1             | 2021-06-08 07:14:37.571 UTC [33] STATEMENT:  CREATE TABLE IF NOT EXISTS migrations (
postgres_1             |      id integer PRIMARY KEY,
postgres_1             |      name varchar(100) UNIQUE NOT NULL,
postgres_1             |      hash varchar(40) NOT NULL, -- sha1 hex encoded hash of the file name and contents, to ensure it hasn't been altered since applying the migration
postgres_1             |      executed_at timestamp DEFAULT current_timestamp
postgres_1             |    );
postgres_1             |    
hasura-backend-plus_1  | (node:29) UnhandledPromiseRejectionWarning: Error: Migration failed. Reason: An error occurred running 'create-migrations-table'. Rolled back this migration. No further migrations were run. Reason: no schema has been selected to create in
hasura-backend-plus_1  |     at /app/node_modules/postgres-migrations/dist/migrate.js:63:27
hasura-backend-plus_1  |     at processTicksAndRejections (internal/process/task_queues.js:95:5)
hasura-backend-plus_1  |     at async /app/node_modules/postgres-migrations/dist/with-lock.js:25:28
hasura-backend-plus_1  |     at async Object.applyMigrations (/app/dist/shared/migrations.js:13:9)
hasura-backend-plus_1  |     at async start (/app/dist/ts-start.js:7:5)
hasura-backend-plus_1  | (Use `node --trace-warnings ...` to show where the warning was created)
hasura-backend-plus_1  | (node:29) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
hasura-backend-plus_1  | (node:29) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
hasura-backend-plus_1  | Done in 2.49s.
server_graphql-engine_1 exited with code 1

Any help is appreciated.

elitan commented 3 years ago

Could you try change toimage: nhost/hasura-backend-plus:v2.5.2 to make sure you're using the latest release?

The 2.5.2 release includes this (https://github.com/nhost/hasura-backend-plus/pull/553) PR which should solve your migration issue.

I would also recommend you to change the Postgres image to: nhost/postgres:12-v0.0.3 which will be the default Postgres image we'll recommend in the future.

Before you reload your docker image make sure to remove db_nhost_data so you start 100% from scratch.

migsar commented 3 years ago

Thanks for the quick reply! It worked like a charm!

I think it is related, so I post it here but feel free to point me to the right place if it is not.

Why the default Postgres image recommended have to be different from the official postgres one? Just curious for the sake of learning, I don't have a strong personal preference although I think in terms of my laptop with limited disk space it would be better to just have one docker image, not a big problem anyway.

I really appreciate the effort for keeping this open source and I know it is a huge effort, so after seeing that the documentation is a bit outdated on the postgres migrations I would like to ask if I can collaborate on that or it is already being taken care of?

Thanks! :)

elitan commented 3 years ago

Why the default Postgres image recommended have to be different from the official postgres one?

  1. We create some default schemas + add some SQL functions.

https://github.com/nhost/postgres/blob/main/v12/db/0001-create-schema.sql#L1-L22

  1. We install extensions (ex Postgis):

https://github.com/nhost/postgres/blob/main/v12/Dockerfile#L3-L11

dgchrt commented 2 years ago
  1. We create some default schemas + add some SQL functions.
  2. We install extensions (ex Postgis):

Will these customizations make future versions of HB+ incompatible with the default Postgres images and/or hosted Postgres offerings?