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

Unable to get docker-compose working #640

Open mrcasablr opened 3 years ago

mrcasablr commented 3 years ago

Describe the bug Using the following docker-compose yaml prevents hbp from starting

version: "3.6"
services:
  postgres:
    image: postgres:13.3
    restart: always
    ports:
    - "5432:5432"
    volumes:
    - db_data:/var/lib/postgresql/data
    environment:
      POSTGRES_PASSWORD: pgpasswd
      POSTGRES_DB: postgres
  graphql-engine:
    image: "hasura/graphql-engine:v2.0.4"
    restart: always
    ports:
      - "8080:8080"
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:pgpasswd@postgres:5432/postgres
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
      HASURA_GRAPHQL_ADMIN_SECRET: secret
      HASURA_GRAPHQL_DEV_MODE: "true"
      HASURA_GRAPHQL_JWT_SECRET: >-
        {"type":"HS256", "key":
        "jhyu89jiuhyg7678hoijhuytf7ghjiasodibagsdga9dha8os7df97a6sdgh9asudgo7f7g8h1uuoyafsod8pgasipdg8aps9dhaiaisydg8agsd87gasd9oihasd87gas78d"}
      HASURA_GRAPHQL_UNAUTHORIZED_ROLE: public
    command:
    - graphql-engine
    - serve
    depends_on:
    - postgres
  hasura-backend-plus:
    image: "nhost/hasura-backend-plus:latest"
    container_name: hbp-dev-hbp
    depends_on:
    - graphql-engine
    - postgres
    restart: always
    ports:
    - "4000:4000"
    environment:
      HOST: 0.0.0.0
      PORT: 4000
      DATABASE_URL: postgres://postgres:pgpasswd@postgres:5432/postgres
      SERVER_URL: "http://localhost:4000"
      HASURA_ENDPOINT: "http://graphql-engine:8080/v1/graphql"
      HASURA_GRAPHQL_ADMIN_SECRET: secret
      JWT_KEY: >-
        jhyu89jiuhyg7678hoijhuytf7ghjiasodibagsdga9dha8os7df97a6sdgh9asudgo7f7g8h1uuoyafsod8pgasipdg8aps9dhai;sd
      JWT_ALGORITHM: HS256
      ALLOWED_REDIRECT_URLS: "http://localhost"
      JWT_CUSTOM_FIELDS: ""
      AUTO_ACTIVATE_NEW_USERS: "true"
      PROVIDER_SUCCESS_REDIRECT: "http://localhost:3001/success"
      PROVIDER_FAILURE_REDIRECT: "http://localhost:3001/failed"
      HIBP_ENABLED: "false"
      DEFAULT_ALLOWED_USER_ROLES: "user,me"
      ALLOWED_USER_ROLES: "user,me"
      REGISTRATION_CUSTOM_FIELDS: "display_name"
      COOKIE_SECURE: "false"
      COOKIE_SECRET: "somelongvalue"
      REDIRECT_URL_SUCCESS: "http://localhost:3000"
      REDIRECT_URL_ERROR: "http://localhost:3000/fail"
volumes:
  db_data:

Expected behavior docker logs show postgres and hasura containers working, Just the hbp fails to start.

Screenshots docker logs show -

yarn run v1.22.5
$ node -r ./dist/start.js
Applying migrations
(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
    at /app/node_modules/postgres-migrations/dist/migrate.js:63:27
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at async /app/node_modules/postgres-migrations/dist/with-lock.js:25:28
    at async Object.applyMigrations (/app/dist/shared/migrations.js:13:9)
    at async start (/app/dist/ts-start.js:29:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(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)
(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.
Done in 2.89s.

Desktop (please complete the following information): Fedora 34 docker-compose version 1.29.2, build 5becea4c Docker version 20.10.7, build f0df350

elitan commented 3 years ago

The auth schema must be in place for HBP to start. Either create it manually, or create a init script for the postgres container, or use the image: nhost/postgres:12-v0.0.5.

dgchrt commented 2 years ago

Couldn't HBP automatically create the auth schema if not found upon start?

dgchrt commented 2 years ago

If not, it would be nice to have the instructions on how to create necessary schemas/tables in the getting started guide, for those who can't use a different Postgres image.