File tree Expand file tree Collapse file tree 6 files changed +104
-0
lines changed Expand file tree Collapse file tree 6 files changed +104
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Database configuration
2
+ DB_PASSWORD = your_secure_password
3
+
4
+ # Host machine connection for IB Gateway
5
+ HOST_IP = 127.0.0.1
6
+ IB_PORT = 4001
7
+ IB_CLIENT_ID = 1
Original file line number Diff line number Diff line change
1
+ FROM ubuntu:22.04 as builder
2
+
3
+ # Install build dependencies
4
+ RUN apt-get update && apt-get install -y \
5
+ build-essential \
6
+ cmake \
7
+ libboost-all-dev \
8
+ libpq-dev \
9
+ git \
10
+ && rm -rf /var/lib/apt/lists/*
11
+
12
+ # Copy source code
13
+ WORKDIR /build
14
+ COPY . .
15
+
16
+ # Configure with performance flags
17
+ RUN mkdir -p build && cd build && \
18
+ cmake -DCMAKE_BUILD_TYPE=Release \
19
+ -DCMAKE_CXX_FLAGS="-O3 -march=native -ffast-math -flto" ..
20
+
21
+ # Compile with all cores
22
+ RUN cd build && make -j$(nproc)
23
+
24
+ # Create minimal runtime image
25
+ FROM ubuntu:22.04
26
+
27
+ # Install only runtime dependencies
28
+ RUN apt-get update && apt-get install -y \
29
+ libboost-system1.74.0 \
30
+ libboost-thread1.74.0 \
31
+ libpq5 \
32
+ postgresql-client \
33
+ && rm -rf /var/lib/apt/lists/*
34
+
35
+ # Copy the compiled application and configs
36
+ COPY --from=builder /build/build/thales /usr/local/bin/
37
+ COPY config /etc/thales/config/
38
+
39
+ # Create entrypoint script
40
+ COPY docker/entrypoint.sh /entrypoint.sh
41
+ RUN chmod +x /entrypoint.sh
42
+
43
+ ENTRYPOINT ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ # Wait for PostgreSQL to be ready
5
+ echo " Waiting for PostgreSQL..."
6
+ until PGPASSWORD=$DB_PASSWORD psql -h $DB_HOST -U $DB_USER -d $DB_NAME -c ' \q' 2> /dev/null; do
7
+ echo " PostgreSQL is unavailable - sleeping"
8
+ sleep 1
9
+ done
10
+
11
+ echo " PostgreSQL is up - starting Thales"
12
+
13
+ # Start the trading bot with optimized settings
14
+ exec /usr/local/bin/thales /etc/thales/config/config.json
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ cd " $( git rev-parse --show-toplevel) "
5
+
6
+ # Detect host IP for different platforms
7
+ if [[ " $OSTYPE " == " darwin" * ]]; then
8
+ # macOS
9
+ HOST_IP=" host.docker.internal"
10
+ elif [[ " $OSTYPE " == " msys" * || " $OSTYPE " == " cygwin" * ]]; then
11
+ # Windows
12
+ HOST_IP=" host.docker.internal"
13
+ else
14
+ # Linux
15
+ HOST_IP=$( ip route get 1 | awk ' {print $7;exit}' )
16
+ fi
17
+
18
+ # Update .env file
19
+ cd docker
20
+ sed -i.bak " s/HOST_IP=.*/HOST_IP=$HOST_IP /" .env
21
+ rm -f .env.bak 2> /dev/null || true
22
+ cd ..
23
+
24
+ # Create directories
25
+ mkdir -p logs data
26
+
27
+ echo " Starting Thales Trading Bot with host IP: $HOST_IP "
28
+ echo " Make sure IB Gateway is running on your host machine on port 4001"
29
+
30
+ # Start containers
31
+ cd docker && docker-compose up -d
32
+
33
+ echo " Containers started successfully!"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ cd " $( git rev-parse --show-toplevel) "
5
+ cd docker && docker-compose down
6
+
7
+ echo " Thales trading containers have been stopped."
You can’t perform that action at this time.
0 commit comments