forked from manhinhang/ib-gateway-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDockerfile
79 lines (65 loc) · 2.04 KB
/
Dockerfile
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
FROM python:3.7-slim
# install dependencies
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y wget \
unzip \
xvfb \
libxtst6 \
libxrender1 \
build-essential \
net-tools \
x11-utils \
socat \
expect \
procps \
xterm
RUN apt install -y openjdk-17-jre
RUN pip install ib_insync==0.9.71 google-cloud-secret-manager==2.11.1
# set environment variables
ENV TWS_INSTALL_LOG=/root/Jts/tws_install.log \
ibcIni=/root/ibc/config.ini \
ibcPath=/opt/ibc \
javaPath=/opt/i4j_jres \
twsPath=/root/Jts \
twsSettingsPath=/root/Jts \
IB_GATEWAY_PING_CLIENT_ID=1 \
ibAccMaxRetryCount=30
# make dirs
RUN mkdir -p /tmp && mkdir -p ${ibcPath} && mkdir -p ${twsPath}
# download IB TWS
RUN wget -q -O /tmp/ibgw.sh https://download2.interactivebrokers.com/installers/ibgateway/stable-standalone/ibgateway-stable-standalone-linux-x64.sh
RUN chmod +x /tmp/ibgw.sh
# download IBC
RUN wget -q -O /tmp/IBC.zip https://github.com/IbcAlpha/IBC/releases/download/3.14.0/IBCLinux-3.14.0.zip
RUN unzip /tmp/IBC.zip -d ${ibcPath}
RUN chmod +x ${ibcPath}/*.sh ${ibcPath}/*/*.sh
# install TWS, write output to file so that we can parse the TWS version number later
COPY install_ibgw.exp /tmp/install_ibgw.exp
RUN chmod +x /tmp/install_ibgw.exp
RUN /tmp/install_ibgw.exp
# remove downloaded files
RUN rm /tmp/ibgw.sh /tmp/IBC.zip
# copy IBC/Jts configs
COPY ibc/config.ini ${ibcIni}
COPY ibc/jts.ini ${twsPath}/jts.ini
# copy cmd script
WORKDIR /root
COPY cmd.sh /root/cmd.sh
RUN chmod +x /root/cmd.sh
# python script for /root directory
COPY src/bootstrap.py /root/bootstrap.py
RUN chmod +x /root/bootstrap.py
COPY src/ib_account.py /root/ib_account.py
RUN chmod +x /root/ib_account.py
# set display environment variable (must be set after TWS installation)
ENV DISPLAY=:0
ENV GCP_SECRET=False
ENV IBGW_PORT 4002
ENV IBGW_WATCHDOG_CONNECT_TIMEOUT 30
ENV IBGW_WATCHDOG_APP_STARTUP_TIME 30
ENV IBGW_WATCHDOG_APP_TIMEOUT 30
ENV IBGW_WATCHDOG_RETRY_DELAY 2
ENV IBGW_WATCHDOG_PROBE_TIMEOUT 4
EXPOSE $IBGW_PORT
ENTRYPOINT [ "sh", "/root/cmd.sh" ]