我试图在Docker Compose中分离hasura的数据库。我的想法是有一个hasura的元数据数据库。还有一个是我的实际数据。这是我的docker-compose.yml文件。
version: "3.8"
services:
meta:
image: postgres
hostname: meta
container_name: meta
environment:
POSTGRES_DB: meta
POSTGRES_USER: meta
POSTGRES_PASSWORD: metapass
restart: always
volumes:
- db_meta:/var/lib/postgresql/data
networks:
- backend
data:
image: postgres
hostname: data
container_name: data
environment:
POSTGRES_DB: data
POSTGRES_USER: data
POSTGRES_PASSWORD: datapass
restart: always
volumes:
- db_data:/var/lib/postgresql/data
networks:
- backend
graphql-engine:
image: hasura/graphql-engine:v2.13.0
ports:
- "8080:8080"
depends_on:
- "meta"
- "data"
restart: always
environment:
## postgres database to store Hasura metadata
# Database URL postgresql://username:password@hostname:5432/database
HASURA_GRAPHQL_METADATA_DATABASE_URL: meta://meta:metapass@meta:5432/meta
## this env var can be used to add the above postgres database to Hasura as a data source. this can be removed/updated based on your needs
PG_DATABASE_URL: data://data:datapass@data:5432/data
## enable the console served by server
HASURA_GRAPHQL_ENABLE_CONSOLE: "true" # set to "false" to disable console
## enable debugging mode. It is recommended to disable this in production
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to run console offline (i.e load console assets from server instead of CDN)
# HASURA_GRAPHQL_CONSOLE_ASSETS_DIR: /srv/console-assets
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
networks:
- backend
volumes:
db_data:
db_meta:
networks:
backend:
driver: bridge
我得到{"detail":{"info":{"code":"postgres-error","error":"connection error","internal":"missing \"=\" after \"meta://meta:metapass@meta:5432/meta\" in connection info string\n","path":"$"},"kind":"catalog_migrate"},"level":"error","timestamp":"2022-10-24T14:16:06.432+0000","type":"startup"}
我想这个问题和主机名有关。但是我不知道怎么解决。有什么办法吗?
1条答案
按热度按时间xdyibdwo1#
我已经尝试了很多,所以现在我的解决方案看起来是这样的。我注意到volumes delete使它更容易开发。数据库URL的开头必须以
postgresql://
开头。正如@landercy已经说过的那样。