Spaces:
Sleeping

File size: 4,690 Bytes
0b355ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
version: '3.8'

services:
  # MongoDB Database
  mongodb:
    image: mongo:6.0
    container_name: uga-chatbot-mongodb
    restart: unless-stopped
    environment:
      MONGO_INITDB_ROOT_USERNAME: ${MONGODB_ROOT_USERNAME:-admin}
      MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_ROOT_PASSWORD:-password}
      MONGO_INITDB_DATABASE: ${MONGODB_DATABASE:-uga_chatbot}
    volumes:
      - mongodb_data:/data/db
      - mongodb_config:/data/configdb
      - ./scripts/init-mongo.js:/docker-entrypoint-initdb.d/init-mongo.js:ro
    ports:
      - "27017:27017"
    networks:
      - uga-chatbot-network
    healthcheck:
      test: echo 'db.runCommand("ping").ok' | mongosh mongodb://localhost:27017/test --quiet
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 40s

  # Redis Cache
  redis:
    image: redis:7-alpine
    container_name: uga-chatbot-redis
    restart: unless-stopped
    command: redis-server --requirepass ${REDIS_PASSWORD:-password} --maxmemory 256mb --maxmemory-policy allkeys-lru
    volumes:
      - redis_data:/data
    ports:
      - "6379:6379"
    networks:
      - uga-chatbot-network
    healthcheck:
      test: ["CMD", "redis-cli", "-a", "${REDIS_PASSWORD:-password}", "ping"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  # Ollama AI Service
  ollama:
    image: ollama/ollama:latest
    container_name: edichat-ollama
    restart: unless-stopped
    volumes:
      - ollama_data:/root/.ollama
    ports:
      - "11434:11434"
    networks:
      - uga-chatbot-network
    environment:
      - OLLAMA_KEEP_ALIVE=24h
      - OLLAMA_HOST=0.0.0.0
    command: serve
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost:11434/api/tags"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

  # Backend API
  backend:
    build:
      context: ./backend
      dockerfile: Dockerfile
    container_name: edichat-backend
    restart: unless-stopped
    environment:
      NODE_ENV: production
      PORT: 5000
      FRONTEND_URL: https://edi.chat
      BACKEND_URL: https://api.edi.chat
      MONGODB_URI: ${MONGODB_URI:-mongodb+srv://edichat:edi.chat@edi-chat-test.xc6c8ou.mongodb.net/?retryWrites=true&w=majority&appName=edi-chat-test}
      REDIS_URL: ${REDIS_URL:-redis://:${REDIS_PASSWORD:-password}@redis:6379}
      JWT_SECRET: ${JWT_SECRET}
      JWT_REFRESH_SECRET: ${JWT_REFRESH_SECRET}
      USE_LOCAL_AI: true
      LOCAL_AI_URL: http://ollama:11434
      LOCAL_AI_MODEL: llama3.2:latest
      OPENAI_API_KEY: ${OPENAI_API_KEY:-optional}
      UGA_API_BASE_URL: ${UGA_API_BASE_URL}
      UGA_API_KEY: ${UGA_API_KEY}
      EMAIL_SERVICE: ${EMAIL_SERVICE:-gmail}
      EMAIL_USER: ${EMAIL_USER}
      EMAIL_PASS: ${EMAIL_PASS}
    volumes:
      - backend_uploads:/app/uploads
      - backend_logs:/app/logs
    ports:
      - "5000:5000"
    depends_on:
      mongodb:
        condition: service_healthy
      redis:
        condition: service_healthy
      ollama:
        condition: service_healthy
    networks:
      - uga-chatbot-network
    healthcheck:
      test: ["CMD", "node", "healthcheck.js"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 60s

  # Frontend Web App
  frontend:
    build:
      context: ./frontend
      dockerfile: Dockerfile
    container_name: edichat-frontend
    restart: unless-stopped
    ports:
      - "80:80"
      - "443:443"
    depends_on:
      backend:
        condition: service_healthy
    networks:
      - uga-chatbot-network
    healthcheck:
      test: ["CMD", "curl", "-f", "http://localhost/health"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 30s

  # Load Balancer (Nginx)
  nginx:
    image: nginx:alpine
    container_name: uga-chatbot-nginx
    restart: unless-stopped
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
      - ./nginx/ssl:/etc/nginx/ssl:ro
      - nginx_logs:/var/log/nginx
    ports:
      - "8080:80"
      - "8443:443"
    depends_on:
      - frontend
      - backend
    networks:
      - uga-chatbot-network

# Networks
networks:
  uga-chatbot-network:
    driver: bridge
    name: uga-chatbot-network

# Volumes
volumes:
  mongodb_data:
    driver: local
    name: uga-chatbot-mongodb-data
  mongodb_config:
    driver: local
    name: uga-chatbot-mongodb-config
  redis_data:
    driver: local
    name: uga-chatbot-redis-data
  ollama_data:
    driver: local
    name: edichat-ollama-data
  backend_uploads:
    driver: local
    name: uga-chatbot-backend-uploads
  backend_logs:
    driver: local
    name: uga-chatbot-backend-logs
  nginx_logs:
    driver: local
    name: uga-chatbot-nginx-logs