File size: 4,456 Bytes
a282d4b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
version: "3.8"

# ============================================================
# BankBot AI β€” Docker Compose
#
# Development:  docker compose up -d
# Production:   docker compose --profile production up -d
# Seed data:    docker compose exec backend python app/scripts/seed_demo.py
# Logs:         docker compose logs -f backend
# Stop:         docker compose down
# ============================================================

services:

  # ─── PostgreSQL ─────────────────────────────────────────────
  db:
    image: postgres:15-alpine
    container_name: bankbot_postgres
    restart: unless-stopped
    environment:
      POSTGRES_USER:     ${POSTGRES_USER:-admin}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-adminpassword}
      POSTGRES_DB:       ${POSTGRES_DB:-bankbot}
    ports:
      - "5432:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-admin} -d ${POSTGRES_DB:-bankbot}"]
      interval: 5s
      timeout: 5s
      retries: 10
      start_period: 10s

  # ─── Redis ──────────────────────────────────────────────────
  redis:
    image: redis:7-alpine
    container_name: bankbot_redis
    restart: unless-stopped
    command: >
      redis-server
      --maxmemory 256mb
      --maxmemory-policy allkeys-lru
      --save 60 1
    ports:
      - "6379:6379"
    volumes:
      - redisdata:/data
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 5s
      timeout: 3s
      retries: 5

  # ─── Backend ────────────────────────────────────────────────
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
      target: runtime
    container_name: bankbot_backend
    restart: unless-stopped
    ports:
      - "8000:8000"
    environment:
      DATABASE_URL:              postgresql://${POSTGRES_USER:-admin}:${POSTGRES_PASSWORD:-adminpassword}@db:5432/${POSTGRES_DB:-bankbot}
      REDIS_URL:                 redis://redis:6379/0
      OPENAI_API_KEY:            ${OPENAI_API_KEY:-}
      GROQ_API_KEY:              ${GROQ_API_KEY:-}
      OLLAMA_MODEL:              ${OLLAMA_MODEL:-llama3:latest}
      JWT_SECRET_KEY:            ${JWT_SECRET_KEY:-bankbot-change-in-production}
      JWT_ALGORITHM:             HS256
      ACCESS_TOKEN_EXPIRE_MINUTES: "60"
      BACKEND_CORS_ORIGINS:      '["http://localhost:3000","http://frontend:3000","${FRONTEND_URL:-http://localhost:3000}"]'
    depends_on:
      db:
        condition: service_healthy
      redis:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
      interval: 15s
      timeout: 10s
      retries: 5
      start_period: 20s

  # ─── Frontend ───────────────────────────────────────────────
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
      target: runtime
      args:
        NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:8000}
    container_name: bankbot_frontend
    restart: unless-stopped
    ports:
      - "3000:3000"
    environment:
      NEXT_PUBLIC_API_URL: ${NEXT_PUBLIC_API_URL:-http://localhost:8000}
      NODE_ENV: production
    depends_on:
      backend:
        condition: service_healthy
    healthcheck:
      test: ["CMD", "wget", "-qO-", "http://localhost:3000/"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  # ─── Nginx (production profile only) ────────────────────────
  nginx:
    image: nginx:1.25-alpine
    container_name: bankbot_nginx
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - nginx_logs:/var/log/nginx
    depends_on:
      - frontend
      - backend
    profiles:
      - production
    healthcheck:
      test: ["CMD", "nginx", "-t"]
      interval: 30s
      timeout: 5s
      retries: 3

volumes:
  pgdata:
    driver: local
  redisdata:
    driver: local
  nginx_logs:
    driver: local