-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathdocker-compose.yml
More file actions
207 lines (187 loc) · 8.31 KB
/
docker-compose.yml
File metadata and controls
207 lines (187 loc) · 8.31 KB
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
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
version: '3.8'
services:
########################################
# Your .NET Web API Application Service
########################################
forex-trading-bot-app:
build:
context: .
dockerfile: Dockerfile
container_name: forex-trading-bot-app
ports:
- "8080:80"
environment:
# --- Database Connection (Using PostgreSQL) ---
- ConnectionStrings__DefaultConnection=Host=postgres-db;Port=5432;Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD};Include Error Detail=true
# - ConnectionStrings__DefaultConnection_SQLSERVER=Server=db,1433;Database=${DB_DATABASE_NAME};User Id=sa;Password=${DB_SA_PASSWORD};TrustServerCertificate=True
# --- Redis Connection ---
- ConnectionStrings__Redis=redis:6379,abortConnect=false
# --- Settings relevant for WebAPI, TelegramPanel, BackgroundTasks ---
# --- Telegram Panel specific settings are primarily for TelegramPanel service ---
- TelegramPanel__BotToken=${TELEGRAM_BOT_TOKEN}
- TelegramPanel__AdminUserIds=${TELEGRAM_ADMIN_IDS}
# --- Telegram User API (used by ApiUserClient, potentially in multiple services) ---
- TelegramUserApi__ApiId=${TELEGRAM_API_ID}
- TelegramUserApi__ApiHash=${TELEGRAM_API_HASH}
- TelegramUserApi__PhoneNumber=${TELEGRAM_PHONE_NUMBER}
# Session path for ApiUserClient, ensure this volume is mapped if used by multiple services or make path unique per service
- TelegramUserApi__SessionPath=/app/sessions/telegram_user_webapi.session
# --- CryptoPay ---
- CryptoPay__ApiToken=${CRYPTO_PAY_API_TOKEN}
# --- General Settings ---
- ASPNETCORE_ENVIRONMENT=Production
- DOTNET_ENVIRONMENT=Production # General .NET environment variable
volumes:
- telegram_session_data:/app/sessions # For ApiUserClient session files
- log_data_webapi:/app/logs # Specific logs for WebAPI
depends_on:
postgres-db:
condition: service_healthy # Wait for postgres to be healthy
redis:
condition: service_started # Redis doesn't have a healthcheck in this config, so wait for start
restart: unless-stopped
networks:
- forex-bot-network
################################################
# TelegramPanel Service (Bot Interaction Logic)
################################################
telegram-panel:
build:
context: .
dockerfile: TelegramPanel/Dockerfile
container_name: telegram-panel-service
environment:
# --- Database Connection (Using PostgreSQL) ---
- ConnectionStrings__DefaultConnection=Host=postgres-db;Port=5432;Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD};Include Error Detail=true
# --- Redis Connection ---
- ConnectionStrings__Redis=redis:6379,abortConnect=false
# --- Telegram Panel Specific Settings ---
- TelegramPanel__BotToken=${TELEGRAM_BOT_TOKEN} # Crucial for the bot to operate
- TelegramPanel__AdminUserIds=${TELEGRAM_ADMIN_IDS}
# Add any other specific settings TelegramPanel needs from appsettings or .env
# --- Telegram User API (if ApiUserClient is used directly by TelegramPanel) ---
- TelegramUserApi__ApiId=${TELEGRAM_API_ID}
- TelegramUserApi__ApiHash=${TELEGRAM_API_HASH}
- TelegramUserApi__PhoneNumber=${TELEGRAM_PHONE_NUMBER}
- TelegramUserApi__SessionPath=/app/sessions/telegram_user_panel.session # Unique session path
# --- General Settings ---
- ASPNETCORE_ENVIRONMENT=Production # If it's an ASP.NET Core app for webhooks
- DOTNET_ENVIRONMENT=Production
- ASPNETCORE_URLS=http://+:80 # If it hosts a webhook endpoint
volumes:
- telegram_session_data:/app/sessions # Shared or unique path for ApiUserClient session
- log_data_telegrampanel:/app/logs # Specific logs for TelegramPanel
depends_on:
postgres-db:
condition: service_healthy
redis:
condition: service_started
forex-trading-bot-app: # May depend on WebAPI for certain functionalities
condition: service_healthy
restart: unless-stopped
networks:
- forex-bot-network
# Ports: If TelegramPanel uses webhooks, it needs a port exposed.
# Example: - "8081:80" # Ensure this doesn't conflict with other services if mapped to host
####################################################
# BackgroundTasks Service (Scheduled/Worker Tasks)
####################################################
background-tasks:
build:
context: .
dockerfile: BackgroundTasks/Dockerfile
container_name: background-tasks-service
environment:
# --- Database Connection (Using PostgreSQL) ---
- ConnectionStrings__DefaultConnection=Host=postgres-db;Port=5432;Database=${POSTGRES_DB};Username=${POSTGRES_USER};Password=${POSTGRES_PASSWORD};Include Error Detail=true
# --- Redis Connection (e.g., for Hangfire if it uses Redis) ---
- ConnectionStrings__Redis=redis:6379,abortConnect=false
# --- Telegram Settings (if it needs to send notifications or use ApiUserClient) ---
- TelegramPanel__BotToken=${TELEGRAM_BOT_TOKEN}
- TelegramUserApi__ApiId=${TELEGRAM_API_ID}
- TelegramUserApi__ApiHash=${TELEGRAM_API_HASH}
- TelegramUserApi__PhoneNumber=${TELEGRAM_PHONE_NUMBER}
- TelegramUserApi__SessionPath=/app/sessions/telegram_user_background.session # Unique session path
# --- General Settings ---
- DOTNET_ENVIRONMENT=Production
# ASPNETCORE_ENVIRONMENT might not be relevant if not an ASP.NET host
volumes:
- telegram_session_data:/app/sessions # Shared or unique path for ApiUserClient session
- log_data_backgroundtasks:/app/logs # Specific logs for BackgroundTasks
depends_on:
postgres-db:
condition: service_healthy
redis:
condition: service_started
forex-trading-bot-app: # May depend on WebAPI for data or coordination
condition: service_healthy
restart: unless-stopped
networks:
- forex-bot-network
###################################
# SQL Server Database Service (Commented out - Replaced by PostgreSQL)
###################################
# db:
# image: "mcr.microsoft.com/mssql/server:2022-latest"
# container_name: sql-server-db
# environment:
# - ACCEPT_EULA=Y
# - SA_PASSWORD=${DB_SA_PASSWORD}
# volumes:
# - sqlserver_data:/var/opt/mssql
# networks:
# - forex-bot-network
###################################
# Redis Cache Service
###################################
redis:
image: redis:7-alpine
container_name: redis-cache
restart: always
volumes:
- redis_data:/data
networks:
- forex-bot-network
# ✅✅ THIS IS THE FIX ✅✅
# Map port 6379 on your Windows machine (the host) to port 6379 inside the container.
ports:
- "6379:6379"
#######################################
# ✅✅ NEW: PostgreSQL Database Service ✅✅
#######################################
postgres-db:
image: postgres:15-alpine # Use a specific, recent, and lightweight version
container_name: postgres-db
restart: always
environment:
# These variables are read from your .env file
- POSTGRES_USER=${POSTGRES_USER}
- POSTGRES_PASSWORD=${POSTGRES_PASSWORD}
- POSTGRES_DB=${POSTGRES_DB}
volumes:
# This persists the PostgreSQL data, so you don't lose it on restart
- postgres_data:/var/lib/postgresql/data
networks:
- forex-bot-network
ports:
# Optional: Expose the port to your Windows machine for tools like DBeaver or pgAdmin
- "5432:5432"
healthcheck:
# This command checks if the database is ready to accept connections
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"]
interval: 10s
timeout: 5s
retries: 5
# --- Docker Network ---
networks:
forex-bot-network:
driver: bridge
# --- Docker Volumes ---
volumes:
# sqlserver_data: # SQL Server volume, commented out as the service is.
telegram_session_data: # For ApiUserClient session files, shared or mounted per service
postgres_data: # For PostgreSQL data persistence
log_data_webapi: # Logs for WebAPI service
log_data_telegrampanel: # Logs for TelegramPanel service
log_data_backgroundtasks: # Logs for BackgroundTasks service
redis_data: # For Redis data persistence