File size: 4,817 Bytes
127bfda
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
version: "3.8"

services:
  # =============================================================================
  # TWITCH V-BOT - Main Application
  # =============================================================================
  bot:
    build:
      context: .
      dockerfile: bot/Dockerfile
    container_name: twitch-v-bot
    restart: unless-stopped
    env_file:
      - .env
    environment:
      - PYTHONUNBUFFERED=1
      - PYTHONDONTWRITEBYTECODE=1
    volumes:
      - ./bot:/app/bot:ro
      - ./dashboard:/app/dashboard:ro
    networks:
      - twitch-network
    depends_on:
      - redis
      - supabase
    healthcheck:
      test: ["CMD", "python", "-c", "import bot"]
      interval: 30s
      timeout: 10s
      retries: 3

  # =============================================================================
  # REDIS - Cache and Pub/Sub
  # =============================================================================
  redis:
    image: redis:7-alpine
    container_name: twitch-v-bot-redis
    restart: unless-stopped
    ports:
      - "6379:6379"
    volumes:
      - redis-data:/data
    networks:
      - twitch-network
    healthcheck:
      test: ["CMD", "redis-cli", "ping"]
      interval: 10s
      timeout: 3s
      retries: 3

  # =============================================================================
  # SUPABASE - Local Database (optional)
  # =============================================================================
  supabase:
    image: supabase/postgres:15.1.0.147
    container_name: twitch-v-bot-supabase
    restart: unless-stopped
    ports:
      - "5432:5432"
      - "54321:54321"
    environment:
      - POSTGRES_PASSWORD=postgres
      - POSTGRES_DB=postgres
      - POSTGRES_USER=postgres
    volumes:
      - supabase-data:/var/lib/postgresql/data
    networks:
      - twitch-network
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U postgres"]
      interval: 10s
      timeout: 3s
      retries: 3

  # =============================================================================
  # DASHBOARD - Web Interface
  # =============================================================================
  dashboard:
    build:
      context: .
      dockerfile: bot/Dockerfile
    container_name: twitch-v-bot-dashboard
    restart: unless-stopped
    ports:
      - "8080:8080"
    env_file:
      - .env
    environment:
      - PYTHONUNBUFFERED=1
    volumes:
      - ./bot:/app/bot:ro
      - ./dashboard:/app/dashboard:ro
    networks:
      - twitch-network
    depends_on:
      - redis
      - supabase

  # =============================================================================
  # PGADMIN - Database Management (optional)
  # =============================================================================
  pgadmin:
    image: dpage/pgadmin4:latest
    container_name: twitch-v-bot-pgadmin
    restart: unless-stopped
    ports:
      - "5050:80"
    environment:
      - PGADMIN_DEFAULT_EMAIL=admin@localhost
      - PGADMIN_DEFAULT_PASSWORD=admin
    volumes:
      - pgadmin-data:/var/lib/pgadmin
    networks:
      - twitch-network
    depends_on:
      - supabase

  # =============================================================================
  # REDIS-CLI - Redis CLI for debugging
  # =============================================================================
  redis-cli:
    image: redis:7-alpine
    container_name: twitch-v-bot-redis-cli
    profiles:
      - debug
    command: redis-cli -h redis
    networks:
      - twitch-network
    depends_on:
      - redis

  # =============================================================================
  # TEST RUNNER - Run tests in Docker
  # =============================================================================
  test:
    build:
      context: .
      dockerfile: bot/Dockerfile
    container_name: twitch-v-bot-test
    profiles:
      - debug
    env_file:
      - .env.test
    environment:
      - PYTHONUNBUFFERED=1
    volumes:
      - ./bot:/app/bot
      - ./dashboard:/app/dashboard
      - ./coverage:/app/coverage
    networks:
      - twitch-network
    command: pytest bot/tests/ -v --cov=bot/ --cov-report=html --cov-report=term-missing
    depends_on:
      - redis
      - supabase

networks:
  twitch-network:
    driver: bridge

volumes:
  redis-data:
  supabase-data:
  pgadmin-data:

# =============================================================================
# USAGE
# =============================================================================
# Development:
#   docker-compose up -d
#
# Run tests:
#   docker-compose --profile test up test
#
# Redis CLI:
#   docker-compose --profile debug up redis-cli
#
# View logs:
#   docker-compose logs -f
#
# Stop:
#   docker-compose down
#
# Stop with volumes:
#   docker-compose down -v