Skip to content

Commit a847a18

Browse files
authored
Merge pull request #2 from petercool/iss-1
[Iss-1][Feature] Implement containerisation of ib-cp-gateway
2 parents b889055 + b36f360 commit a847a18

18 files changed

+31741
-0
lines changed

.github/workflows/docker-ci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
name: Docker CI
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
docker:
10+
runs-on: ubuntu-latest
11+
environment: release
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
16+
- name: Docker meta
17+
id: meta
18+
uses: docker/metadata-action@v5
19+
with:
20+
images: |
21+
${{ secrets.DOCKER_HUB_USERNAME }}/ib-gateway
22+
tags: |
23+
type=semver,pattern={{version}}
24+
type=semver,pattern={{major}}.{{minor}}
25+
26+
- name: Set up Docker Buildx
27+
uses: docker/setup-buildx-action@v3
28+
29+
- name: Login to Docker Hub
30+
uses: docker/login-action@v3
31+
with:
32+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
33+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
34+
35+
- name: Build and push
36+
uses: docker/build-push-action@v5
37+
with:
38+
context: .
39+
push: true
40+
tags: ${{ steps.meta.outputs.tags }}
41+
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/release-pleases.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Release Please
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
12+
jobs:
13+
release-please:
14+
runs-on: ubuntu-latest
15+
environment: release
16+
steps:
17+
- uses: google-github-actions/release-please-action@v3
18+
with:
19+
release-type: node
20+
package-name: ib-gateway
21+
token: ${{ secrets.RELEASE_GITHUB_TOKEN }}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,8 @@
2222
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
2323
hs_err_pid*
2424
replay_pid*
25+
26+
.idea/
27+
.vscode/
28+
.DS_Store
29+
.aider*

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM openjdk:8-jdk
2+
3+
WORKDIR /app
4+
5+
# Copy the entire ib_cp_gateway directory
6+
COPY ib_cp_gateway/ .
7+
8+
# Make the run script executable
9+
RUN chmod +x bin/run.sh
10+
11+
# Expose port 8000
12+
EXPOSE 8000
13+
14+
# Set the entrypoint
15+
ENTRYPOINT ["./bin/run.sh", "./root/conf.yaml"]

compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: '3.8'
2+
3+
services:
4+
ib-gateway:
5+
build:
6+
context: .
7+
dockerfile: Dockerfile
8+
ports:
9+
- "8000:8000"
10+
volumes:
11+
- ./ib_cp_gateway/root:/app/root

ib_cp_gateway/bin/run.bat

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@echo off
2+
3+
rem example setting a JAVA_HOME and adding to PATH
4+
#set JAVA_HOME=c:\jdk
5+
#set PATH=%JAVA_HOME%\bin;%PATH%
6+
7+
if exist %1 goto FOUND_CONF
8+
echo "usage: %0 /path/to/conf.yaml"
9+
goto END
10+
11+
:FOUND_CONF
12+
set config_file=%1
13+
for /F %%i in ("%config_file%") do set config_path=%%~dpi
14+
echo "config path :%config_path%"
15+
16+
set RUNTIME_PATH="%config_path%;dist\ibgroup.web.core.iblink.router.clientportal.gw.jar;build\lib\runtime\*"
17+
18+
echo "running %verticle% "
19+
echo "runtime path : %RUNTIME_PATH%"
20+
21+
java -server -Dvertx.disableDnsResolver=true -Djava.net.preferIPv4Stack=true -Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory -Dnologback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener -Dnolog4j.debug=true -Dnolog4j2.debug=true -classpath %RUNTIME_PATH% ibgroup.web.core.clientportal.gw.GatewayStart
22+
rem optional arguments
23+
rem -conf conf.beta.yaml --nossl
24+
25+
:END

ib_cp_gateway/bin/run.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# example setting a JAVA_HOME and adding to PATH
4+
#export JAVA_HOME=/usr/local/jdk1.8_x64/
5+
#export PATH=$JAVA_HOME/bin:$PATH
6+
7+
if [ $# -lt 1 ]; then
8+
>&2 echo "usage: $0 /path/to/conf.yaml"
9+
exit 1
10+
fi
11+
12+
config_file=$1
13+
config_path=$(dirname $1)
14+
name=$(basename $config_path)
15+
16+
export RUNTIME_PATH="$config_path:dist/ibgroup.web.core.iblink.router.clientportal.gw.jar:build/lib/runtime/*"
17+
18+
echo "running $verticle "
19+
echo " runtime path : $RUNTIME_PATH"
20+
echo " config file : $config_file"
21+
22+
java \
23+
-server \
24+
-Dvertx.disableDnsResolver=true \
25+
-Djava.net.preferIPv4Stack=true \
26+
-Dvertx.logger-delegate-factory-class-name=io.vertx.core.logging.SLF4JLogDelegateFactory \
27+
-Dnologback.statusListenerClass=ch.qos.logback.core.status.OnConsoleStatusListener \
28+
-Dnolog4j.debug=true \
29+
-Dnolog4j2.debug=true \
30+
-cp "${RUNTIME_PATH}" \
31+
ibgroup.web.core.clientportal.gw.GatewayStart \
32+
--conf ../$config_file \

ib_cp_gateway/doc/GettingStarted.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Getting Started
2+
3+
The Client Portal gateway is available for download at: [http://download2.interactivebrokers.com/portal/clientportal.gw.zip](http://download2.interactivebrokers.com/portal/clientportal.gw.zip)
4+
5+
You can download and extract to any location your user has access to. We will install it under
6+
7+
C:\gateway\ in Windows or ~user\gateway in Linux.
8+
9+
The gateway requires Java 1.8 update 192 or higher to run, and has been tested successfully with OpenJDK 11.
10+
11+
Oracle Java 8 download: [https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html](https://www.oracle.com/technetwork/java/javase/downloads/jre8-downloads-2133155.html)
12+
13+
Once you extract the .zip file, you will see the following directories:
14+
15+
- **bin** contains the run scripts for Linux and Windows
16+
17+
- **build** contains all the 3rd party libraries required for the gateway to run
18+
19+
- **dist** contains the .jar file for the gateway
20+
21+
- **doc** contains this GettingStarted.md guide
22+
23+
- **root** contains files required for the runtime configuration of the gateway and is also the location where webapps reside. We will explain those in more detail later.
24+
25+
To start the gateway you need to open a command prompt or bash on the directory the files were extracted. In our case we will open windows -> run -> cmd and go to c:\gateway\.
26+
27+
Once in that directory you can run *"bin\run.sh root/conf.yaml"* or *"bin\run.bat root\conf.yaml"*
28+
29+
Once the gateway is running, you should see the following entry in the console:
30+
"Server listening on port 5000"
31+
By default the gateway runs in SSL mode and port 5000.
32+
33+
Now that the gateway is running, you are ready to authenticate, to do that open your browser and go to:
34+
[https://localhost:5000/](https://localhost:5000/)
35+
36+
In this page you should see our regular login page which is also visible here:
37+
[https://gdcdyn.interactivebrokers.com/sso/Login?forwardTo=22](https://gdcdyn.interactivebrokers.com/sso/Login?forwardTo=22)
38+
39+
Once you login, the gateway will confirm the client is authenticated and is ok to close the browser window. Or will display any reasons why the authentication may have failed.
40+
41+
Once the gateway is authenticated you can close the browser or navigate away.
42+
43+
From this point on, the end points documented in the API spec should be available for you to query with curl or any other HTTP client.
44+
45+
[https://gdcdyn.interactivebrokers.com/portal.proxy/v1/portal/swagger/swagger?format=yaml](https://gdcdyn.interactivebrokers.com/portal.proxy/v1/portal/swagger/swagger?format=yaml)
46+
47+
[https://rebilly.github.io/ReDoc/?url=https://rebilly.github.io/ReDoc/?url=https://gdcdyn.interactivebrokers.com/portal.proxy/v1/portal/swagger/swagger?format=yaml](https://rebilly.github.io/ReDoc/?url=https://rebilly.github.io/ReDoc/?url=https://gdcdyn.interactivebrokers.com/portal.proxy/v1/portal/swagger/swagger?format=yaml)
48+
49+
There is an external Client Portal API guide with test pages at: [https://interactivebrokers.github.io/cpwebapi](https://interactivebrokers.github.io/cpwebapi)
50+

0 commit comments

Comments
 (0)