Skip to content

Commit

Permalink
update dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
manhinhang committed Apr 20, 2024
1 parent 07c6185 commit 56cac38
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
26 changes: 22 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ARG IBC_ASSET_URL="https://github.com/IbcAlpha/IBC/releases/download/3.18.0-Upda
ARG IB_GATEWAY_MAJOR="10"
ARG IB_GATEWAY_MINOR="19"

USER root

# install dependencies
RUN apt-get update \
&& apt-get upgrade -y \
Expand Down Expand Up @@ -51,9 +53,7 @@ RUN chmod +x ${IBC_PATH}/*.sh ${IBC_PATH}/*/*.sh

# install TWS, write output to file so that we can parse the TWS version number later
RUN touch $TWS_INSTALL_LOG
COPY install_ibgw.exp /tmp/install_ibgw.exp
RUN chmod +x /tmp/install_ibgw.exp
RUN /tmp/install_ibgw.exp
RUN /tmp/ibgw.sh -q -dir /root/Jts/ibgateway/${IB_GATEWAY_MAJOR}${IB_GATEWAY_MINOR}

# remove downloaded files
RUN rm /tmp/ibgw.sh /tmp/IBC.zip
Expand All @@ -72,15 +72,33 @@ COPY ibc/config.ini ${IBC_INI}

FROM ubuntu:24.04

USER root

ENV TWS_INSTALL_LOG=/root/Jts/tws_install.log
ENV IBC_INI=/root/ibc/config.ini
ENV IBC_PATH=/opt/ibc
ENV TWS_PATH=/root/Jts
ENV TWOFA_TIMEOUT_ACTION=restart
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=ibgw /javaruntime $JAVA_HOME

# RUN apt-get update \
# && apt-get upgrade -y \
# && apt-get install -y \
# xvfb \
# libxtst6 \
# libxrender1 \
# net-tools \
# x11-utils \
# socat \
# procps \
# xterm

RUN mkdir -p /opt/ibc
RUN mkdir -p /root/Jts
RUN mkdir -p /root/ibc

COPY --from=ibgw /javaruntime $JAVA_HOME
COPY --from=dependencies / /
COPY --from=ibgw /opt/ibc /opt/ibc
COPY --from=ibgw /root/Jts /root/Jts
Expand Down
28 changes: 23 additions & 5 deletions Dockerfile.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ ARG IBC_ASSET_URL="###IBC_ASSET_URL###"
ARG IB_GATEWAY_MAJOR="###IB_GATEWAY_MAJOR###"
ARG IB_GATEWAY_MINOR="###IB_GATEWAY_MINOR###"

USER root

# install dependencies
RUN apt-get update \
&& apt-get upgrade -y \
Expand Down Expand Up @@ -51,9 +53,7 @@ RUN chmod +x ${IBC_PATH}/*.sh ${IBC_PATH}/*/*.sh

# install TWS, write output to file so that we can parse the TWS version number later
RUN touch $TWS_INSTALL_LOG
COPY install_ibgw.exp /tmp/install_ibgw.exp
RUN chmod +x /tmp/install_ibgw.exp
RUN /tmp/install_ibgw.exp
RUN /tmp/ibgw.sh -q -dir /root/Jts/ibgateway/${IB_GATEWAY_MAJOR}${IB_GATEWAY_MINOR}

# remove downloaded files
RUN rm /tmp/ibgw.sh /tmp/IBC.zip
Expand All @@ -72,18 +72,37 @@ COPY ibc/config.ini ${IBC_INI}

FROM ubuntu:24.04

USER root

ENV TWS_INSTALL_LOG=/root/Jts/tws_install.log
ENV IBC_INI=/root/ibc/config.ini
ENV IBC_PATH=/opt/ibc
ENV TWS_PATH=/root/Jts
ENV TWOFA_TIMEOUT_ACTION=restart
ENV JAVA_HOME=/opt/java/openjdk
ENV PATH "${JAVA_HOME}/bin:${PATH}"
COPY --from=ibgw /javaruntime $JAVA_HOME

# RUN apt-get update \
# && apt-get upgrade -y \
# && apt-get install -y \
# xvfb \
# libxtst6 \
# libxrender1 \
# net-tools \
# x11-utils \
# socat \
# procps \
# xterm

RUN mkdir -p /opt/ibc
RUN mkdir -p /root/Jts
RUN mkdir -p /root/ibc

COPY --from=ibgw /javaruntime $JAVA_HOME
COPY --from=dependencies / /
COPY --from=ibgw /opt/ibc /opt/ibc
COPY --from=ibgw /root/Jts /root/Jts
COPY --from=ibgw /root/ibc /root/ibc

# install healthcheck tool
ADD healthcheck/healthcheck/build/distributions/healthcheck.tar /
Expand All @@ -102,4 +121,3 @@ ENV IBGW_PORT 4002
EXPOSE $IBGW_PORT

ENTRYPOINT [ "sh", "/root/start.sh" ]

1 change: 1 addition & 0 deletions start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ trap 'cleanup' INT TERM
echo "IB gateway starting..."

${IBC_PATH}/scripts/ibcstart.sh "1019" -g \
"--java-path=${JAVA_HOME}/bin" \
"--tws-path=${TWS_PATH}" \
"--ibc-path=${IBC_PATH}" "--ibc-ini=${IBC_INI}" \
"--user=${IB_ACCOUNT}" "--pw=${IB_PASSWORD}" "--mode=${TRADING_MODE}" \
Expand Down

0 comments on commit 56cac38

Please sign in to comment.