diff --git a/hasura/metadata/databases/databases.yaml b/hasura/metadata/databases/databases.yaml index 52ba870eb..264a9908f 100644 --- a/hasura/metadata/databases/databases.yaml +++ b/hasura/metadata/databases/databases.yaml @@ -1,4 +1,4 @@ -- name: twenty +- name: default kind: postgres configuration: connection_info: @@ -6,4 +6,4 @@ from_env: HASURA_GRAPHQL_PG_DATABASE_URL isolation_level: read-committed use_prepared_statements: false - tables: "!include twenty/tables/tables.yaml" + tables: "!include default/tables/tables.yaml" diff --git a/hasura/metadata/databases/twenty/tables/public_workspaces.yaml b/hasura/metadata/databases/default/tables/public_workspaces.yaml similarity index 100% rename from hasura/metadata/databases/twenty/tables/public_workspaces.yaml rename to hasura/metadata/databases/default/tables/public_workspaces.yaml diff --git a/hasura/metadata/databases/twenty/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml similarity index 100% rename from hasura/metadata/databases/twenty/tables/tables.yaml rename to hasura/metadata/databases/default/tables/tables.yaml diff --git a/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/down.sql b/hasura/migrations/default/1681407878182_create_table_public_workspaces/down.sql similarity index 100% rename from hasura/migrations/twenty/1681407878182_create_table_public_workspaces/down.sql rename to hasura/migrations/default/1681407878182_create_table_public_workspaces/down.sql diff --git a/hasura/migrations/twenty/1681407878182_create_table_public_workspaces/up.sql b/hasura/migrations/default/1681407878182_create_table_public_workspaces/up.sql similarity index 100% rename from hasura/migrations/twenty/1681407878182_create_table_public_workspaces/up.sql rename to hasura/migrations/default/1681407878182_create_table_public_workspaces/up.sql diff --git a/infra/dev/docker-compose.yml b/infra/dev/docker-compose.yml index 70ac45478..f6d8fe0fc 100644 --- a/infra/dev/docker-compose.yml +++ b/infra/dev/docker-compose.yml @@ -20,6 +20,7 @@ services: - "9693:9693" volumes: - ../../hasura:/hasura + - /hasura/entrypoints depends_on: - "postgres" restart: always @@ -29,6 +30,36 @@ services: HASURA_GRAPHQL_ENABLE_CONSOLE: "false" HASURA_GRAPHQL_DEV_MODE: "true" HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log + HASURA_GRAPHQL_ADMIN_SECRET: secret + HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256", "key": "jwt-very-long-hard-to-guess-secret"}' + hasura-auth: + image: nhost/hasura-auth:0.19.1 + ports: + - "4000:4000" + environment: + HASURA_GRAPHQL_JWT_SECRET: '{"type":"HS256", "key": "jwt-very-long-hard-to-guess-secret"}' + HASURA_GRAPHQL_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/twenty + HASURA_GRAPHQL_GRAPHQL_URL: http://twenty-hasura:8080/v1/graphql + HASURA_GRAPHQL_ADMIN_SECRET: secret + npm_package_version: '0' + AUTH_SMTP_HOST: mailhog + AUTH_SMTP_PORT: 1025 + depends_on: + - "twenty-hasura" + - "postgres" + - "mailhog" + mailhog: + image: jcalonso/mailhog + environment: + SMTP_HOST: mailhog + SMTP_PORT: 1025 + SMTP_PASS: smtp-secret + SMTP_USER: smtp-user + SMTP_SECURE: "false" + SMTP_SENDER: auth@localhost + ports: + - "1025:1025" + - "8025:8025" twenty-server: build: context: ../.. diff --git a/infra/dev/hasura/Dockerfile b/infra/dev/hasura/Dockerfile index bc86e41b7..d7523df67 100644 --- a/infra/dev/hasura/Dockerfile +++ b/infra/dev/hasura/Dockerfile @@ -8,4 +8,8 @@ RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bas WORKDIR /hasura -CMD ["sh", "-c", "graphql-engine serve"] +RUN mkdir entrypoints +COPY ./entrypoint.sh ./entrypoints/entrypoint.sh + +ENTRYPOINT ["entrypoints/entrypoint.sh"] + diff --git a/infra/dev/hasura/entrypoint.sh b/infra/dev/hasura/entrypoint.sh new file mode 100755 index 000000000..3b4503acd --- /dev/null +++ b/infra/dev/hasura/entrypoint.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +graphql-engine serve & + +while ! curl -s http://localhost:8080/healthz > /dev/null ; do + sleep 1 +done + +hasura deploy + +wait \ No newline at end of file diff --git a/infra/dev/postgres/Dockerfile b/infra/dev/postgres/Dockerfile index 0a2f10315..75ddc042d 100644 --- a/infra/dev/postgres/Dockerfile +++ b/infra/dev/postgres/Dockerfile @@ -1,3 +1,5 @@ FROM postgres:13.7 as postgres -COPY init.sql /docker-entrypoint-initdb.d/ \ No newline at end of file +RUN apt update && apt install -y curl + +COPY init.sql /docker-entrypoint-initdb.d/ diff --git a/infra/dev/postgres/init.sql b/infra/dev/postgres/init.sql index 30a091e62..b53c8220a 100644 --- a/infra/dev/postgres/init.sql +++ b/infra/dev/postgres/init.sql @@ -1,2 +1,17 @@ CREATE DATABASE twenty; -CREATE DATABASE hasura; \ No newline at end of file +CREATE DATABASE hasura; + +-- From: https://raw.githubusercontent.com/nhost/hasura-auth/main/docker/initdb.d/0001-create-schema.sql +\c twenty; +-- auth schema +CREATE SCHEMA IF NOT EXISTS auth; +-- https://github.com/hasura/graphql-engine/issues/3657 +CREATE EXTENSION IF NOT EXISTS pgcrypto WITH SCHEMA public; +CREATE EXTENSION IF NOT EXISTS citext WITH SCHEMA public; +CREATE OR REPLACE FUNCTION public.set_current_timestamp_updated_at() RETURNS trigger LANGUAGE plpgsql AS $$ +declare _new record; +begin _new := new; +_new."updated_at" = now(); +return _new; +end; +$$; \ No newline at end of file