forked from manhinhang/ib-gateway-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDockerfile
More file actions
91 lines (76 loc) · 2.39 KB
/
Copy pathDockerfile
File metadata and controls
91 lines (76 loc) · 2.39 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
FROM python:3.11
# FROM arm64v8/python
ARG IBG_VERSION=stable
ENV IBG_VERSION=${IBG_VERSION:-stable}
ENV IBC_VERSION=3.18.0
ENV IBC_VERSION_FIX=-Update.1
ENV IB_INSYNC_VERSION=0.9.72
RUN echo building IB GW ${IBG_VERSION}
# install dependencies
RUN apt update && apt install -y --no-install-recommends \
wget \
unzip \
xvfb \
libxtst6 \
libxrender1 \
build-essential \
net-tools \
x11-utils \
socat \
expect \
procps \
xterm \
x11vnc
RUN apt install -y openjdk-17-jre
RUN pip install --upgrade pip
RUN pip install ib_insync==${IB_INSYNC_VERSION} 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 \
ibAccMaxRetryCount=30
# make dirs
RUN mkdir -p /tmp && mkdir -p ${ibcPath} && mkdir -p ${twsPath}
# download & install IBC
RUN wget -q -O /tmp/IBC.zip https://github.com/IbcAlpha/IBC/releases/download/${IBC_VERSION}${IBC_VERSION_FIX}/IBCLinux-${IBC_VERSION}.zip
RUN unzip /tmp/IBC.zip -d ${ibcPath}
RUN chmod +x ${ibcPath}/*.sh ${ibcPath}/*/*.sh
# remove downloaded files
RUN rm /tmp/IBC.zip
# download IB GW
RUN wget -q -O /tmp/ibgw.sh https://download2.interactivebrokers.com/installers/ibgateway/${IBG_VERSION}-standalone/ibgateway-${IBG_VERSION}-standalone-linux-x64.sh
RUN chmod +x /tmp/ibgw.sh
# install IB Gateway, write output to file so that we can parse the 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
# 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/*.py /root/
RUN chmod +x /root/*.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 20
ENV IBGW_WATCHDOG_APP_STARTUP_TIME 60
ENV IBGW_WATCHDOG_APP_TIMEOUT 20
ENV IBGW_WATCHDOG_RETRY_DELAY 5
ENV IBGW_WATCHDOG_PROBE_TIMEOUT 10
# EXPOSE $IBGW_PORT/tcp
EXPOSE 4002/tcp
EXPOSE 5900/tcp
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=5 \
CMD python healthcheck.py || exit 1
ENTRYPOINT [ "sh", "/root/cmd.sh" ]