chore: add pnpm workspace configuration for apps and packages
This commit is contained in:
20
.devcontainer/Dockerfile
Normal file
20
.devcontainer/Dockerfile
Normal file
@@ -0,0 +1,20 @@
|
||||
FROM mcr.microsoft.com/devcontainers/typescript-node:24
|
||||
|
||||
# Install additional tools
|
||||
RUN apt-get update && apt-get install -y \
|
||||
postgresql-client \
|
||||
redis-tools \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set up pnpm environment
|
||||
ENV PNPM_HOME=/home/node/.local/share/pnpm
|
||||
ENV PATH=$PNPM_HOME:$PATH
|
||||
|
||||
USER node
|
||||
|
||||
# Set working directory
|
||||
WORKDIR /workspace
|
||||
|
||||
# Install global packages
|
||||
RUN pnpm install -g @nestjs/cli@latest
|
||||
|
||||
52
.devcontainer/devcontainer.json
Normal file
52
.devcontainer/devcontainer.json
Normal file
@@ -0,0 +1,52 @@
|
||||
{
|
||||
"name": "DreamChat Development",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "app",
|
||||
"workspaceFolder": "/workspace",
|
||||
"features": {
|
||||
"ghcr.io/devcontainers/features/node:1": {
|
||||
"version": "24"
|
||||
},
|
||||
"ghcr.io/devcontainers/features/docker-in-docker:2": {
|
||||
"moby": false
|
||||
}
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"dbaeumer.vscode-eslint",
|
||||
"esbenp.prettier-vscode",
|
||||
"bradlc.vscode-tailwindcss",
|
||||
"ms-vscode.vscode-typescript-next",
|
||||
"nestjs.vscode-nestjs",
|
||||
"prisma.prisma"
|
||||
],
|
||||
"settings": {
|
||||
"editor.formatOnSave": true,
|
||||
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
||||
"typescript.preferences.importModuleSpecifier": "relative"
|
||||
}
|
||||
}
|
||||
},
|
||||
"forwardPorts": [3000, 5173, 5432],
|
||||
"portsAttributes": {
|
||||
"3000": {
|
||||
"label": "Backend API",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"5173": {
|
||||
"label": "Frontend Dev Server",
|
||||
"onAutoForward": "notify"
|
||||
},
|
||||
"5432": {
|
||||
"label": "PostgreSQL",
|
||||
"onAutoForward": "silent"
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/post-create.sh",
|
||||
"remoteUser": "node",
|
||||
"mounts": [
|
||||
"source=${localWorkspaceFolderBasename}-node_modules,target=${containerWorkspaceFolder}/node_modules,type=volume",
|
||||
"source=${localWorkspaceFolderBasename}-pnpm-store,target=/home/node/.local/share/pnpm/store,type=volume"
|
||||
]
|
||||
}
|
||||
47
.devcontainer/docker-compose.yml
Normal file
47
.devcontainer/docker-compose.yml
Normal file
@@ -0,0 +1,47 @@
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: .devcontainer/Dockerfile
|
||||
volumes:
|
||||
- ..:/workspace:cached
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
command: sleep infinity
|
||||
environment:
|
||||
- DATABASE_URL=postgresql://postgres:postgres@db:5432/dreamchat
|
||||
- REDIS_URL=redis://redis:6379
|
||||
# Keycloak is external - configure KEYCLOAK_URL in apps/backend/.env
|
||||
depends_on:
|
||||
- db
|
||||
- redis
|
||||
networks:
|
||||
- dreamchat-network
|
||||
|
||||
db:
|
||||
image: ankane/pgvector:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: dreamchat
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
ports:
|
||||
- "5432:5432"
|
||||
networks:
|
||||
- dreamchat-network
|
||||
|
||||
redis:
|
||||
image: redis:7-alpine
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "6379:6379"
|
||||
networks:
|
||||
- dreamchat-network
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
networks:
|
||||
dreamchat-network:
|
||||
driver: bridge
|
||||
76
.devcontainer/post-create.sh
Normal file
76
.devcontainer/post-create.sh
Normal file
@@ -0,0 +1,76 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
echo "🚀 Setting up DreamChat monorepo development environment..."
|
||||
|
||||
# Install all dependencies (uses pnpm workspaces)
|
||||
echo "📦 Installing dependencies..."
|
||||
cd /workspace
|
||||
pnpm install
|
||||
|
||||
# Build shared packages first
|
||||
echo "📦 Building shared packages..."
|
||||
pnpm --filter @dreamchat/shared build || echo "Shared package build skipped (may not exist yet)"
|
||||
|
||||
# Generate Prisma client
|
||||
echo "🔧 Generating Prisma client..."
|
||||
cd /workspace/apps/backend
|
||||
pnpm db:generate || echo "Prisma generate skipped (may not be set up yet)"
|
||||
cd -
|
||||
|
||||
# Copy environment files if they don't exist
|
||||
if [ ! -f /workspace/apps/backend/.env ]; then
|
||||
echo "⚙️ Creating backend .env file..."
|
||||
mkdir -p /workspace/apps/backend
|
||||
cat > /workspace/apps/backend/.env << EOF
|
||||
NODE_ENV=development
|
||||
PORT=3000
|
||||
DATABASE_URL=postgresql://postgres:postgres@db:5432/dreamchat
|
||||
JWT_SECRET=dev-jwt-secret-change-in-production
|
||||
JWT_EXPIRES_IN=1h
|
||||
JWT_REFRESH_EXPIRES_IN=7d
|
||||
LLM_PROVIDER=openrouter
|
||||
LLM_API_KEY=your-openrouter-api-key
|
||||
LLM_MODEL=openai/gpt-4o
|
||||
|
||||
# Keycloak (external) - configure if using external Keycloak
|
||||
KEYCLOAK_ENABLED=false
|
||||
# KEYCLOAK_URL=http://your-keycloak-server:8080
|
||||
# KEYCLOAK_REALM=dreamchat
|
||||
# KEYCLOAK_CLIENT_ID=dreamchat-backend
|
||||
# KEYCLOAK_CLIENT_SECRET=your_keycloak_secret
|
||||
|
||||
# Keycloak Authorization (optional)
|
||||
# KEYCLOAK_REQUIRED_GROUP=dreamchat-users
|
||||
# KEYCLOAK_REQUIRED_ROLE=dreamchat-access
|
||||
# KEYCLOAK_REQUIRED_CLIENT_ROLE=user
|
||||
# KEYCLOAK_REQUIRED_ATTRIBUTE=approved:true
|
||||
|
||||
# Keycloak Auto-Create Users
|
||||
KEYCLOAK_AUTO_CREATE_USER=true
|
||||
KEYCLOAK_DEFAULT_USER_ROLE=USER
|
||||
EOF
|
||||
fi
|
||||
|
||||
if [ ! -f /workspace/apps/frontend/.env ]; then
|
||||
echo "⚙️ Creating frontend .env file..."
|
||||
mkdir -p /workspace/apps/frontend
|
||||
cat > /workspace/apps/frontend/.env << EOF
|
||||
VITE_API_URL=http://localhost:3000/api
|
||||
VITE_WS_URL=ws://localhost:3000
|
||||
# Keycloak (external) - configure if using external Keycloak
|
||||
# VITE_KEYCLOAK_URL=http://your-keycloak-server:8080
|
||||
# VITE_KEYCLOAK_REALM=dreamchat
|
||||
# VITE_KEYCLOAK_CLIENT_ID=dreamchat-frontend
|
||||
EOF
|
||||
fi
|
||||
|
||||
echo "✅ Development environment setup complete!"
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo "1. Start all apps: pnpm dev"
|
||||
echo "2. Or start individually:"
|
||||
echo " - Backend: pnpm --filter @dreamchat/backend dev"
|
||||
echo " - Frontend: pnpm --filter @dreamchat/frontend dev"
|
||||
echo ""
|
||||
echo "Note: Keycloak is external. Configure KEYCLOAK_URL in apps/backend/.env if needed."
|
||||
Reference in New Issue
Block a user