forked from gnzsnz/ib-gateway-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DockerfileGatewayGCD
108 lines (90 loc) · 4.41 KB
/
DockerfileGatewayGCD
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
##############################################################################
# Setup Stage: install apps
#
# This is a dedicated stage so that donwload archives don't end up on
# production image and consume unnecessary space.
##############################################################################
# hadolint global ignore=DL3008
FROM gcr.io/deeplearning-platform-release/workbench-container:latest AS setup
ENV IB_GATEWAY_VERSION=$VERSION
ENV IB_GATEWAY_RELEASE_CHANNEL=$CHANNEL
ENV IBC_VERSION=3.20.0
WORKDIR /tmp/setup
# Prepare system
RUN apt-get update -y && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \
curl \
ca-certificates \
unzip && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
# Install IB Gateway
# Use this instead of "RUN curl .." to install a local file:
#COPY ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh .
curl -sSOL https://github.com/gnzsnz/ib-gateway-docker/releases/download/ibgateway-${IB_GATEWAY_RELEASE_CHANNEL}%40${IB_GATEWAY_VERSION}/ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh && \
curl -sSOL https://github.com/gnzsnz/ib-gateway-docker/releases/download/ibgateway-${IB_GATEWAY_RELEASE_CHANNEL}%40${IB_GATEWAY_VERSION}/ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh.sha256 && \
sha256sum --check ./ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh.sha256 && \
chmod a+x ./ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh && \
./ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh -q -dir /root/Jts/ibgateway/${IB_GATEWAY_VERSION} &&\
# Install IBC
curl -sSOL https://github.com/IbcAlpha/IBC/releases/download/${IBC_VERSION}/IBCLinux-${IBC_VERSION}.zip && \
mkdir /root/ibc && \
unzip ./IBCLinux-${IBC_VERSION}.zip -d /root/ibc && \
chmod -R u+x /root/ibc/*.sh && \
chmod -R u+x /root/ibc/scripts/*.sh
COPY ./config/ibgateway/jts.ini.tmpl /root/Jts/jts.ini.tmpl
COPY ./config/ibc/config.ini.tmpl /root/ibc/config.ini.tmpl
# Copy scripts
COPY ./scripts /root/scripts
##############################################################################
# Build Stage: build production image
##############################################################################
FROM gcr.io/deeplearning-platform-release/workbench-container:latest
ENV IB_GATEWAY_VERSION=$VERSION
# IB Gateway user constants
ARG USER_ID="${USER_ID:-1000}"
ARG USER_GID="${USER_GID:-1000}"
# IBC env vars
ENV HOME=/home/ibgateway
ENV TWS_MAJOR_VRSN=${IB_GATEWAY_VERSION}
ENV TWS_PATH=${HOME}/Jts
ENV TWS_INI=jts.ini
ENV TWS_INI_TMPL=${TWS_INI}.tmpl
ENV IBC_PATH=${HOME}/ibc
ENV IBC_INI=${HOME}/ibc/config.ini
ENV IBC_INI_TMPL=${IBC_INI}.tmpl
ENV SCRIPT_PATH=${HOME}/scripts
ENV GATEWAY_OR_TWS=gateway
# Copy files
COPY --from=setup /usr/local/i4j_jres/ /usr/local/i4j_jres
COPY --chown=${USER_ID}:${USER_GID} --from=setup /root/ ${HOME}
COPY requirements.txt /.
# GCD https://cloud.google.com/vertex-ai/docs/workbench/instances/create-custom-container#:~:text=Vertex%20AI%20Workbench%20instances%20support,a%20Vertex%20AI%20Workbench%20instance.
ENV MAMBA_ROOT_PREFIX=/opt/micromamba
# Install mambaforge
ENV MAMBA_ROOT_PREFIX=/opt/micromamba
RUN micromamba create -n micromamba_venv -c conda-forge python=310 -y
SHELL ["micromamba", "run", "-n", "micromamba_venv", "/bin/bash", "-c"]
RUN micromamba install -c conda-forge pip -y
RUN pip install -r /requirements.txt
RUN pip install ipykernel
RUN python -m ipykernel install --prefix /opt/micromamba/envs/micromamba_venv --name micromamba_venv --display-name KERNEL_NAME
# Prepare system
RUN apt-get update -y && \
apt-get upgrade -y && \
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \
gettext-base socat xvfb x11vnc sshpass openssh-client && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* && \
groupadd --gid ${USER_GID} ibgateway && \
useradd -ms /bin/bash --uid ${USER_ID} --gid ${USER_GID} ibgateway && \
chmod a+x ${SCRIPT_PATH}/*.sh
USER ${USER_ID}:${USER_GID}
WORKDIR ${HOME}
# Start run script
CMD ["/home/ibgateway/scripts/run.sh"]
LABEL org.opencontainers.image.source=https://github.com/gnzsnz/ib-gateway-docker
LABEL org.opencontainers.image.url=https://github.com/gnzsnz/ib-gateway-docker/pkgs/container/ib-gateway
LABEL org.opencontainers.image.description="Docker image with IB Gateway and IBC "
LABEL org.opencontainers.image.licenses="Apache License Version 2.0"
LABEL org.opencontainers.image.version=${IB_GATEWAY_VERSION}-${IB_GATEWAY_RELEASE_CHANNEL}