mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-23 03:51:36 +03:00
Simplify local dev (#137)
This commit is contained in:
parent
80f9cc8797
commit
34543b7fea
@ -1,16 +1,10 @@
|
||||
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
|
||||
// README at: https://github.com/devcontainers/templates/tree/main/src/docker-in-docker
|
||||
{
|
||||
"name": "Twenty",
|
||||
"image": "mcr.microsoft.com/devcontainers/base:bullseye",
|
||||
|
||||
{
|
||||
"name": "Twenty Codespace",
|
||||
"image": "node:18.16.0",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {
|
||||
"version": "20.10",
|
||||
"enableNonRootDocker": "true",
|
||||
"moby": "true"
|
||||
}
|
||||
"ghcr.io/devcontainers-contrib/features/jshint:2": {}
|
||||
},
|
||||
"postCreateCommand": ".devcontainer/init.sh",
|
||||
"postStartCommand": ".vscode/up.sh"
|
||||
}
|
||||
"forwardPorts": [3000, 3001, 5432],
|
||||
"postCreateCommand": "cd front && npm install && cd ../server && npm install"
|
||||
}
|
@ -2,5 +2,6 @@
|
||||
|
||||
DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y postgresql-client
|
||||
cd infra/dev
|
||||
make build
|
||||
make up
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,2 @@
|
||||
**/**/.env
|
||||
**/**/.npmrc
|
||||
.DS_Store
|
||||
node_modules
|
8
.vscode/clean.sh
vendored
8
.vscode/clean.sh
vendored
@ -1,8 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$(dirname "$0")/../infra/dev"
|
||||
|
||||
docker-compose down
|
||||
docker volume rm dev_twenty_node_modules_front
|
||||
docker volume rm dev_twenty_node_modules_server
|
||||
docker volume rm dev_twenty_node_modules_docs
|
5
.vscode/logs.sh
vendored
5
.vscode/logs.sh
vendored
@ -1,5 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$(dirname "$0")/../infra/dev"
|
||||
|
||||
docker-compose logs -f
|
48
.vscode/tasks.json
vendored
48
.vscode/tasks.json
vendored
@ -1,48 +0,0 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "up",
|
||||
"command": "${workspaceFolder}/.vscode/up.sh",
|
||||
"type": "shell",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/infra/dev/"
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"focus": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "clean",
|
||||
"command": "${workspaceFolder}/.vscode/clean.sh",
|
||||
"type": "shell",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/infra/dev/"
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"focus": true
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "logs",
|
||||
"command": "docker-compose",
|
||||
"args": [
|
||||
"logs",
|
||||
"-f"
|
||||
],
|
||||
"type": "shell",
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}/infra/dev/"
|
||||
},
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
"panel": "new",
|
||||
"focus": true
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
18
.vscode/up.sh
vendored
18
.vscode/up.sh
vendored
@ -1,18 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd "$(dirname "$0")/../infra/dev"
|
||||
|
||||
cp .env.example .env
|
||||
|
||||
set -o allexport; source .env; set +o allexport
|
||||
|
||||
docker-compose up -d postgres
|
||||
|
||||
while ! pg_isready -h localhost > /dev/null ; do
|
||||
echo "Waiting for Postgres to be ready..."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
echo "Postgres is accepting connections!"
|
||||
|
||||
docker-compose up -d
|
@ -15,7 +15,7 @@ Twenty development stack is composed of 3 different layers
|
||||
- server: our backend that contain endpoint, crm logic, scripts, jobs...
|
||||
- storages: postgres
|
||||
|
||||
## Setup env variables and npmrc variables
|
||||
## Setup env variables
|
||||
|
||||
`cp ./infra/dev/.env.example ./infra/dev/.env` and fill with values
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
||||
"build-storybook": "storybook build -s public",
|
||||
"coverage": "react-scripts test --coverage --watchAll",
|
||||
"coverage-ci": "react-scripts test --coverage --watchAll=false",
|
||||
"graphql-codegen": "REACT_APP_GRAPHQL_ADMIN_SECRET=$REACT_APP_GRAPHQL_ADMIN_SECRET graphql-codegen --config codegen.js"
|
||||
"graphql:generate": "REACT_APP_GRAPHQL_ADMIN_SECRET=$REACT_APP_GRAPHQL_ADMIN_SECRET graphql-codegen --config codegen.js"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"extends": [
|
||||
|
@ -1,32 +1,39 @@
|
||||
build: ##
|
||||
build:
|
||||
@docker-compose down
|
||||
docker volume rm dev_twenty_node_modules_front || true
|
||||
docker volume rm dev_twenty_node_modules_server || true
|
||||
docker volume rm dev_twenty_node_modules_docs || true
|
||||
docker-compose build
|
||||
@docker volume rm dev_twenty_node_modules_front > /dev/null 2>&1 || true
|
||||
@docker volume rm dev_twenty_node_modules_server > /dev/null 2>&1 || true
|
||||
@docker volume rm dev_twenty_node_modules_docs > /dev/null 2>&1 || true
|
||||
@docker-compose build
|
||||
|
||||
up: ##
|
||||
up:
|
||||
@docker-compose up -d
|
||||
|
||||
down: ##
|
||||
down:
|
||||
@docker-compose down
|
||||
|
||||
## Front
|
||||
sh:
|
||||
@docker-compose exec twenty-dev sh
|
||||
|
||||
front-logs: ##
|
||||
@docker-compose logs twenty-front -f
|
||||
front-start:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/front && npm run start"
|
||||
|
||||
front-sh: ##
|
||||
@docker-compose exec twenty-front sh
|
||||
front-test:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/front && npm run test"
|
||||
|
||||
front-test: ##
|
||||
@docker-compose exec twenty-front sh -c "npm run test"
|
||||
front-graphql-generate:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/server && npm run "
|
||||
|
||||
front-coverage: ##
|
||||
@docker-compose exec twenty-front sh -c "npm run coverage"
|
||||
front-storybook:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/front && npm run storybook"
|
||||
|
||||
front-storybook: ##
|
||||
@docker-compose exec twenty-front sh -c "npm run storybook"
|
||||
server-start:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/server && npm run start"
|
||||
|
||||
front-graphql-generate: ##
|
||||
@docker-compose exec twenty-front sh -c "npm run graphql-generate"
|
||||
server-prisma-generate:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/server && npm run prisma:generate"
|
||||
|
||||
server-prisma-migrate:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/server && npm run prisma:migrate"
|
||||
|
||||
server-prisma-seed:
|
||||
@docker-compose exec twenty-dev sh -c "cd /app/server && npm run prisma:seed"
|
||||
|
@ -1,32 +1,24 @@
|
||||
version: "3.9"
|
||||
services:
|
||||
twenty-front:
|
||||
twenty-dev:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: ./infra/dev/front/Dockerfile
|
||||
dockerfile: ./infra/dev/twenty-dev/Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
- "3001:3001"
|
||||
- "6006:6006"
|
||||
volumes:
|
||||
- ../../front:/app/front
|
||||
- twenty_node_modules_front:/app/front/node_modules
|
||||
depends_on:
|
||||
- postgres
|
||||
twenty-server:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: ./infra/dev/server/Dockerfile
|
||||
ports:
|
||||
- "3000:3000"
|
||||
volumes:
|
||||
- ../../server:/app/server
|
||||
- twenty_node_modules_front:/app/front/node_modules
|
||||
- twenty_node_modules_server:/app/server/node_modules
|
||||
depends_on:
|
||||
- postgres
|
||||
twenty-docs:
|
||||
build:
|
||||
context: ../..
|
||||
dockerfile: ./infra/dev/docs/Dockerfile
|
||||
dockerfile: ./infra/dev/twenty-docs/Dockerfile
|
||||
ports:
|
||||
- "5001:3000"
|
||||
volumes:
|
||||
|
@ -1,19 +0,0 @@
|
||||
FROM node:18.16.0-alpine as server
|
||||
|
||||
RUN apk update && apk upgrade && \
|
||||
apk add --no-cache bash git openssh && \
|
||||
apk add libc6-compat
|
||||
|
||||
WORKDIR /app/server
|
||||
|
||||
COPY ../../server/package.json .
|
||||
COPY ../../server/package-lock.json .
|
||||
RUN npm install
|
||||
|
||||
COPY ../../server/src/database/schema.prisma ./src/database/schema.prisma
|
||||
RUN npx prisma generate
|
||||
|
||||
COPY ../../server .
|
||||
|
||||
|
||||
CMD ["npm", "run", "start:dev"]
|
@ -15,4 +15,15 @@ RUN npm install
|
||||
|
||||
COPY ../../front .
|
||||
|
||||
CMD ["npm", "run", "start"]
|
||||
WORKDIR /app/server
|
||||
|
||||
COPY ../../server/package.json .
|
||||
COPY ../../server/package-lock.json .
|
||||
RUN npm install
|
||||
|
||||
COPY ../../server .
|
||||
RUN npx prisma generate
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
CMD ["tail", "-f", "/dev/null"]
|
@ -20,7 +20,8 @@
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json",
|
||||
"prisma:generate": "npx prisma generate",
|
||||
"prisma:migrate": "npx prisma migrate deploy"
|
||||
"prisma:migrate": "npx prisma migrate deploy",
|
||||
"prisma:seed": "npx prisma db seed"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/apollo": "^10.0.5",
|
||||
|
@ -1,18 +0,0 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "front"
|
||||
},
|
||||
{
|
||||
"path": "server"
|
||||
},
|
||||
{
|
||||
"path": "docs"
|
||||
},
|
||||
{
|
||||
"path": ".",
|
||||
"name": "root"
|
||||
|
||||
}
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user