1-
2- #
1+ ##############################################################################
32# Setup Stage: install apps
43#
54# This is a dedicated stage so that donwload archives don't end up on
65# production image and consume unnecessary space.
7- #
6+ ##############################################################################
87
98FROM ubuntu:22.04 as setup
109
@@ -20,6 +19,8 @@ RUN apt-get update -y && \
2019 curl \
2120 ca-certificates \
2221 unzip && \
22+ apt-get clean && \
23+ rm -rf /var/lib/apt/lists/* && \
2324# Install IB Gateway
2425# Use this instead of "RUN curl .." to install a local file:
2526#COPY ibgateway-${IB_GATEWAY_VERSION}-standalone-linux-x64.sh .
@@ -41,36 +42,44 @@ COPY ./config/ibc/config.ini.tmpl /root/ibc/config.ini.tmpl
4142# Copy scripts
4243COPY ./scripts /root/scripts
4344
44- #
45+ ##############################################################################
4546# Build Stage: build production image
46- #
47+ ##############################################################################
4748
4849FROM ubuntu:22.04
4950
5051ENV IB_GATEWAY_VERSION=$VERSION
51-
52- WORKDIR /root
52+ # IB Gateway user constants
53+ ARG USER_ID="${USER_ID:-1000}"
54+ ARG USER_GID="${USER_GID:-1000}"
55+ # IBC env vars
56+ ENV TWS_MAJOR_VRSN=${IB_GATEWAY_VERSION}
57+ ENV TWS_PATH=/home/ibgateway/Jts
58+ ENV TWS_INI=jts.ini
59+ ENV IBC_PATH=/home/ibgateway/ibc
60+ ENV IBC_INI=/home/ibgateway/ibc/config.ini
61+ # Copy files
5362COPY --from=setup /usr/local/i4j_jres/ /usr/local/i4j_jres
63+ COPY --chown=${USER_ID}:${USER_GID} --from=setup /root/ /home/ibgateway/
5464
5565# Prepare system
5666RUN apt-get update -y && \
57- apt-get install --no-install-recommends --yes \
58- gettext-base \
59- socat \
60- xvfb \
61- x11vnc \
62- && rm -rf /var/lib/apt/lists/*
63-
64- # Copy files
65- COPY --from=setup /root/ .
66- RUN chmod a+x /root/scripts/*.sh
67+ DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends --yes \
68+ gettext-base socat xvfb x11vnc sshpass openssh-client && \
69+ apt-get clean && \
70+ rm -rf /var/lib/apt/lists/* && \
71+ groupadd --gid ${USER_GID} ibgateway && \
72+ useradd -ms /bin/bash --uid ${USER_ID} --gid ${USER_GID} ibgateway && \
73+ chmod a+x /home/ibgateway/scripts/*.sh
6774
68- # IBC env vars
69- ENV TWS_MAJOR_VRSN ${IB_GATEWAY_VERSION}
70- ENV TWS_PATH /root/Jts
71- ENV TWS_INI jts.ini
72- ENV IBC_PATH /root/ibc
73- ENV IBC_INI /root/ibc/config.ini
75+ USER ${USER_ID}:${USER_GID}
76+ WORKDIR /home/ibgateway/
7477
7578# Start run script
76- CMD ["/root/scripts/run.sh"]
79+ CMD ["/home/ibgateway/scripts/run.sh"]
80+
81+ LABEL org.opencontainers.image.source=https://github.com/gnzsnz/ib-gateway-docker
82+ LABEL org.opencontainers.image.url=https://github.com/gnzsnz/ib-gateway-docker/pkgs/container/ib-gateway
83+ LABEL org.opencontainers.image.description="Docker image with IB Gateway and IBC "
84+ LABEL org.opencontainers.image.licenses="Apache License Version 2.0"
85+ LABEL org.opencontainers.image.version=${IB_GATEWAY_VERSION}-${IB_GATEWAY_RELEASE_CHANNEL}
0 commit comments