-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Description
I have two repos that I intend to run locally on my machine with Docker. This is on the latest Docker on the latest MacOS Catalina.
Repo 1
The first one works fine, since I just use the standard docker-compose.yaml:
docker-compose.yaml - 1
version: '3.6'
services:
postgres:
image: postgres:12.1
restart: always
volumes:
- db_data:/var/lib/postgresql/data
graphql-engine:
image: hasura/graphql-engine:v1.2.1
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "false" # set to "false" to disable console
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
volumes:
db_data:
I also access the console with hasura console.
This repo runs normally as it should.
Repo 2
Obviously if I copied the exact same docker-compose.yaml from Repo 1, it won't work.
I've looked at a few other sources online to help get this work, e.g.:
I currently cannot get it to work whatsoever. Sometimes if I use a postgres port of 5442:5442 it won't work and the server keeps on restarting in Docker Dashboard. Also if I tried to manually point the Hasura server's database url to port 5442, it would complain that:
// In docker-compose.yaml
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5442/postgres
// Error in Docker Dashboard. Server keeps on restarting
graphql-engine_1 | {"type":"startup","timestamp":"2020-06-04T02:35:43.569+0000","level":"error","detail":{"kind":"db_migrate","info":{"internal":"could not connect to server: Connection refused\n\tIs the server running on host \"postgres\" (172.29.0.2) and accepting\n\tTCP/IP connections on port 5442?\n","path":"$","error":"connection error","code":"postgres-error"}}}
So I changed 5442 in the docker-compose.yaml back to 5432.
So far this is my current attempt at making it work:
docker-compose.yaml - 2
version: '3.6'
services:
postgres:
image: postgres:12.3
restart: always
volumes:
- db_data:/var/lib/postgresql/data
ports:
- "5442:5432"
environment:
POSTGRES_HOST_AUTH_METHOD: trust
graphql-engine:
image: hasura/graphql-engine:v1.2.2
ports:
- "8090:8090"
depends_on:
- "postgres"
restart: always
environment:
HASURA_GRAPHQL_SERVER_PORT: 8090
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "false" # set to "false" to disable console so we can do migrations
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
## uncomment next line to set an admin secret
# Not needed for development since this will just slow us down
# HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
volumes:
db_data:
Neither the graphql nor the postgres server keep on restarting, so that's a good sign. However, if I try to access the console with hasura console --console-port 9696 --endpoint http://host.docker.internal:8090 I get this error:
Running the local Hasura instance for Datbase Items on Docker (localhost:8090)
FATA[0001] version check: failed to get version from server: failed making version api call: Get http://host.docker.internal:8090/v1/version: dial tcp: lookup host.docker.internal on 10.0.0.138:53: no such host
Has anyone managed to run 2 different hasura projects/repos at the same time on their machine locally? And if so, what docker-compose.yaml do you have for the second one?