mirror of
https://github.com/twentyhq/twenty.git
synced 2026-04-18 05:54:42 -04:00
## Summary Completely rewrites the development environment setup script to be more robust, idempotent, and flexible. The new implementation auto-detects available services (local PostgreSQL/Redis vs Docker), provides multiple operational modes, and includes comprehensive health checks and error handling. ## Key Changes - **Enhanced setup script** (`packages/twenty-utils/setup-dev-env.sh`): - Added auto-detection logic to prefer local services (PostgreSQL 16, Redis) over Docker - Implemented service health checks with retry logic (30s timeout) - Added command-line flags: `--docker` (force Docker), `--down` (stop services), `--reset` (wipe data) - Improved error handling with `set -euo pipefail` and descriptive failure messages - Added helper functions for service detection, startup, and status checking - Fallback to manual `.env` file copying if Nx is unavailable - Enhanced output with clear status messages and usage instructions - **New Docker Compose file** (`packages/twenty-docker/docker-compose.dev.yml`): - Dedicated development infrastructure file (PostgreSQL 16 + Redis 7) - Includes health checks for both services - Configured with appropriate restart policies and volume management - Separate from production compose configuration - **Updated documentation** (`CLAUDE.md`): - Clarified that all environments (CI, local, Claude Code, Cursor) use the same setup script - Documented new command-line flags and their purposes - Noted that CI workflows manage services independently via GitHub Actions - **Updated Cursor environment config** (`.cursor/environment.json`): - Simplified to use the new unified setup script instead of complex inline commands ## Implementation Details The script now follows a clear three-phase approach: 1. **Service startup** — Auto-detects and starts PostgreSQL and Redis (local or Docker) 2. **Database creation** — Creates 'default' and 'test' databases 3. **Environment configuration** — Sets up `.env` files via Nx or direct file copy The auto-detection logic prioritizes local services for better performance while gracefully falling back to Docker if local services aren't available. All operations are idempotent and safe to run multiple times. https://claude.ai/code/session_01UDxa2Kp1ub9tTL3pnpBVFs --------- Co-authored-by: Claude <noreply@anthropic.com>
43 lines
1014 B
YAML
43 lines
1014 B
YAML
# Development infrastructure services only (Postgres + Redis).
|
|
# Use this when developing locally against the source code.
|
|
#
|
|
# Usage:
|
|
# docker compose -f docker-compose.dev.yml up -d
|
|
# docker compose -f docker-compose.dev.yml down # stop
|
|
# docker compose -f docker-compose.dev.yml down -v # stop + wipe data
|
|
|
|
name: twenty-dev
|
|
|
|
services:
|
|
db:
|
|
image: postgres:16
|
|
volumes:
|
|
- dev-db-data:/var/lib/postgresql/data
|
|
ports:
|
|
- "5432:5432"
|
|
environment:
|
|
POSTGRES_USER: postgres
|
|
POSTGRES_PASSWORD: postgres
|
|
POSTGRES_DB: default
|
|
healthcheck:
|
|
test: pg_isready -U postgres -h localhost -d postgres
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
restart: unless-stopped
|
|
|
|
redis:
|
|
image: redis:7
|
|
ports:
|
|
- "6379:6379"
|
|
command: ["--maxmemory-policy", "noeviction"]
|
|
healthcheck:
|
|
test: ["CMD", "redis-cli", "ping"]
|
|
interval: 5s
|
|
timeout: 5s
|
|
retries: 10
|
|
restart: unless-stopped
|
|
|
|
volumes:
|
|
dev-db-data:
|