-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdocker-compose.cloud.yml
More file actions
187 lines (177 loc) · 6.58 KB
/
docker-compose.cloud.yml
File metadata and controls
187 lines (177 loc) · 6.58 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
# ── Cloud / VPS Docker Compose ────────────────────────────────────────────────
# Für: Hetzner, DigitalOcean, AWS EC2, Azure VM, Google Cloud VM
#
# Unterschiede zu docker-compose.qnap.yml:
# - Mehr RAM (Bot: 2GB, Forex: 1GB)
# - PostgreSQL statt SQLite (wenn DB_BACKEND=postgres gesetzt)
# - Traefik als Reverse Proxy mit HTTPS
# - Kein QNAP-spezifischer Docker-Pfad
#
# Start:
# bash deploy-vps.sh user@your-server.com
#
# Oder manuell:
# docker compose -f docker-compose.cloud.yml up -d
#
# Voraussetzungen:
# - Docker + Docker Compose auf dem Server
# - .env + forex_bot/.env mit Credentials
# - DOMAIN=yourdomain.com in .env setzen (für HTTPS via Traefik)
# - ACME_EMAIL=your@email.com in .env setzen (Let's Encrypt)
version: "3.9"
networks:
trading_net:
driver: bridge
volumes:
postgres_data:
data_store:
logs:
forex_logs:
reports:
services:
# ── Crypto Bot ───────────────────────────────────────────────────────────────
trading-bot:
image: trading-bot:latest
container_name: crypto-bot
restart: unless-stopped
env_file: .env
environment:
- FEATURE_LSTM=${FEATURE_LSTM:-true} # GPU vorhanden → LSTM möglich
- AUTO_TRAIN=false
- DB_BACKEND=${DB_BACKEND:-sqlite}
volumes:
- data_store:/app/data_store
- logs:/app/logs
- reports:/app/reports
- ./crypto_bot/ai:/app/crypto_bot/ai
networks:
- trading_net
mem_limit: 2g
cpus: "2.0"
logging:
driver: json-file
options:
max-size: "20m"
max-file: "5"
healthcheck:
test: ["CMD", "python", "-c", "import os,time; f='logs/bot.log'; assert os.path.exists(f) and (time.time()-os.path.getmtime(f))<4200"]
interval: 5m
timeout: 10s
retries: 3
start_period: 2m
# ── Crypto Dashboard API ──────────────────────────────────────────────────────
trading-dashboard:
image: trading-bot:latest
container_name: trading-dashboard
restart: unless-stopped
env_file: .env
command: python -m uvicorn crypto_bot.dashboard.api:app --host 0.0.0.0 --port 8000
volumes:
- data_store:/app/data_store
- logs:/app/logs
- ./crypto_bot/ai:/app/crypto_bot/ai
networks:
- trading_net
mem_limit: 512m
cpus: "1.0"
labels:
- "traefik.enable=true"
- "traefik.http.routers.api.rule=Host(`${DOMAIN:-localhost}`) && PathPrefix(`/api`)"
- "traefik.http.routers.api.tls.certresolver=letsencrypt"
- "traefik.http.services.api.loadbalancer.server.port=8000"
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:8000/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 15s
# ── Forex Bot ─────────────────────────────────────────────────────────────────
forex-bot:
image: trading-bot:latest
container_name: forex-bot
restart: unless-stopped
env_file: forex_bot/.env
command: python -m forex_bot.bot
volumes:
- ./forex_bot:/app/forex_bot
- forex_logs:/app/forex_bot/logs
networks:
- trading_net
mem_limit: 1g
cpus: "1.5"
labels:
- "traefik.enable=true"
- "traefik.http.routers.forex.rule=Host(`${DOMAIN:-localhost}`) && PathPrefix(`/forex`)"
- "traefik.http.routers.forex.tls.certresolver=letsencrypt"
- "traefik.http.services.forex.loadbalancer.server.port=8001"
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:8001/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 30s
# ── Streamlit Dashboard ───────────────────────────────────────────────────────
trading-streamlit:
image: trading-streamlit:latest
container_name: trading-streamlit
restart: unless-stopped
environment:
- DASHBOARD_API_URL=http://trading-dashboard:8000
- FOREX_API_URL=http://forex-bot:8001
networks:
- trading_net
mem_limit: 1g
cpus: "1.5"
labels:
- "traefik.enable=true"
- "traefik.http.routers.dashboard.rule=Host(`${DOMAIN:-localhost}`)"
- "traefik.http.routers.dashboard.tls.certresolver=letsencrypt"
- "traefik.http.services.dashboard.loadbalancer.server.port=8501"
healthcheck:
test: ["CMD", "curl", "-sf", "http://localhost:8501/_stcore/health"]
interval: 30s
timeout: 5s
retries: 3
start_period: 20s
# ── Traefik Reverse Proxy (HTTPS) ─────────────────────────────────────────────
traefik:
image: traefik:v3.0
container_name: traefik
restart: unless-stopped
command:
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.web.http.redirections.entrypoint.to=websecure"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge=true"
- "--certificatesresolvers.letsencrypt.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.letsencrypt.acme.email=${ACME_EMAIL:-admin@example.com}"
- "--certificatesresolvers.letsencrypt.acme.storage=/letsencrypt/acme.json"
ports:
- "80:80"
- "443:443"
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
- ./data/letsencrypt:/letsencrypt
networks:
- trading_net
# ── PostgreSQL (optional, wenn DB_BACKEND=postgres) ───────────────────────────
postgres:
image: postgres:16-alpine
container_name: trading-postgres
restart: unless-stopped
profiles: ["postgres"] # nur aktiv wenn: docker compose --profile postgres up
environment:
POSTGRES_DB: trading_bot
POSTGRES_USER: ${POSTGRES_USER:-trading}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-changeme}
volumes:
- postgres_data:/var/lib/postgresql/data
networks:
- trading_net
healthcheck:
test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER:-trading}"]
interval: 30s
timeout: 5s
retries: 5