···1+# ============================================================================
2+# atBB Production Environment Configuration
3+# ============================================================================
4+# Copy this file to .env.production and fill in your actual values.
5+# NEVER commit .env.production with real secrets to version control!
6+#
7+# After copying:
8+# 1. Generate SESSION_SECRET: openssl rand -hex 32
9+# 2. Fill in your AT Protocol credentials (FORUM_DID, PDS_URL, etc.)
10+# 3. Set strong passwords for FORUM_PASSWORD and database
11+# 4. Update URLs to match your deployment domain
12+# 5. Restrict file permissions: chmod 600 .env.production
13+#
14+# Security note: This file contains sensitive credentials. Protect it like
15+# you would protect SSH keys or API tokens.
16+# ============================================================================
17+18+# ============================================================================
19+# Database Configuration
20+# ============================================================================
21+# PostgreSQL connection string
22+# Format: postgresql://username:password@hostname:port/database
23+#
24+# Production example (managed PostgreSQL):
25+# DATABASE_URL=postgresql://atbb_prod:S3cureP@ssw0rd@db.example.com:5432/atbb_prod
26+#
27+# Docker Compose example (container name as hostname):
28+# DATABASE_URL=postgresql://atbb:changeme@postgres:5432/atbb
29+#
30+# Notes:
31+# - Use strong passwords (minimum 16 characters, alphanumeric + symbols)
32+# - Enable SSL/TLS in production: ?sslmode=require
33+# - Consider connection pooling for high traffic
34+DATABASE_URL=postgresql://atbb_user:CHANGE_ME_STRONG_PASSWORD@db.example.com:5432/atbb_production
35+36+# ============================================================================
37+# AT Protocol Configuration
38+# ============================================================================
39+# These settings connect your forum to the AT Protocol network (Bluesky/atproto).
40+41+# Forum's Decentralized Identifier (DID)
42+# This is your forum's unique identity on the AT Protocol network.
43+# Get this after creating your forum account on a PDS.
44+#
45+# Example: did:plc:abcdef1234567890
46+# Production: Use your actual forum DID from your PDS
47+FORUM_DID=did:plc:CHANGE_ME_YOUR_FORUM_DID
48+49+# Personal Data Server URL
50+# The PDS where your forum's records are stored.
51+# This can be your own PDS instance or a hosted service.
52+#
53+# Examples:
54+# - Self-hosted: https://pds.yourdomain.com
55+# - Bluesky PDS: https://bsky.social
56+PDS_URL=https://pds.example.com
57+58+# Note: FORUM_HANDLE and FORUM_PASSWORD are only used by the spike test script,
59+# not by the production applications. The appview and web services do not require
60+# forum credentials to operate.
61+62+# ============================================================================
63+# Application URLs
64+# ============================================================================
65+# These URLs determine how services communicate and handle OAuth.
66+67+# Public URL where your forum is accessible to users
68+# Used for OAuth redirect URIs and client_id generation.
69+# MUST be HTTPS in production (HTTP only for local development).
70+#
71+# Examples:
72+# - Production: https://forum.example.com
73+# - Staging: https://staging.forum.example.com
74+OAUTH_PUBLIC_URL=https://forum.example.com
75+76+# Internal URL for web service to reach appview API
77+# In single-container deployments: http://localhost:3000
78+# In multi-container deployments: http://appview:3000 (Docker service name)
79+# In Kubernetes: http://appview-service:3000
80+#
81+# Notes:
82+# - Use container/service names, not external domains
83+# - HTTP is fine for internal communication (encrypted at network layer)
84+# - Must be reachable from web service container
85+APPVIEW_URL=http://localhost:3000
86+87+# ============================================================================
88+# Session Management
89+# ============================================================================
90+# Session security is critical for protecting user accounts.
91+92+# Secret key for encrypting and signing session cookies
93+# CRITICAL: Generate a strong random value, never use the default!
94+#
95+# Generate with: openssl rand -hex 32
96+#
97+# Security requirements:
98+# - Minimum 32 bytes (64 hex characters)
99+# - Use cryptographically secure random generation
100+# - Unique per environment (dev, staging, production)
101+# - Never commit to version control
102+# - Rotate periodically (invalidates all active sessions)
103+#
104+# Example output from openssl:
105+# a1b2c3d4e5f6789012345678901234567890abcdef1234567890abcdef123456
106+SESSION_SECRET=
107+108+# ============================================================================
109+# Service Ports (Optional)
110+# ============================================================================
111+# Override default ports if needed for your deployment environment.
112+# Most deployments can use the defaults.
113+114+# AppView API server port (default: 3000)
115+# This is the internal port the appview service listens on.
116+# PORT=3000
117+118+# Note: The web service also uses PORT (not WEB_PORT) and defaults to 3001.
119+# In the Docker container, nginx listens on port 80 and proxies to both services.
120+121+# ============================================================================
122+# AT Protocol Features (Optional)
123+# ============================================================================
124+# Advanced AT Protocol configuration.
125+126+# Jetstream firehose URL for real-time updates
127+# Receives live events from the AT Protocol network to keep your forum
128+# synchronized with user posts and profile changes.
129+#
130+# Default: wss://jetstream2.us-east.bsky.network/subscribe
131+#
132+# Notes:
133+# - Uses WebSocket (wss://) for real-time streaming
134+# - Alternative endpoints available for different regions
135+# - Required for live post indexing
136+# JETSTREAM_URL=wss://jetstream2.us-east.bsky.network/subscribe
137+138+# ============================================================================
139+# Session Configuration (Optional)
140+# ============================================================================
141+# Fine-tune session behavior for your deployment.
142+143+# Session cookie TTL (Time To Live) in days
144+# How long users stay logged in before requiring re-authentication.
145+#
146+# Default: 7 days
147+# Recommended ranges:
148+# - High security: 1-7 days (default)
149+# - Balanced: 14-30 days
150+# - Convenience: 90 days
151+#
152+# Notes:
153+# - Shorter TTL = more secure, more logins required
154+# - Longer TTL = less secure, better user experience
155+# - Consider your forum's security requirements
156+# SESSION_TTL_DAYS=7
157+158+# Redis session storage (optional, for multi-instance deployments)
159+# If set, sessions are stored in Redis instead of memory.
160+# Required for horizontal scaling (multiple appview instances).
161+#
162+# Format: redis://[username]:[password]@hostname:port/database
163+#
164+# Examples:
165+# - Local Redis: redis://localhost:6379
166+# - Docker Compose: redis://redis:6379
167+# - Managed Redis: redis://default:password@redis.example.com:6379/0
168+#
169+# Notes:
170+# - Leave blank/commented for single-instance deployments (uses in-memory)
171+# - Required for multi-instance deployments (shared session state)
172+# - Supports Redis Cluster and Sentinel configurations
173+# REDIS_URL=redis://redis:6379
174+175+# ============================================================================
176+# Security Checklist
177+# ============================================================================
178+# Before deploying to production, verify:
179+#
180+# [ ] Generated SESSION_SECRET with: openssl rand -hex 32
181+# [ ] Used strong, unique passwords (minimum 16 characters)
182+# [ ] Never committed .env.production to version control
183+# [ ] Set file permissions: chmod 600 .env.production
184+# [ ] All URLs use HTTPS (except APPVIEW_URL for internal communication)
185+# [ ] Database connection uses SSL/TLS (?sslmode=require)
186+# [ ] Forum account password is unique (not reused)
187+# [ ] SESSION_SECRET is different from dev/staging environments
188+# [ ] Documented secret rotation schedule (every 90 days recommended)
189+# [ ] Tested OAuth flow with OAUTH_PUBLIC_URL
190+# [ ] Verified APPVIEW_URL is reachable from web service
191+# [ ] Reviewed firewall rules (only expose necessary ports)
192+#
193+# ============================================================================
194+# Deployment Notes
195+# ============================================================================
196+#
197+# Single Container Deployment (appview + web in same container):
198+# - Use APPVIEW_URL=http://localhost:3000
199+# - No Redis required (in-memory sessions OK)
200+# - Simpler setup, suitable for small forums
201+#
202+# Multi Container Deployment (separate appview and web containers):
203+# - Use APPVIEW_URL=http://appview:3000 (Docker service name)
204+# - Consider Redis for session storage
205+# - Better scalability, suitable for larger forums
206+#
207+# Kubernetes Deployment:
208+# - Use APPVIEW_URL=http://appview-service:3000
209+# - Redis highly recommended for multi-replica deployments
210+# - Use Secrets for sensitive values (not ConfigMaps)
211+#
212+# Environment Variable Loading:
213+# - Docker: Use --env-file flag or docker-compose env_file
214+# - Kubernetes: Mount as Secret or use external-secrets
215+# - Systemd: Use EnvironmentFile=/path/to/.env.production
216+# - Node.js: Use --env-file flag (Node 20.6+)
217+#
218+# ============================================================================
219+# Troubleshooting
220+# ============================================================================
221+#
222+# "Database connection failed":
223+# - Verify DATABASE_URL is correct and accessible
224+# - Check network connectivity to database host
225+# - Ensure database exists and user has permissions
226+# - Enable SSL if required by your database provider
227+#
228+# "OAuth redirect URI mismatch":
229+# - Verify OAUTH_PUBLIC_URL matches your actual domain
230+# - Must use HTTPS in production (not HTTP)
231+# - Check for trailing slashes (should not have one)
232+#
233+# "Session errors / users logged out randomly":
234+# - Verify SESSION_SECRET is set (not blank)
235+# - For multi-instance: must use Redis (set REDIS_URL)
236+# - Check SESSION_TTL_DAYS is reasonable (default 7)
237+#
238+# "Cannot reach appview API":
239+# - Verify APPVIEW_URL uses correct hostname
240+# - In Docker: use service name, not localhost
241+# - Check container/service networking configuration
242+#
243+# ============================================================================