From 2c0d12ea0d721d8c2e413ef7307c3089bcb5df67 Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Wed, 24 Apr 2024 22:09:21 +0800 Subject: [PATCH 01/11] ci: allow to publish to github package (#99) * ci: allow to publish to github package * ci: remove workflow file --- .../{deploy-dockerhub.yml => deploy.yml} | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) rename .github/workflows/{deploy-dockerhub.yml => deploy.yml} (51%) diff --git a/.github/workflows/deploy-dockerhub.yml b/.github/workflows/deploy.yml similarity index 51% rename from .github/workflows/deploy-dockerhub.yml rename to .github/workflows/deploy.yml index 870604c..2b56d9b 100644 --- a/.github/workflows/deploy-dockerhub.yml +++ b/.github/workflows/deploy.yml @@ -1,4 +1,4 @@ -name: Deploy to docker hub +name: "Publish Docker" on: push: @@ -13,6 +13,19 @@ on: jobs: build: + strategy: + matrix: + include: + # Dockerhub + - images: manhinhang/ib-gateway-docker + username: DOCKERHUB_USERNAME + password: DOCKERHUB_PASSWORD + registry: '' + # Github + - images: ghcr.io/manhinhang/ib-gateway-docker + username: ${{ github.actor }} + password: GITHUB_TOKEN + registry: 'ghcr.io' runs-on: ubuntu-latest timeout-minutes: 20 steps: @@ -21,12 +34,13 @@ jobs: id: meta uses: docker/metadata-action@v5 with: - images: manhinhang/ib-gateway-docker + images: ${{ matrix.images }} - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + registry: ${{ matrix.registry }} + username: ${{ matrix.registry == 'ghcr.io' && matrix.username || secrets[matrix.username] }} + password: ${{ secrets[matrix.password] }} - name: Build and push uses: docker/build-push-action@v5 with: From bc8c3e14e49fd253cf5a34a152b2fa604fde5aed Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Wed, 24 Apr 2024 22:15:17 +0800 Subject: [PATCH 02/11] ci: remove setup python step --- .github/workflows/detect-new-ver.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/detect-new-ver.yml b/.github/workflows/detect-new-ver.yml index 867a14e..8dde440 100644 --- a/.github/workflows/detect-new-ver.yml +++ b/.github/workflows/detect-new-ver.yml @@ -14,8 +14,6 @@ jobs: IBC_VERSION_JSON_URL: "https://api.github.com/repos/IbcAlpha/IBC/releases" steps: - uses: actions/checkout@master - - name: Setup python - uses: actions/setup-python@v5 - name: detect new ib gateway version id: check-update run: | From 6a8ac70f6b7135b4c821836afdaafb251f51f071 Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Thu, 25 Apr 2024 02:00:50 +0800 Subject: [PATCH 03/11] feat: allow to disable healthcheck api (#100) * feat: allow to disable healthcheck api * test: update tests --- Dockerfile | 1 + README.md | 3 +++ start.sh | 7 ++++++- test/test_ib_gateway.py | 25 ++++++++++++++++++++++++- test/test_ib_gateway_fail.py | 7 +++++-- 5 files changed, 39 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 155e1a7..4dbfe8b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -105,6 +105,7 @@ ENV DISPLAY=:0 ENV IBGW_PORT 4002 ENV JAVA_HEAP_SIZE 768 +ENV HEALTHCHECK_API_ENABLE=false EXPOSE $IBGW_PORT diff --git a/README.md b/README.md index 8770526..9af4d86 100644 --- a/README.md +++ b/README.md @@ -60,6 +60,8 @@ ib-gateway-docker Healthcheck via api call `http://localhost:8080/healthcheck` +Config `HEALTHCHECK_API_ENABLE=true` in environment variable to enable API + ```bash curl -f http://localhost:8080/healthcheck ``` @@ -76,6 +78,7 @@ services: - IB_ACCOUNT=$IB_ACCOUNT - IB_PASSWORD=$IB_PASSWORD - TRADING_MODE=$TRADING_MODE + - HEALTHCHECK_API_ENABLE=true healthcheck: test: ["CMD", "curl", "-f", "http://localhost:8080/healthcheck"] interval: 60s diff --git a/start.sh b/start.sh index 7602fa0..44053d4 100755 --- a/start.sh +++ b/start.sh @@ -58,7 +58,12 @@ set_java_heap() { set_java_heap # start rest api for healthcheck -healthcheck-rest >&1 & +if [ "$HEALTHCHECK_API_ENABLE" = true ] ; then + echo "starting healthcheck api..." + healthcheck-rest >&1 & +else + echo "Skip starting healthcheck api" +fi echo "detect IB gateway version: $IBGW_VERSION" diff --git a/test/test_ib_gateway.py b/test/test_ib_gateway.py index d4d36b8..2b41dfb 100644 --- a/test/test_ib_gateway.py +++ b/test/test_ib_gateway.py @@ -23,7 +23,7 @@ def test_healthcheck(): assert subprocess.check_call(['docker', 'exec', docker_id, 'healthcheck']) == 0 subprocess.check_call(['docker', 'rm', '-f', docker_id]) -def test_healthcheck_rest(): +def test_healthcheck_api(): account = os.environ['IB_ACCOUNT'] password = os.environ['IB_PASSWORD'] trading_mode = os.environ['TRADING_MODE'] @@ -34,9 +34,32 @@ def test_healthcheck_rest(): '--env', 'IB_ACCOUNT={}'.format(account), '--env', 'IB_PASSWORD={}'.format(password), '--env', 'TRADING_MODE={}'.format(trading_mode), + '--env', 'HEALTHCHECK_API_ENABLE=true', '-p', '8080:8080', '-d', IMAGE_NAME]).decode().strip() time.sleep(30) response = requests.get("http://127.0.0.1:8080/healthcheck") assert response.ok subprocess.check_call(['docker', 'rm', '-f', docker_id]) + +def test_healthcheck_api_fail(): + account = 'test' + password = 'test' + trading_mode = os.environ['TRADING_MODE'] + + # run a container + docker_id = subprocess.check_output( + ['docker', 'run', + '--env', 'IB_ACCOUNT={}'.format(account), + '--env', 'IB_PASSWORD={}'.format(password), + '--env', 'TRADING_MODE={}'.format(trading_mode), + '--env', 'HEALTHCHECK_API_ENABLE=true', + '-p', '8080:8080', + '-d', IMAGE_NAME]).decode().strip() + time.sleep(30) + try: + response = requests.get("http://127.0.0.1:8080/healthcheck") + assert not response.ok + except requests.exceptions.ConnectionError: + pass + subprocess.check_call(['docker', 'rm', '-f', docker_id]) diff --git a/test/test_ib_gateway_fail.py b/test/test_ib_gateway_fail.py index 61b622e..af4a9b3 100644 --- a/test/test_ib_gateway_fail.py +++ b/test/test_ib_gateway_fail.py @@ -63,5 +63,8 @@ def test_healthcheck_fail(host): def test_healthcheck_rest_fail(host): time.sleep(30) - response = requests.get("http://127.0.0.1:8080/healthcheck") - assert not response.ok \ No newline at end of file + try: + response = requests.get("http://127.0.0.1:8080/healthcheck") + assert False + except requests.exceptions.ConnectionError: + pass From 7e7e2b5016c387f1d7aaa7f51df175a8d4debf0f Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Sun, 28 Apr 2024 12:29:54 +0800 Subject: [PATCH 04/11] fix: typo --- .github/workflows/detect-new-ver.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/detect-new-ver.yml b/.github/workflows/detect-new-ver.yml index 8dde440..c1b4120 100644 --- a/.github/workflows/detect-new-ver.yml +++ b/.github/workflows/detect-new-ver.yml @@ -23,7 +23,7 @@ jobs: source .env if [ "$IB_GATEWAY_VER" = "$CUR_IB_GATEWAY_VER" ]; then - echo "No dated IB gateway version" + echo "No new IB gateway version available" echo has_update=false >> "$GITHUB_OUTPUT" else echo "New IB gateway version($IB_GATEWAY_VER)" @@ -31,10 +31,10 @@ jobs: fi if [ "$IBC_VER" = "$CUR_IBC_VER" ]; then - echo "No dated IBC version" + echo "No new IBC version available" echo has_update=false >> "$GITHUB_OUTPUT" else - echo "New IBC version($IBC_VER)" + echo "New IBC version($IBC_VER) available" echo has_update=true >> "$GITHUB_OUTPUT" fi echo "ib-gateway-ver=$IB_GATEWAY_VER" >> "$GITHUB_OUTPUT" From 842f6fc50a8779691d877d48c640376c0bb77357 Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Thu, 2 May 2024 16:12:53 +0800 Subject: [PATCH 05/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9af4d86..c292df3 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ docker run -d \ --env IB_ACCOUNT= \ #YOUR_USER_ID --env IB_PASSWORD= \ #YOUR_PASSWORD --env TRADING_MODE= \ #paper or live ---p 4002:4002 \ #brige IB gateway port to your local port 4002 +-p 4002:4002 \ #brige IB gateway port to your local port 4002 manhinhang/ib-gateway-docker ``` From 9b328b3c3fe2700673858848af7757bae6c908b2 Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Sat, 11 May 2024 13:29:40 +0800 Subject: [PATCH 06/11] ci: fix unable detect new ibgw version --- .github/workflows/detect-new-ver.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/detect-new-ver.yml b/.github/workflows/detect-new-ver.yml index c1b4120..f877ace 100644 --- a/.github/workflows/detect-new-ver.yml +++ b/.github/workflows/detect-new-ver.yml @@ -22,21 +22,25 @@ jobs: IBC_VER=$(curl ${IBC_VERSION_JSON_URL} | jq -r '.[0].name') source .env + HAS_UPDATE='false' if [ "$IB_GATEWAY_VER" = "$CUR_IB_GATEWAY_VER" ]; then echo "No new IB gateway version available" echo has_update=false >> "$GITHUB_OUTPUT" + HAS_UPDATE='true' else echo "New IB gateway version($IB_GATEWAY_VER)" echo has_update=true >> "$GITHUB_OUTPUT" fi - - if [ "$IBC_VER" = "$CUR_IBC_VER" ]; then + if [ "$HAS_UPDATE" = 'false' ]; then + if [ "$IBC_VER" = "$CUR_IBC_VER" ]; then echo "No new IBC version available" echo has_update=false >> "$GITHUB_OUTPUT" - else - echo "New IBC version($IBC_VER) available" - echo has_update=true >> "$GITHUB_OUTPUT" + else + echo "New IBC version($IBC_VER) available" + echo has_update=true >> "$GITHUB_OUTPUT" + fi fi + echo "ib-gateway-ver=$IB_GATEWAY_VER" >> "$GITHUB_OUTPUT" echo "ibc-ver=$IBC_VER" >> "$GITHUB_OUTPUT" - name: Update files with new version From 7c84810001d27e3f71e8b17140f189598b331463 Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Sat, 11 May 2024 13:32:22 +0800 Subject: [PATCH 07/11] ci: fix unable detect new ibgw version --- .github/workflows/detect-new-ver.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/detect-new-ver.yml b/.github/workflows/detect-new-ver.yml index f877ace..21275b6 100644 --- a/.github/workflows/detect-new-ver.yml +++ b/.github/workflows/detect-new-ver.yml @@ -26,10 +26,10 @@ jobs: if [ "$IB_GATEWAY_VER" = "$CUR_IB_GATEWAY_VER" ]; then echo "No new IB gateway version available" echo has_update=false >> "$GITHUB_OUTPUT" - HAS_UPDATE='true' else echo "New IB gateway version($IB_GATEWAY_VER)" echo has_update=true >> "$GITHUB_OUTPUT" + HAS_UPDATE='true' fi if [ "$HAS_UPDATE" = 'false' ]; then if [ "$IBC_VER" = "$CUR_IBC_VER" ]; then From c9202093a4d8a88a01d52a3ea7817aaa9cbfa5ad Mon Sep 17 00:00:00 2001 From: github-actions Date: Sat, 11 May 2024 06:13:20 +0000 Subject: [PATCH 08/11] Update to `10.19.2m` --- .env | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env b/.env index d6b889c..61e1edb 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -CUR_IB_GATEWAY_VER=10.19.2l +CUR_IB_GATEWAY_VER=10.19.2m CUR_IBC_VER=3.18.0 diff --git a/README.md b/README.md index c292df3..e6a4db6 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It's just pure `IB Gateway` and don't include any VNC service (for security reas This docker image just installed: -- [IB Gateway](https://www.interactivebrokers.com/en/index.php?f=16457) (10.19.2l) +- [IB Gateway](10.19.2m) (10.19.2l) - [IBC](https://github.com/IbcAlpha/IBC) (3.18.0) From 4b496e6d4ab26fb64950122169ffef4f0b42a9c1 Mon Sep 17 00:00:00 2001 From: Andrew <39019063+manhinhang@users.noreply.github.com> Date: Sat, 11 May 2024 18:05:52 +0800 Subject: [PATCH 09/11] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6a4db6..1f6d0ed 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It's just pure `IB Gateway` and don't include any VNC service (for security reas This docker image just installed: -- [IB Gateway](10.19.2m) (10.19.2l) +- [IB Gateway](https://www.interactivebrokers.com/en/index.php?f=16457) (10.19.2m) - [IBC](https://github.com/IbcAlpha/IBC) (3.18.0) From 29f8b20876efcb4cd80b72c509afb2965d13cd85 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 10:19:16 +0800 Subject: [PATCH 10/11] Update to `10.19.2n` (#105) * Update to `10.19.2n` * Update README.md --------- Co-authored-by: github-actions Co-authored-by: Andrew <39019063+manhinhang@users.noreply.github.com> --- .env | 4 ++-- README.md | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.env b/.env index 61e1edb..db8ff8d 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -CUR_IB_GATEWAY_VER=10.19.2m -CUR_IBC_VER=3.18.0 +CUR_IB_GATEWAY_VER=10.19.2n +CUR_IBC_VER=3.19.0 diff --git a/README.md b/README.md index 1f6d0ed..c6d71e0 100644 --- a/README.md +++ b/README.md @@ -10,9 +10,9 @@ It's just pure `IB Gateway` and don't include any VNC service (for security reas This docker image just installed: -- [IB Gateway](https://www.interactivebrokers.com/en/index.php?f=16457) (10.19.2m) +- [IB Gateway](https://www.interactivebrokers.com/en/index.php?f=16457) (10.19.2n) -- [IBC](https://github.com/IbcAlpha/IBC) (3.18.0) +- [IBC](https://github.com/IbcAlpha/IBC) (3.19.0) ## Pull the Docker image from Docker Hub From 63156ab406307d068c7c6663c297677c18fe1c92 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 5 Jul 2024 08:48:09 +0800 Subject: [PATCH 11/11] Update to `10.19.2o` (#106) * Update to `10.19.2o` * Update README.md --------- Co-authored-by: github-actions Co-authored-by: Andrew <39019063+manhinhang@users.noreply.github.com> --- .env | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.env b/.env index db8ff8d..e8bf873 100644 --- a/.env +++ b/.env @@ -1,2 +1,2 @@ -CUR_IB_GATEWAY_VER=10.19.2n +CUR_IB_GATEWAY_VER=10.19.2o CUR_IBC_VER=3.19.0 diff --git a/README.md b/README.md index c6d71e0..e1e0e70 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It's just pure `IB Gateway` and don't include any VNC service (for security reas This docker image just installed: -- [IB Gateway](https://www.interactivebrokers.com/en/index.php?f=16457) (10.19.2n) +- [IB Gateway](https://www.interactivebrokers.com/en/index.php?f=16457) (10.19.2o) - [IBC](https://github.com/IbcAlpha/IBC) (3.19.0)