rdev/internal/adapter/gitea/templates/infrastructure.md
jordan c59d348040 chore: prepare for composable monorepo template implementation
This commit captures the current state before implementing the composable
monorepo template system. Key changes included:

Infrastructure:
- Add CockroachDB provisioner adapter for database provisioning
- Add Redis provisioner adapter for cache provisioning
- Add build events system with PostgreSQL storage
- Add WebSocket endpoint for real-time build progress

Code agent improvements:
- Fix Claude Code adapter to use default allowed tools instead of dangerously-skip-permissions
- Add context-aware stream closing for cancellation support
- Improve parser tests for edge cases

Build system:
- Add build event constants and metrics
- Remove deprecated git_operations.go (replaced by pod_git_operations.go)
- Add rollback logic for multi-step provisioning operations

Documentation:
- Add composable-monorepo feature documentation
- Add DNS/Cloudflare service documentation
- Update deployment and troubleshooting guides

Cookbooks:
- Add fullstack-app cookbook
- Refactor landing-test with shared library

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-31 11:39:28 -07:00

93 lines
2.0 KiB
Markdown

# Infrastructure
This project has provisioned database and cache access.
## Database (CockroachDB)
PostgreSQL-compatible distributed SQL database.
### Connection
| Environment | Variable |
|-------------|----------|
| Production | `DATABASE_URL` |
| Staging | `DATABASE_URL_STAGING` |
### Usage
**Go (sqlx):**
```go
import "github.com/jmoiron/sqlx"
import _ "github.com/lib/pq"
db, err := sqlx.Connect("postgres", os.Getenv("DATABASE_URL"))
```
**Node.js (pg):**
```javascript
import pg from 'pg';
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL });
```
**Python (psycopg2):**
```python
import psycopg2
conn = psycopg2.connect(os.environ['DATABASE_URL'])
```
### Schema Migrations
Use any PostgreSQL migration tool. Recommended:
- Go: `golang-migrate/migrate`
- Node.js: `node-pg-migrate`
- Python: `alembic`
## Cache (Redis)
Redis cache with project-isolated key prefix.
### Connection
| Environment | Variable |
|-------------|----------|
| Production | `REDIS_URL` |
| Staging | `REDIS_URL_STAGING` |
| Key Prefix | `REDIS_PREFIX` |
**Important:** Always prefix your keys with `REDIS_PREFIX` to ensure isolation.
### Usage
**Go (go-redis):**
```go
import "github.com/redis/go-redis/v9"
opt, _ := redis.ParseURL(os.Getenv("REDIS_URL"))
client := redis.NewClient(opt)
prefix := os.Getenv("REDIS_PREFIX")
client.Set(ctx, prefix+"users:123", data, time.Hour)
```
**Node.js (ioredis):**
```javascript
import Redis from 'ioredis';
const redis = new Redis(process.env.REDIS_URL);
const prefix = process.env.REDIS_PREFIX;
await redis.set(`${prefix}session:abc`, JSON.stringify(data), 'EX', 3600);
```
## Environment Variables
These are automatically injected into your deployment:
| Variable | Description |
|----------|-------------|
| `DATABASE_URL` | CockroachDB production connection |
| `DATABASE_URL_STAGING` | CockroachDB staging connection |
| `REDIS_URL` | Redis production connection |
| `REDIS_URL_STAGING` | Redis staging connection |
| `REDIS_PREFIX` | Key prefix for Redis isolation |