Skip to content

Commit

Permalink
feat: Automaticaly run db as dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Untel committed Dec 31, 2022
1 parent 14d358a commit fea7188
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
9 changes: 8 additions & 1 deletion packages/database/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings

DATABASE_URL="postgresql://postgres:[email protected]:5432/postgres?schema=public"
# Database connection variable
DATABASE_HOST=127.0.0.1:5432
DATABASE_USER=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=postgres

# Used by prisma to establish de database connection
DATABASE_URL="postgresql://${DATABASE_USER}:${DATABASE_PASSWORD}@${DATABASE_HOST}/${DATABASE_NAME}?schema=public"
15 changes: 15 additions & 0 deletions packages/database/compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
version: "3"
services:
database:
container_name: kubestack_database
image: postgres
ports:
- 5432:5432
environment:
POSTGRES_USER: ${DATABASE_USER}
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_DB: ${DATABASE_NAME}
volumes: ["database:/var/lib/postgresql/data"]

volumes:
database:
1 change: 1 addition & 0 deletions packages/database/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@kubessandra/database",
"scripts": {
"db:dev": "docker compose up --build -d",
"db:generate": "prisma generate",
"db:migrate": "prisma migrate dev",
"db:studio": "prisma studio"
Expand Down
5 changes: 4 additions & 1 deletion turbo.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"outputs": [".next/**"]
},
"dev": {
"dependsOn": ["^db:generate"],
"dependsOn": ["^db:dev", "^db:generate"],
"cache": false
},
"test": {
Expand All @@ -24,6 +24,9 @@
"lint-fix": {
"outputs": []
},
"db:dev": {
"cache": false
},
"db:generate": {
"cache": false
},
Expand Down

0 comments on commit fea7188

Please sign in to comment.