WIP! A BB-style forum, on the ATmosphere! We're still working... we'll be back soon when we have something to show off!
node typescript hono htmx atproto
at atb-59-theme-editor 177 lines 6.4 kB view raw
1# ============================================================================ 2# atBB Docker Compose Example 3# ============================================================================ 4# This example demonstrates how to run atBB with PostgreSQL for local testing 5# and development. For production deployments, see docs/deployment-guide.md. 6# 7# Prerequisites: 8# - Docker Engine 20.10+ or Docker Desktop 9# - Docker Compose v2.0+ 10# - .env file with your configuration (copy .env.production.example) 11# 12# Quick Start: 13# 1. Copy environment template: 14# cp .env.production.example .env 15# 16# 2. Generate session secret: 17# openssl rand -hex 32 18# 19# 3. Edit .env and fill in required values: 20# - SESSION_SECRET (generated above) 21# - FORUM_DID (your forum's AT Protocol DID) 22# - PDS_URL (your PDS server URL) 23# - FORUM_HANDLE (your forum's handle) 24# - FORUM_PASSWORD (your forum account password) 25# - OAUTH_PUBLIC_URL (e.g., http://localhost for local testing) 26# 27# 4. Start services: 28# docker-compose -f docker-compose.example.yml up -d 29# 30# 5. Run database migrations (IMPORTANT - do this before first use): 31# docker-compose -f docker-compose.example.yml exec atbb \ 32# pnpm --filter @atbb/appview db:migrate 33# 34# 6. Access your forum at http://localhost 35# 36# Management: 37# - View logs: docker-compose -f docker-compose.example.yml logs -f 38# - Stop services: docker-compose -f docker-compose.example.yml down 39# - Remove data: docker-compose -f docker-compose.example.yml down -v 40# - Restart: docker-compose -f docker-compose.example.yml restart 41# 42# Production Deployment: 43# This example is for LOCAL TESTING ONLY. For production: 44# - Use managed PostgreSQL (AWS RDS, DigitalOcean, etc.) 45# - Use strong passwords (minimum 16 characters) 46# - Enable HTTPS with Caddy or nginx reverse proxy 47# - Set OAUTH_PUBLIC_URL to your actual domain (https://forum.example.com) 48# - Use environment variable injection instead of .env files 49# - Enable database SSL/TLS (?sslmode=require) 50# - Set up automated backups and monitoring 51# - Review security checklist in .env.production.example 52# 53# See docs/deployment-guide.md for complete production setup instructions. 54# ============================================================================ 55 56version: '3.8' 57 58services: 59 # PostgreSQL Database 60 # Stores forum data: posts, users, categories, moderation actions. 61 postgres: 62 image: postgres:17-alpine 63 container_name: atbb-postgres 64 65 # Database credentials 66 # For local testing only - use strong passwords in production! 67 environment: 68 POSTGRES_USER: atbb 69 POSTGRES_PASSWORD: atbb_local_dev_password 70 POSTGRES_DB: atbb 71 72 # Expose PostgreSQL port for debugging (optional) 73 # Remove in production or restrict to localhost: "127.0.0.1:5432:5432" 74 ports: 75 - "5432:5432" 76 77 # Persist database data across container restarts 78 # Data stored in Docker volume: docker volume inspect atbb_postgres_data 79 volumes: 80 - postgres_data:/var/lib/postgresql/data 81 82 # Health check ensures database is ready before starting atbb service 83 # Prevents connection errors during startup 84 healthcheck: 85 test: ["CMD-SHELL", "pg_isready -U atbb"] 86 interval: 10s 87 timeout: 5s 88 retries: 5 89 start_period: 10s 90 91 # Restart policy: restart unless explicitly stopped 92 # Ensures database comes back online after host reboot 93 restart: unless-stopped 94 95 # atBB Application 96 # Runs both appview (API) and web (UI) services with nginx routing. 97 atbb: 98 # Build from Dockerfile in current directory 99 build: 100 context: . 101 dockerfile: Dockerfile 102 103 container_name: atbb-app 104 105 # Expose nginx port (public HTTP access) 106 # nginx routes: 107 # - /api/* → appview:3000 (API server) 108 # - /* → web:3001 (web UI) 109 ports: 110 - "80:80" 111 112 # Wait for database to be healthy before starting 113 # Prevents connection errors at startup 114 depends_on: 115 postgres: 116 condition: service_healthy 117 118 # Environment variables 119 # Load from .env file + override specific values 120 # NOTE: DATABASE_URL must use container name "postgres" as hostname 121 environment: 122 # Database connection (uses container service name as hostname) 123 DATABASE_URL: postgresql://atbb:atbb_local_dev_password@postgres:5432/atbb 124 125 # AT Protocol credentials (loaded from .env file) 126 FORUM_DID: ${FORUM_DID} 127 PDS_URL: ${PDS_URL} 128 FORUM_HANDLE: ${FORUM_HANDLE} 129 FORUM_PASSWORD: ${FORUM_PASSWORD} 130 131 # OAuth configuration 132 # For local testing, use http://localhost 133 # For production, use your actual domain (https://forum.example.com) 134 OAUTH_PUBLIC_URL: ${OAUTH_PUBLIC_URL} 135 136 # Internal service communication 137 # Web service connects to appview API at http://localhost:3000 138 # (both run in same container, so localhost is correct) 139 APPVIEW_URL: http://localhost:3000 140 141 # Session encryption key 142 # CRITICAL: Generate with: openssl rand -hex 32 143 SESSION_SECRET: ${SESSION_SECRET} 144 145 # Optional: Session TTL (defaults to 7 days if not set) 146 # SESSION_TTL_DAYS: ${SESSION_TTL_DAYS:-7} 147 148 # Optional: Jetstream firehose URL (uses default if not set) 149 # JETSTREAM_URL: ${JETSTREAM_URL:-wss://jetstream2.us-east.bsky.network/subscribe} 150 151 # Load additional environment variables from .env file 152 # Variables defined above take precedence over .env file 153 env_file: 154 - .env 155 156 # Health check for container orchestration 157 # Verifies web UI is responding to requests 158 # NOTE: This checks nginx, which proxies to both appview and web 159 healthcheck: 160 test: ["CMD", "wget", "--no-verbose", "--tries=1", "--spider", "http://localhost/"] 161 interval: 30s 162 timeout: 3s 163 retries: 3 164 start_period: 10s 165 166 # Restart policy: restart unless explicitly stopped 167 # Ensures forum comes back online after crashes or host reboot 168 restart: unless-stopped 169 170# Named volumes for data persistence 171# Volumes survive container removal (docker-compose down) 172# To remove volumes: docker-compose down -v 173volumes: 174 postgres_data: 175 # PostgreSQL data directory 176 # Contains all forum data (posts, users, categories, etc.) 177 # Backup strategy: Use pg_dump or managed database backups in production