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

Help with docker-compose and hasura-backend-plus #611

Closed mrcasablr closed 3 years ago

mrcasablr commented 3 years ago

I have the following docker-compose file

version: '3.6'
services:
  graphql-engine:
    image: hasura/graphql-engine:v2.0.1
    restart: always
    network_mode: "host"
    environment:
      HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgres@127.0.0.1:5432/postgres
      HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET}
      HASURA_GRAPHQL_JWT_SECRET: '{"type": "RS256", "jwk_url": "http://localhost:3000/auth/jwks"}'
      HASURA_GRAPHQL_ENABLED_CONSOLE: 'true'
  hasura-backend-plus:
    image: nhost/hasura-backend-plus:v2.6.1
    ports:
      - '3000:3000'
    restart: always
    volumes:
      - ./custom:/app/custom
    environment:
      SERVER_URL: http://localhost:3000
      HASURA_ENDPOINT: http://localhost:8080/v1/graphql
      HASURA_GRAPHQL_ADMIN_SECRET: ${HASURA_GRAPHQL_ADMIN_SECRET}
      JWT_ALGORITHM: RS256

and I see the following in the docker logs

ocumentation about this command.
yarn run v1.22.5
$ node -r ./dist/start.js
internal/fs/utils.js:314
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/app/custom/keys/private.pem'
    at Object.openSync (fs.js:498:3)
    at Object.writeFileSync (fs.js:1524:35)
    at Object.<anonymous> (/app/dist/shared/jwt.js:36:26)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/app/dist/routes/auth/jwks.js:4:15)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:92:18) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/app/custom/keys/private.pem'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
michaelschort commented 3 years ago

create a private.pem file in your connected Folder /custom/keys/

./custom is a relative path to your docker-compose

If something like Portainer is used for management it's easier to just Point to a /custom Folder somewhere else.

also HASURA_ENDPOINT: http://localhost:8080/v1/graphql will not work as 'localhost' in this context is the HBP-Container itself. To connect to the Hasura Container change to : HASURA_ENDPOINT: http://graphql-engine:8080/v1/graphql