Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hasuraの環境を構築しました! #199

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .docker/hasura.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM hasura/graphql-engine:latest.cli-migrations-v3
WORKDIR /hasura
RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash
RUN apt install postgresql-client
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,11 @@ db:
docker compose run --rm seeds_api rails db:create
docker compose run --rm seeds_api rails db:migrate
docker compose run --rm seeds_api rails db:seed_fu

db-export:
docker compose up hasura -d
sleep 15
docker compose exec hasura hasura metadata export
docker compose exec hasura hasura migrate create "auto" --from-server --database-name default
docker compose exec hasura hasura migrate status --database-name default
docker compose down
37 changes: 37 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,21 @@ services:
volumes:
- mysql-data:/var/lib/mysql

seeds_hasura_db:
image: postgres:12
volumes:
- db-data:/var/lib/postgresql/data
environment:
POSTGRES_DB: myapp_development
POSTGRES_USER: seeds
POSTGRES_PASSWORD: password
POSTGRES_HOST_AUTH_METHOD: trust
healthcheck:
test: ["CMD-SHELL", "pg_isready"]
interval: 10s
timeout: 5s
retries: 5

seeds_api:
build: ./api
container_name: "seeds_api"
Expand All @@ -24,6 +39,27 @@ services:
stdin_open: true
tty: true

hasura:
build:
context: .docker
dockerfile: hasura.Dockerfile
container_name: "seeds_hasura"
ports:
- "8082:8080"
# restart: always
volumes:
- ./hasura:/hasura
environment:
HASURA_GRAPHQL_MIGRATIONS_DIR: /hasura/migrations
HASURA_GRAPHQL_METADATA_DIR: /hasura/metadata
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_DATABASE_URL: postgres://seeds:password@seeds_hasura_db:5432/myapp_development
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
depends_on:
seeds_hasura_db:
condition: service_healthy

seeds_view:
build: ./view
container_name: "seeds_view"
Expand Down Expand Up @@ -52,3 +88,4 @@ services:
volumes:
mysql-data:
driver: local
db-data:
6 changes: 6 additions & 0 deletions hasura/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 3
endpoint: http://hasura:8080
metadata_directory: metadata
actions:
kind: synchronous
handler_webhook_baseurl: http://localhost:3000
Empty file added hasura/metadata/actions.graphql
Empty file.
6 changes: 6 additions & 0 deletions hasura/metadata/actions.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
actions: []
custom_types:
enums: []
input_objects: []
objects: []
scalars: []
1 change: 1 addition & 0 deletions hasura/metadata/allow_list.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
1 change: 1 addition & 0 deletions hasura/metadata/api_limits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
1 change: 1 addition & 0 deletions hasura/metadata/backend_configs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dataconnector: {}
1 change: 1 addition & 0 deletions hasura/metadata/cron_triggers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
14 changes: 14 additions & 0 deletions hasura/metadata/databases/databases.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
- name: default
kind: postgres
configuration:
connection_info:
database_url:
from_env: HASURA_GRAPHQL_DATABASE_URL
isolation_level: read-committed
pool_settings:
connection_lifetime: 600
idle_timeout: 180
max_connections: 50
retries: 1
use_prepared_statements: true
tables: "!include default/tables/tables.yaml"
11 changes: 11 additions & 0 deletions hasura/metadata/databases/default/tables/public_bureaus.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
table:
name: bureaus
schema: public
array_relationships:
- name: user_details
using:
foreign_key_constraint_on:
column: bureau_id
table:
name: user_details
schema: public
11 changes: 11 additions & 0 deletions hasura/metadata/databases/default/tables/public_categories.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
table:
name: categories
schema: public
array_relationships:
- name: skills
using:
foreign_key_constraint_on:
column: category_id
table:
name: skills
schema: public
15 changes: 15 additions & 0 deletions hasura/metadata/databases/default/tables/public_chapters.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
table:
name: chapters
schema: public
object_relationships:
- name: curriculum
using:
foreign_key_constraint_on: curriculum_id
array_relationships:
- name: records
using:
foreign_key_constraint_on:
column: chapter_id
table:
name: records
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
table:
name: curriculum_skills
schema: public
object_relationships:
- name: curriculum
using:
foreign_key_constraint_on: curriculum_id
- name: skill
using:
foreign_key_constraint_on: skill_id
22 changes: 22 additions & 0 deletions hasura/metadata/databases/default/tables/public_curriculums.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
table:
name: curriculums
schema: public
object_relationships:
- name: skill
using:
foreign_key_constraint_on: skill_ids
array_relationships:
- name: chapters
using:
foreign_key_constraint_on:
column: curriculum_id
table:
name: chapters
schema: public
- name: curriculum_skills
using:
foreign_key_constraint_on:
column: curriculum_id
table:
name: curriculum_skills
schema: public
11 changes: 11 additions & 0 deletions hasura/metadata/databases/default/tables/public_departments.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
table:
name: departments
schema: public
array_relationships:
- name: user_details
using:
foreign_key_constraint_on:
column: department_id
table:
name: user_details
schema: public
11 changes: 11 additions & 0 deletions hasura/metadata/databases/default/tables/public_grades.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
table:
name: grades
schema: public
array_relationships:
- name: user_details
using:
foreign_key_constraint_on:
column: grade_id
table:
name: user_details
schema: public
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
table:
name: project_skills
schema: public
object_relationships:
- name: project
using:
foreign_key_constraint_on: project_id
- name: skill
using:
foreign_key_constraint_on: skill_id
13 changes: 13 additions & 0 deletions hasura/metadata/databases/default/tables/public_project_users.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
table:
name: project_users
schema: public
object_relationships:
- name: project
using:
foreign_key_constraint_on: project_id
- name: role
using:
foreign_key_constraint_on: role_id
- name: user
using:
foreign_key_constraint_on: user_id
18 changes: 18 additions & 0 deletions hasura/metadata/databases/default/tables/public_projects.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
table:
name: projects
schema: public
array_relationships:
- name: project_skills
using:
foreign_key_constraint_on:
column: project_id
table:
name: project_skills
schema: public
- name: project_users
using:
foreign_key_constraint_on:
column: project_id
table:
name: project_users
schema: public
18 changes: 18 additions & 0 deletions hasura/metadata/databases/default/tables/public_records.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
table:
name: records
schema: public
object_relationships:
- name: chapter
using:
foreign_key_constraint_on: chapter_id
- name: user
using:
foreign_key_constraint_on: user_id
array_relationships:
- name: teachers
using:
foreign_key_constraint_on:
column: record_id
table:
name: teachers
schema: public
11 changes: 11 additions & 0 deletions hasura/metadata/databases/default/tables/public_roles.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
table:
name: roles
schema: public
array_relationships:
- name: project_users
using:
foreign_key_constraint_on:
column: role_id
table:
name: project_users
schema: public
39 changes: 39 additions & 0 deletions hasura/metadata/databases/default/tables/public_skills.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
table:
name: skills
schema: public
object_relationships:
- name: category
using:
foreign_key_constraint_on: category_id
- name: type
using:
foreign_key_constraint_on: type_id
array_relationships:
- name: curriculum_skills
using:
foreign_key_constraint_on:
column: skill_id
table:
name: curriculum_skills
schema: public
- name: curriculums
using:
foreign_key_constraint_on:
column: skill_ids
table:
name: curriculums
schema: public
- name: project_skills
using:
foreign_key_constraint_on:
column: skill_id
table:
name: project_skills
schema: public
- name: user_skills
using:
foreign_key_constraint_on:
column: skill_id
table:
name: user_skills
schema: public
10 changes: 10 additions & 0 deletions hasura/metadata/databases/default/tables/public_teachers.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
table:
name: teachers
schema: public
object_relationships:
- name: record
using:
foreign_key_constraint_on: record_id
- name: user
using:
foreign_key_constraint_on: user_id
18 changes: 18 additions & 0 deletions hasura/metadata/databases/default/tables/public_types.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
table:
name: types
schema: public
array_relationships:
- name: skills
using:
foreign_key_constraint_on:
column: type_id
table:
name: skills
schema: public
- name: user_details
using:
foreign_key_constraint_on:
column: type_id
table:
name: user_details
schema: public
19 changes: 19 additions & 0 deletions hasura/metadata/databases/default/tables/public_user_details.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
table:
name: user_details
schema: public
object_relationships:
- name: bureau
using:
foreign_key_constraint_on: bureau_id
- name: department
using:
foreign_key_constraint_on: department_id
- name: grade
using:
foreign_key_constraint_on: grade_id
- name: type
using:
foreign_key_constraint_on: type_id
- name: user
using:
foreign_key_constraint_on: user_id
10 changes: 10 additions & 0 deletions hasura/metadata/databases/default/tables/public_user_skills.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
table:
name: user_skills
schema: public
object_relationships:
- name: skill
using:
foreign_key_constraint_on: skill_id
- name: user
using:
foreign_key_constraint_on: user_id
Loading