project-standalo-note-to-app/.claude/references/eureka-infrastructure.md

238 lines
5.5 KiB
Markdown

# Eureka Platform Infrastructure Reference
Reference documentation for services available on the Eureka deployment platform.
## Injected Environment Variables
These variables are **automatically injected** by Eureka platform at runtime:
```bash
# Database
DATABASE_URL
# MinIO
MINIO_ENDPOINT
MINIO_PORT
MINIO_ROOT_USER
MINIO_ROOT_PASSWORD
MINIO_BUCKET_NAME
MINIO_USE_SSL
MINIO_PUBLIC_URL
```
## Available Services
### PostgreSQL Database
| Setting | Value |
|----------------|-----------------------------------------------------------|
| Host | `postgres` (Docker network) |
| Port | `5432` |
| Database | `eurekalabo` |
| Username | `appuser` |
| Password | `supersecret` |
| Connection URL | `postgresql://appuser:supersecret@postgres:5432/eurekalabo` |
**Environment Variable (injected):**
```bash
DATABASE_URL="postgresql://appuser:supersecret@postgres:5432/eurekalabo"
```
### MinIO Object Storage (S3-Compatible)
| Setting | Value |
|---------------|------------------------------------|
| Endpoint | `minio` (Docker network) |
| Port | `9000` |
| Root User | `minioadmin` |
| Root Password | `minioadmin` |
| Bucket Name | `eurekalabo-files` |
| Use SSL | `false` |
| Public URL | `https://minio.162-43-92-100.nip.io` |
**Environment Variables (injected):**
```bash
MINIO_ENDPOINT="minio"
MINIO_PORT="9000"
MINIO_ROOT_USER="minioadmin"
MINIO_ROOT_PASSWORD="minioadmin"
MINIO_BUCKET_NAME="eurekalabo-files"
MINIO_USE_SSL="false"
MINIO_PUBLIC_URL="https://minio.162-43-92-100.nip.io"
```
---
## Docker Network Architecture
Services run on shared Docker networks:
- `base_data` - Database connections
- `base_web` - Web/HTTP traffic
- `shared_backend` - Internal service communication
Your application container automatically joins these networks when deployed.
---
## Framework Integration
### Prisma (Node.js)
**prisma/schema.prisma:**
```prisma
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
```
**No changes needed** - Prisma reads `DATABASE_URL` automatically.
### Drizzle (Node.js)
**drizzle.config.ts:**
```typescript
import { defineConfig } from 'drizzle-kit';
export default defineConfig({
schema: './src/db/schema.ts',
out: './drizzle',
dialect: 'postgresql',
dbCredentials: {
url: process.env.DATABASE_URL!,
},
});
```
### SQLAlchemy (Python)
```python
from sqlalchemy import create_engine
import os
engine = create_engine(os.environ['DATABASE_URL'])
```
### MinIO / S3 Client (Node.js)
**Using AWS SDK v3:**
```typescript
import { S3Client } from '@aws-sdk/client-s3';
const s3 = new S3Client({
endpoint: `http://${process.env.MINIO_ENDPOINT}:${process.env.MINIO_PORT}`,
region: 'us-east-1',
credentials: {
accessKeyId: process.env.MINIO_ROOT_USER!,
secretAccessKey: process.env.MINIO_ROOT_PASSWORD!,
},
forcePathStyle: true, // Required for MinIO
});
// Use bucket: process.env.MINIO_BUCKET_NAME
```
**Using MinIO SDK:**
```typescript
import { Client } from 'minio';
const minio = new Client({
endPoint: process.env.MINIO_ENDPOINT!,
port: parseInt(process.env.MINIO_PORT || '9000'),
useSSL: process.env.MINIO_USE_SSL === 'true',
accessKey: process.env.MINIO_ROOT_USER!,
secretKey: process.env.MINIO_ROOT_PASSWORD!,
});
// Use bucket: process.env.MINIO_BUCKET_NAME
```
### MinIO / S3 Client (Python)
**Using boto3:**
```python
import boto3
import os
s3 = boto3.client(
's3',
endpoint_url=f"http://{os.environ['MINIO_ENDPOINT']}:{os.environ['MINIO_PORT']}",
aws_access_key_id=os.environ['MINIO_ROOT_USER'],
aws_secret_access_key=os.environ['MINIO_ROOT_PASSWORD'],
)
# Use bucket: os.environ['MINIO_BUCKET_NAME']
```
---
## Dockerfile Environment Variables
When building Docker images, these environment variables are injected at runtime, NOT build time.
**DO NOT hardcode credentials in Dockerfile.**
**Correct pattern:**
```dockerfile
# Runtime env vars - set by Eureka platform
ENV NODE_ENV=production
# DATABASE_URL, MINIO_* injected at runtime
```
**Wrong pattern:**
```dockerfile
# NEVER DO THIS
ENV DATABASE_URL="postgresql://..."
ENV MINIO_ROOT_PASSWORD="..."
```
---
## Pre-Deployment Checklist
Before deploying, verify your app:
1. **Reads from environment variables** (not hardcoded)
2. **Has `.env.example`** documenting required vars
3. **Dockerfile doesn't contain secrets**
4. **Database migrations** are ready (`prisma migrate deploy`, etc.)
### Migration Commands
**Prisma:**
```bash
npx prisma migrate deploy
```
**Drizzle:**
```bash
npx drizzle-kit migrate
```
**Django:**
```bash
python manage.py migrate
```
---
## Troubleshooting
### Database Connection Failed
1. Check container is on correct networks
2. Verify `DATABASE_URL` format
3. Check postgres container is running: `docker ps | grep postgres`
### MinIO Upload Failed
1. Verify bucket exists: `eurekalabo-files`
2. Check `forcePathStyle: true` for AWS SDK
3. Verify endpoint format: `http://minio:9000` (not `https`)
### Environment Variables Not Available
1. Check `.env` file exists (copy from `.env.example`)
2. Verify Eureka deployment injects vars
3. Check Docker Compose env_file configuration