1

我想创建一个开发人员离线空间来使用hasura开发我的数据库

我知道带有标签 cli-migrations 的容器的存在,但是命令:

hasura-cli 控制台

不适用于访问容器外部。

我对 docker-compose.yml 的配置是:

version: '3'
services:
  hasura:
    environment:
      - HASURA_GRAPHQL_DATABASE_URL=postgres://[some pass]:[some user]@db:5432/[some db]
      - HASURA_GRAPHQL_ENABLE_CONSOLE=false
    image: hasura/graphql-engine:v1.0.0-rc.1.cli-migrations
    container_name: hasura
    volumes:
      - ./hasura-migrations:/hasura-migrations
    networks:
      - hasura-db
    ports:
      - "8081:8080"
      - "8082:8081"
    restart: always
    command: hasura-cli console --console-port 8081 --no-browser
  db:
    environment:
      - POSTGRES_USER=[some user]
      - POSTGRES_PASSWORD=[some pass]
      - POSTGRES_DB=[some db]
    image: postgres:11.4-alpine
    container_name: db
    restart: always
    networks:
      - hasura-db

networks:
  hasura-db:

hasura graphql 项目中有针对此问题的Pull 请求,但未合并。

我现在正在为此拉取请求寻找解决方法。

4

1 回答 1

2

我找到了解决方法!

如果我在我的机器上安装hasura cli并使用

hasura 控制台 --console-port 8080 --endpoint http://127.0.0.1:8081

我可以连接到 hasura api 并在本地运行控制台。

这是我更新的 docker-compose.yml

version: '3'
services:
  hasura:
    environment:
      - HASURA_GRAPHQL_DATABASE_URL=postgres://[some pass]:[some user]@db:5432/[some db]
      - HASURA_GRAPHQL_ENABLE_CONSOLE=false
    image: hasura/graphql-engine:v1.0.0-rc.1.cli-migrations
    container_name: hasura
    volumes:
      - ./hasura-migrations:/hasura-migrations
    networks:
      - hasura-db
    ports:
      - "8081:8080"
    restart: always
  db:
    environment:
      - POSTGRES_USER=[some user]
      - POSTGRES_PASSWORD=[some pass]
      - POSTGRES_DB=[some db]
    image: postgres:11.4-alpine
    container_name: db
    restart: always
    networks:
      - hasura-db

networks:
  hasura-db:
于 2019-12-16T17:08:35.537 回答