Skip to content

Commit

Permalink
Setup Hasura locally
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesBochet committed Apr 12, 2023
1 parent c63b7df commit 93fb589
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 581 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.vscode/*
**/**/.env
.DS_Store
node_modules/**/**
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ docker-compose up --build --force-recreate

Once this is completed you should have:
- front available on: http://localhost:3001
- hasura available on: http://localhost:8080
- server available on: http://localhost:3000/health
- postgres: available on http://localhost:5432 that should contain `twenty` database

Expand Down
23 changes: 23 additions & 0 deletions front/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="/logo192.png" />

<link rel="manifest" href="/manifest.json" />
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">

<title>Twenty</title>
<script defer src="/static/js/bundle.js"></script></head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
</body>
</html>
36 changes: 30 additions & 6 deletions infra/dev/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,42 @@
version: "3.9"
services:
twenty:
twenty-front:
build:
context: ../..
dockerfile: ./infra/dev/twenty/Dockerfile
dockerfile: ./infra/dev/front/Dockerfile
ports:
- "3000:3000"
- "3001:3001"
- "6006:6006"
volumes:
- ../..:/app
- twenty_node_modules_root:/app/node_modules
- ../../front:/app/front
- twenty_node_modules_front:/app/front/node_modules
depends_on:
- postgres
twenty-hasura:
build: ./hasura
ports:
- "8080:8080"
- "9695:9695"
- "9693:9693"
volumes:
- ../../hasura:/hasura
depends_on:
- "postgres"
restart: always
environment:
HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/hasura
HASURA_GRAPHQL_PG_DATABASE_URL: postgres://postgres:postgrespassword@postgres:5432/twenty
HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
HASURA_GRAPHQL_DEV_MODE: "true"
HASURA_GRAPHQL_ENABLED_LOG_TYPES: startup, http-log, webhook-log, websocket-log, query-log
twenty-server:
build:
context: ../..
dockerfile: ./infra/dev/server/Dockerfile
ports:
- "3000:3000"
volumes:
- ../../front:/app/front
- twenty_node_modules_server:/app/server/node_modules
depends_on:
- postgres
Expand All @@ -25,6 +50,5 @@ services:
- "5432:5432"
volumes:
db_data:
twenty_node_modules_root:
twenty_node_modules_front:
twenty_node_modules_server:
8 changes: 4 additions & 4 deletions infra/dev/twenty/Dockerfile → infra/dev/front/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
FROM node:18-alpine as app
FROM node:18-alpine as front

RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh && \
apk add libc6-compat

WORKDIR /app
COPY ../.. .
WORKDIR /app/front
COPY ../../front .

RUN npm run install-dev
RUN npm install

CMD ["npm", "run", "start"]
9 changes: 9 additions & 0 deletions infra/dev/hasura/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
FROM hasura/graphql-engine:latest as api

RUN apt-get update
RUN apt-get install -y curl
RUN apt-get install -y socat
RUN apt-get install -y vim
RUN curl -L https://github.com/hasura/graphql-engine/raw/stable/cli/get.sh | bash

CMD ["sh", "-c", "graphql-engine serve"]
3 changes: 2 additions & 1 deletion infra/dev/postgres/init.sql
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
CREATE DATABASE twenty;
CREATE DATABASE twenty;
CREATE DATABASE hasura;
12 changes: 12 additions & 0 deletions infra/dev/server/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
FROM node:18-alpine as server

RUN apk update && apk upgrade && \
apk add --no-cache bash git openssh && \
apk add libc6-compat

WORKDIR /app/server
COPY ../../server .

RUN npm install

CMD ["npm", "run", "start"]
Loading

0 comments on commit 93fb589

Please sign in to comment.