【发布时间】:2021-07-06 08:17:58
【问题描述】:
我有一个 ruby on rails 应用程序,我通过 docker-compose up 运行。我完全是 graphql 和 hasura 的菜鸟,我尝试了不同的方法来配置我的 docker,但我无法让它工作。
我的 docker-compose.yml:
version: '3.6'
services:
postgres:
image: postgis/postgis:latest
restart: always
ports:
- "5434:5432"
volumes:
- ./init.sql:/docker-entrypoint-initdb.d/init.sql
environment:
PG_HOST_AUTH_METHOD: "trust"
graphql-engine:
image: hasura/graphql-engine:v1.2.2.cli-migrations-v2
restart: always
ports:
- "8081:8080"
volumes:
- ./metadata:/hasura-metadata
environment:
HSR_GQL_DB_URL: "postgres://postgres@postgres/db-dev-name"
HSR_GQL_ADMIN_SECRET: secret
env_file:
- .env
server:
build: .
depends_on:
- "postgres"
command: bundle exec rails server -p 8081 -b 0.0.0.0
ports:
- "8080:8081"
volumes:
- ./:/server
- gem_cache:/usr/local/bundle/gems
- node_modules:/server/node_modules
env_file:
- .env
volumes:
gem_cache:
node_modules:
config.yml:
version: 2
endpoint: http://localhost:8080
metadata_directory: metadata
actions:
kind: synchronous
handler_webhook_baseurl: http://localhost:8080
Docker 日志服务器显示:
Listening on tcp://0.0.0.0:8081
我可以在 docker-compose up 后访问应用程序 http://localhost:8080/server/
检查数据库连接,它也可以在数据库管理器 GUI 中的端口 :5434 访问。
但是当我尝试执行hasura console --admin-secret secret 时,浏览器上的 hasura 控制台没有显示。我只是在不同的日志上收到此错误:
- 码头日志服务器:
Started POST "//v1/query" for 172.25.0.1 at 2021-04-10 17:53:08 +0000
ActionController::RoutingError (No route matches [POST] "/v1/query")
- docker 日志 postgresql:
17:27:33.453 UTC [1] LOG: starting PostgreSQL 13.2 (Debian 13.2-1.pgdg100+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit
17:27:33.453 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
17:27:33.453 UTC [1] LOG: listening on IPv6 address "::", port 5432
17:27:33.459 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
17:27:33.467 UTC [103] LOG: database system was shut down at 2021-04-10 17:27:33 UTC
17:27:33.473 UTC [1] LOG: database system is ready to accept connections
17:27:41.250 UTC [111] ERROR: duplicate key value violates unique constraint "pg_extension_name_index"
17:27:41.250 UTC [111] DETAIL: Key (extname)=(postgis) already exists.
17:27:41.250 UTC [111] STATEMENT: CREATE EXTENSION IF NOT EXISTS postgis
17:27:47.565 UTC [116] ERROR: duplicate key value violates unique constraint "pg_extension_name_index"
17:27:47.565 UTC [116] DETAIL: Key (extname)=(pgcrypto) already exists.
17:27:47.565 UTC [116] STATEMENT: CREATE EXTENSION IF NOT EXISTS "pgcrypto"
17:28:01.619 UTC [128] ERROR: duplicate key value violates unique constraint "acct_status_pkey"
17:28:01.619 UTC [128] DETAIL: Key (status)=(new) already exists.
17:28:01.619 UTC [128] STATEMENT: INSERT INTO "acct_status" ("status") VALUES ($1) RETURNING "status"
- docker logs graphql-engine:最后几行。
{"kind":"event_triggers","info":"preparing data"}}
{"type":"startup","timestamp":"2021-04-10T17:28:15.576+0000","level":"info","detail":{"kind":"event_triggers","info":"starting workers"}}
{"type":"startup","timestamp":"2021-04-10T17:28:15.576+0000","level":"info","detail":{"kind":"telemetry","info":"Help us improve Hasura! The graphql-engine server collects anonymized usage stats which allows us to keep improving Hasura at warp speed. To read more or opt-out, visit https://hasura.io/docs/1.0/graphql/manual/guides/telemetry.html"}}
{"type":"startup","timestamp":"2021-04-10T17:28:15.576+0000","level":"info","detail":{"kind":"server","info":{"time_taken":2.384872458,"message":"starting API server"}}}
我尝试通过浏览器访问 http://localhost:8081//console/api-explorer,似乎 graphql 容器正在获取请求,但仍然不会显示 hasura 控制台
{
"type": "http-log",
"timestamp": "2021-04-12T03:24:24.399+0000",
"level": "error",
"detail": {
"operation": {
"error": {
"path": "$",
"error": "resource does not exist",
"code": "not-found"
},
"request_id": "6d1e5f04-f7d4-48d6-932e-4cf81bdf9795",
"response_size": 65,
"raw_query": ""
},
"http_info": {
"status": 404,
"http_version": "HTTP/1.1",
"url": "/console/api-explorer",
"ip": "192.168.0.1",
"method": "GET",
"content_encoding": null
}
}
我尝试将 HSR_GQL_DB_URL 设置为 postgres / localhost:5432 以及 postgis:// 而不是 postgres://。 我也尝试将 config.yml 端点字段更改为 http://localhost:8080/server/ 但这些也不起作用。
【问题讨论】: