Skip to content

Commit 02d8143

Browse files
KopymaticCopilot
andcommitted
better dev
Co-authored-by: Copilot <copilot@github.com>
1 parent 8e82f59 commit 02d8143

3 files changed

Lines changed: 49 additions & 5 deletions

File tree

compose.dev.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
services:
2+
db:
3+
image: postgres:17
4+
container_name: thevoid-db-dev
5+
restart: unless-stopped
6+
environment:
7+
POSTGRES_USER: postgres
8+
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
9+
POSTGRES_DB: ${POSTGRES_DB}
10+
volumes:
11+
- pgdata_dev:/var/lib/postgresql/data
12+
ports:
13+
- "5432:5432"
14+
healthcheck:
15+
test: ["CMD-SHELL", "pg_isready -U postgres"]
16+
interval: 10s
17+
timeout: 5s
18+
retries: 5
19+
start_period: 10s
20+
21+
volumes:
22+
pgdata_dev:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.10.5",
44
"type": "module",
55
"scripts": {
6-
"dev": "vite dev",
6+
"dev": "./startup-dev.sh",
77
"build": "vite build",
88
"preview": "vite preview",
99
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",

startup-dev.sh

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,28 @@
1-
#docker compose up db -d &&
1+
#!/bin/bash
22

3-
#bunx prisma migrate dev &&
4-
#bunx prisma generate &&
3+
set -e # this makes sure that if any command fails, the script exits
54

6-
GIT_COMMIT=$(git rev-parse --short HEAD) bun dev
5+
echo "Starting dev environment..."
6+
7+
# Load environment variables from .env.local, or defaults
8+
if [ -f .env.local ]; then
9+
echo "Loading .env.local..."
10+
export $(grep -v '^#' .env.local | xargs)
11+
elif [ -f .env ]; then
12+
echo "Loading .env..."
13+
export $(grep -v '^#' .env | xargs)
14+
else
15+
echo ".env.local not found. Using defaults..."
16+
fi
17+
18+
# Start database in background
19+
echo "Starting postgres..."
20+
docker compose -f compose.dev.yml up -d db
21+
22+
# Run prisma migrations
23+
echo "Running Prisma migrations..."
24+
bunx prisma migrate dev
25+
26+
# Start the dev server with HMR
27+
echo "Starting dev server..."
28+
GIT_COMMIT=$(git rev-parse --short HEAD) bunx vite dev

0 commit comments

Comments
 (0)