diff --git a/README.md b/README.md index eaae4a9e..9ac74f32 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ To install all dependencies, run: ```bash yarn install # and optionally -yarn db:generate +yarn generate:db ``` Now, copy the example `.env` file and change all its options: diff --git a/package.json b/package.json index defc499d..93282ba4 100644 --- a/package.json +++ b/package.json @@ -15,12 +15,13 @@ "clean": "turbo clean", "start": "turbo start", "dev": "turbo dev", + "dev:frontend": "turbo dev --filter=frontend...", "lint": "turbo lint", "prettier": "turbo prettier --ui=stream", - "db:generate": "turbo @repo/db#db:generate", - "db:studio": "turbo @repo/db#db:studio", - "db:migrate": "turbo @repo/db#db:migrate", - "git:pull": "git pull && yarn install && yarn run db:generate", + "generate:db": "turbo generate:db", + "studio:db": "yarn workspace @repo/db studio:db", + "migrate:db": "yarn workspace api migrate:db", + "git:pull": "git pull && yarn install && yarn run generate:db", "ws": "yarn workspace" }, "devDependencies": { diff --git a/packages/db/docker-compose.yaml b/packages/db/docker-compose.yaml new file mode 100644 index 00000000..c1561876 --- /dev/null +++ b/packages/db/docker-compose.yaml @@ -0,0 +1,19 @@ +services: + postgres: + image: postgres:18 + environment: + - POSTGRES_PASSWORD=password + - POSTGRES_USER=website + - POSTGRES_DATABASE=database + ports: + - '5432:5432' + + wait-for-postgres: + image: postgres:18 + environment: + - POSTGRES_PASSWORD=password + - POSTGRES_USER=website + - POSTGRES_DATABASE=database + depends_on: + - postgres + command: sh -c "until pg_isready -h postgres -U $$POSTGRES_USER; do echo waiting for postgres; sleep 2; done;" diff --git a/packages/db/package.json b/packages/db/package.json index c65c20ea..660217ac 100644 --- a/packages/db/package.json +++ b/packages/db/package.json @@ -10,10 +10,12 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "scripts": { - "db:generate": "prisma generate", - "db:migrate": "prisma migrate deploy", - "db:studio": "prisma studio", - "db:pull": "prisma db pull", + "generate:db": "prisma generate", + "migrate:db": "prisma migrate deploy", + "studio:db": "prisma studio", + "pull:db": "prisma db pull", + "up": "docker compose up -d", + "wait": "docker compose up wait-for-postgres", "env:copy": "cp .env.example .env", "build": "tsc" }, diff --git a/turbo.json b/turbo.json index b5575d57..394a8cec 100644 --- a/turbo.json +++ b/turbo.json @@ -1,9 +1,9 @@ { - "$schema": "https://turbo.build/schema.json", - "ui": "tui", - "tasks": { + "$schema": "https://turbo.build/schema.json", + "ui": "tui", + "tasks": { "build": { - "dependsOn": ["db:generate", "^build"], + "dependsOn": ["generate:db", "^build"], "inputs": ["$TURBO_DEFAULT$", ".env*"], "outputs": [".next/**", "!.next/cache/**", "dist/**"] }, @@ -18,6 +18,18 @@ }, "dev": { "persistent": true, + "dependsOn": ["migrate:db"], + "cache": false + }, + "migrate:db": { + "dependsOn": ["wait"], + "cache": false + }, + "wait": { + "dependsOn": ["up"], + "cache": false + }, + "up": { "cache": false }, "lint": { @@ -26,10 +38,10 @@ "prettier": { "dependsOn": ["^prettier"] }, - "db:generate": { + "generate:db": { "cache": false }, - "db:studio": { + "studio:db": { "persistent": true, "cache": false }