76 lines
2.0 KiB
PowerShell
76 lines
2.0 KiB
PowerShell
# PowerShell script to install and run Cal.com with Docker
|
|
# Save as: start-calcom.ps1
|
|
|
|
$folder = "C:\Users\johnn\Desktop\Docker\calcom-app"
|
|
$composeFile = "$folder\docker-compose.yml"
|
|
|
|
# Create project directory if it doesn't exist
|
|
if (-Not (Test-Path $folder)) {
|
|
New-Item -ItemType Directory -Path $folder | Out-Null
|
|
}
|
|
|
|
# Generate secure random strings for secrets
|
|
function Generate-Secret($length) {
|
|
return -join ((33..126) | Get-Random -Count $length | ForEach-Object {[char]$_})
|
|
}
|
|
|
|
$NEXTAUTH_SECRET = Generate-Secret 32
|
|
$ENCRYPTION_KEY = Generate-Secret 32
|
|
|
|
# Write Docker Compose file with both DATABASE_URL and DATABASE_DIRECT_URL
|
|
@"
|
|
version: '3.9'
|
|
|
|
services:
|
|
calcom:
|
|
image: calcom/cal.com:latest
|
|
ports:
|
|
- "3000:3000"
|
|
environment:
|
|
DATABASE_URL: postgresql://caluser:calpass@db:5432/caldb
|
|
DATABASE_DIRECT_URL: postgresql://caluser:calpass@db:5432/caldb # Fix: Added DATABASE_DIRECT_URL
|
|
NEXTAUTH_SECRET: $NEXTAUTH_SECRET
|
|
NEXT_PUBLIC_APP_URL: http://localhost:3000
|
|
CALENDSO_ENCRYPTION_KEY: $ENCRYPTION_KEY
|
|
NODE_ENV: production
|
|
depends_on:
|
|
- db
|
|
|
|
db:
|
|
image: postgres:15
|
|
restart: always
|
|
environment:
|
|
POSTGRES_DB: caldb
|
|
POSTGRES_USER: caluser
|
|
POSTGRES_PASSWORD: calpass
|
|
volumes:
|
|
- caldata:/var/lib/postgresql/data
|
|
|
|
volumes:
|
|
caldata:
|
|
"@ | Set-Content -Path $composeFile
|
|
|
|
# Navigate to the folder
|
|
Set-Location $folder
|
|
|
|
# Start Docker containers
|
|
Write-Host "🚀 Starting Docker containers..."
|
|
docker compose up -d
|
|
|
|
# Wait for DB and Cal.com to initialize (30 seconds)
|
|
Write-Host "⏳ Waiting for services to initialize..."
|
|
Start-Sleep -Seconds 30
|
|
|
|
# Apply Prisma database migrations
|
|
Write-Host "📦 Running Prisma migrations..."
|
|
docker compose exec calcom yarn prisma migrate deploy
|
|
|
|
# Seed the database
|
|
Write-Host "🌱 Seeding the database..."
|
|
docker compose exec calcom yarn prisma db seed
|
|
|
|
# Open Cal.com in the browser
|
|
Write-Host "🌐 Opening Cal.com at http://localhost:3000"
|
|
Start-Process "http://localhost:3000"
|
|
|
|
Write-Host "`n✅ Cal.com is ready!" |