version: '3.8' services: # PostgreSQL database postgres: image: postgres:16-alpine container_name: langchain-agent-db networks: - app-network environment: POSTGRES_DB: postgres POSTGRES_USER: postgres POSTGRES_PASSWORD: ${POSTGRES_ROOT_PASSWORD:-postgres_root_password} # These are used by init scripts to create the app database APP_DB_NAME: ${POSTGRES_DB:-ai_conversations} APP_DB_USER: ${POSTGRES_USER:-myapp_user} APP_DB_PASSWORD: ${POSTGRES_PASSWORD:-secure_password_123} volumes: - postgres_data:/var/lib/postgresql/data - ../scripts/init_database:/docker-entrypoint-initdb.d ports: - "${POSTGRES_PORT:-5432}:5432" healthcheck: test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 10s timeout: 5s retries: 5 restart: unless-stopped # Backend API server backend: build: context: .. dockerfile: docker/Dockerfile.prod container_name: langchain-agent-backend environment: - PYTHONPATH=/app - PYTHONUNBUFFERED=1 - CONN_STR=postgresql://${POSTGRES_USER:-myapp_user}:${POSTGRES_PASSWORD:-secure_password_123}@postgres:5432/${POSTGRES_DB:-ai_conversations} - POSTGRES_USER=${POSTGRES_USER:-myapp_user} - POSTGRES_PASSWORD=${POSTGRES_PASSWORD:-secure_password_123} - POSTGRES_DB=${POSTGRES_DB:-ai_conversations} ports: - "${BACKEND_PORT:-8500}:8500" volumes: - ../configs:/app/configs - ../scripts:/app/scripts - ../assets:/app/assets - ../static:/app/static networks: - app-network depends_on: postgres: condition: service_healthy restart: unless-stopped healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8500/health"] interval: 30s timeout: 10s retries: 3 start_period: 40s # Nginx for serving frontend (optional - can also serve via FastAPI) nginx: image: nginx:alpine container_name: langchain-agent-nginx networks: - app-network ports: - "${FRONTEND_PORT:-80}:80" volumes: - ../nginx.conf:/etc/nginx/nginx.conf:ro - ../frontend/dist:/usr/share/nginx/html:ro depends_on: - backend restart: unless-stopped volumes: postgres_data: networks: app-network: driver: bridge