为 hasura 容器和 运行 控制台进行迁移

Making migrations for hasura container and running console

我想让 开发人员离线 space 来使用 hasura

开发我的数据库

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

hasura-cli console

无法访问容器外部。

我的 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 request针对此问题,但未合并。

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

我找到了解决方法!

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

hasura console --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: