Comments (11)
For anyone else who has the same question as @mnlbox, I found a fairly easy way to achieve this.
- Clone the https://github.com/hasura/3factor-example repository
- Add
docker-compose.yaml
to the repository root (see code below) - Run
docker-compose up -d
- Run
docker exec -i 3factor_postgres psql -U postgres postgres < schema.sql
docker-compose.yaml
:
version: '3.7'
services:
postgres:
image: "postgres:11.5"
container_name: "3factor_postgres"
ports:
- "5432:5432"
restart: always
volumes:
- db_data:/var/lib/postgresql/data
graphql-engine:
image: hasura/graphql-engine:v1.0.0-beta.4
container_name: "3factor_hasura"
ports:
- "8080:8080"
depends_on:
- "postgres"
restart: always
environment:
HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:@postgres:5432/postgres
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
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:
With Hasura and Postgres running via this docker-compose.yaml
configuration, when you want to run the Express server as part of https://github.com/jordanmkoncz/3factor-example#step-3-local-development (node localDevelopment.js
), in your terminal you should first run:
export POSTGRES_CONNECTION_STRING='postgres://postgres:@localhost:5432/postgres'
Side note: if you decide to run the 3factor-example project like this, you will probably run into an issue where the event triggers fail. In the event response, I was seeing an error of ConnectionFailure Network.Socket.connect: <socket: 27>: does not exist (Connection refused)
. This happens because the webhooks are pointing to localhost
, e.g. http://localhost:8081/validate-order
, and Hasura which is running from the Docker container is not able to connect to the Express server (node localDevelopment.js
) running directly on localhost (not in Docker).
The solution is to modify the event triggers so that Hasura within the Docker container can connect to the Express server on localhost, which is discussed in https://docs.hasura.io/1.0/graphql/manual/deployment/docker/index.html#network-config. On macOS, the event trigger would be updated by replacing localhost
with host.docker.internal
, and on Windows replacing it with docker.for.win.localhost
, e.g. the new event trigger would point to http://host.docker.internal:8081/validate-order
. You'll need to make this change for all event triggers.
from 3factor-example.
Hey @mnlbox
Do you have access to your Postgres db?
from 3factor-example.
@tirumaraiselvan I run my Hasura instance with this guide:
https://docs.hasura.io/1.0/graphql/manual/getting-started/docker-simple.html
How we can access to this Postgres? 🤔
from 3factor-example.
@mnlbox Ah! Seems like the Postgres container is not exposed to localhost in docker-compose manifest. We will fix it.
In the meanwhile, you can go to Hasura console -> Data tab -> Run SQL and copy paste the contents of schema.sql there. And execute.
from 3factor-example.
@tirumaraiselvan Thanks man.
Maybe related: hasura/graphql-engine#1424
from 3factor-example.
from 3factor-example.
Thanks @tirumaraiselvan I think expose Postgres and pgAdmin to local can be useful for this purpose 😉
Your temp solution (run SQL in Hasura console working well).
from 3factor-example.
Resolved
from 3factor-example.
@tirumaraiselvan Can you guide a little?
from 3factor-example.
@mnlbox You can use pgadmin like here: https://github.com/hasura/graphql-engine/blob/master/install-manifests/docker-compose-pgadmin/docker-compose.yaml
Or you can use network: host
in your docker-compose.yaml and connect to psql directly on port 5432
from 3factor-example.
I've made a fork that includes all of the above changes (and some other fixes for this project) and submitted a pull request at #17. Feel free to use this fork if you'd prefer to use a docker-compose.yaml
configuration and to run both Hasura and Postgres via Docker.
from 3factor-example.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from 3factor-example.