From fe1c068397d44f634db57f3de6a22bd3b1607da3 Mon Sep 17 00:00:00 2001 From: "Martin C. Richards" Date: Mon, 25 May 2026 08:50:49 +0200 Subject: [PATCH] fix: automate TWS version extraction for release tags - Extract version from installed twslaunch jar during Docker build - Save version to .tws-version inside image and read back during make build - Update Makefile to use deferred expansion so VERSION resolves after build - Remove stale 335MB install-ibgateway.sh from repo root (downloaded fresh in Dockerfile) - Add .tws-version to .gitignore - Rename DOCKER_TOKEN to DOCKER_HUB_TOKEN in GitHub workflow --- .github/workflows/docker.yml | 2 +- .gitignore | 1 + Dockerfile | 11 ++++++----- Makefile | 5 ++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6429d48..6a35100 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -34,7 +34,7 @@ jobs: uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_TOKEN }} + password: ${{ secrets.DOCKER_HUB_TOKEN }} - name: Extract version from tag id: version diff --git a/.gitignore b/.gitignore index 4c49bd7..f3879f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .env +.tws-version diff --git a/Dockerfile b/Dockerfile index fe6a33c..ed9d88b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,8 @@ WORKDIR /home/docker USER docker COPY --from=builder /root/install-ibgateway.sh install-ibgateway.sh -RUN printf "/home/docker/Jts/1030\nn" | ./install-ibgateway.sh +RUN printf "/home/docker/Jts/tws\nn" | ./install-ibgateway.sh \ + && ls /home/docker/Jts/tws/jars/twslaunch-*.jar | grep -oE '[0-9]+' | head -1 > /home/docker/.tws-version RUN mkdir .vnc \ && x11vnc -storepasswd password .vnc/passwd @@ -48,10 +49,10 @@ COPY --from=builder /opt/ibc /opt/ibc COPY --from=builder /root/run.sh run.sh COPY ibc_config.ini ibc/config.ini -ENV DISPLAY :0 -ENV TRADING_MODE paper -ENV TWS_PORT 4002 -ENV VNC_PORT 5900 +ENV DISPLAY=:0 +ENV TRADING_MODE=paper +ENV TWS_PORT=4002 +ENV VNC_PORT=5900 EXPOSE $TWS_PORT EXPOSE $VNC_PORT diff --git a/Makefile b/Makefile index 174a45b..7514e21 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,13 @@ -VERSION := v$(shell grep -o 'Jts/[0-9]*' Dockerfile | cut -d'/' -f2)-ibc$(shell grep -o 'IBCLinux-[0-9.]*' Dockerfile | sed 's/IBCLinux-//' | sed 's/\.$$//') +TWS_VERSION = $(shell cat .tws-version 2>/dev/null) +IBC_VERSION = $(shell grep -o 'IBCLinux-[0-9.]*' Dockerfile | sed 's/IBCLinux-//' | sed 's/\.$$//') +VERSION = v$(TWS_VERSION)-ibc$(IBC_VERSION) vnc: up open vnc://localhost:5900 build: docker-compose build ib-gateway + @docker run --rm martinffx/ib-gateway-docker cat /home/docker/.tws-version > .tws-version up: docker-compose up -d ib-gateway