Files
lang-agent/docker/docker-compose.prod.yml
2026-03-12 17:20:32 +08:00

99 lines
2.6 KiB
YAML

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:-5434}: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
# Frontend build service
frontend:
build:
context: ../frontend
dockerfile: ../docker/Dockerfile.frontend
volumes:
- frontend_dist:/app/dist
networks:
- app-network
# 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:-8080}:80"
volumes:
- ../nginx.conf:/etc/nginx/nginx.conf:ro
- frontend_dist:/usr/share/nginx/html:ro
depends_on:
frontend:
condition: service_completed_successfully
backend:
condition: service_started
restart: unless-stopped
volumes:
postgres_data:
frontend_dist:
networks:
app-network:
driver: bridge