From 932388ca3213c84964af88668d22ad64ee3f1494 Mon Sep 17 00:00:00 2001 From: shum Date: Sat, 10 Oct 2026 12:27:31 +0000 Subject: [PATCH] calculator bot: load libs and add-on in image --- apps/simplex-calculator-bot/README.md | 2 +- scripts/calculator-bot/Dockerfile | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/simplex-calculator-bot/README.md b/apps/simplex-calculator-bot/README.md index 028e470964..d8985700cd 100644 --- a/apps/simplex-calculator-bot/README.md +++ b/apps/simplex-calculator-bot/README.md @@ -25,7 +25,7 @@ The bot prints its address and keeps its data in `./data`. To add a SimpleX name to the address, register the name with the address short link, and run `npm start -- --domain yourname.simplex`. The name is kept when the bot starts without `--domain`. -To use the library from this repository, build it and run `npm install --no-save ../../packages/simplex-chat-nodejs` instead of `npm install`. +To use the library from this repository, build it and run `npm install --no-save ../../packages/simplex-chat-nodejs` instead of `npm install`, then start the bot with `SIMPLEX_ADDON_PATH=../../packages/simplex-chat-nodejs/build/Release/simplex.node`. ## Test diff --git a/scripts/calculator-bot/Dockerfile b/scripts/calculator-bot/Dockerfile index 6e049ec3d6..fb25c0f7df 100644 --- a/scripts/calculator-bot/Dockerfile +++ b/scripts/calculator-bot/Dockerfile @@ -66,8 +66,9 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ rm -rf /var/lib/apt/lists/* COPY --from=libsimplex /libs /opt/simplex/libs -# Without it, npm re-running the library's preinstall downloads the released libs. -ENV SIMPLEX_LIBS_DIR=/opt/simplex/libs +# The library loads libsimplex and the add-on built below instead of downloading the released ones. +ENV SIMPLEX_LIBS_DIR=/opt/simplex/libs \ + SIMPLEX_ADDON_PATH=/src/packages/simplex-chat-nodejs/build/Release/simplex.node WORKDIR /src COPY packages/simplex-chat-client/types/typescript packages/simplex-chat-client/types/typescript @@ -76,6 +77,7 @@ RUN cd packages/simplex-chat-client/types/typescript && \ npx tsc COPY packages/simplex-chat-nodejs packages/simplex-chat-nodejs +# npm install builds the add-on from binding.gyp. RUN cd packages/simplex-chat-nodejs && \ npm install --no-audit --no-fund && \ npm install --no-save --no-audit --no-fund ../simplex-chat-client/types/typescript && \ @@ -105,7 +107,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates dumb-init libffi8 libgmp10 libssl3 zlib1g && \ rm -rf /var/lib/apt/lists/* +COPY --from=build /opt/simplex/libs /opt/simplex/libs COPY --from=build --chown=node:node /src /src +ENV SIMPLEX_LIBS_DIR=/opt/simplex/libs \ + SIMPLEX_ADDON_PATH=/src/packages/simplex-chat-nodejs/build/Release/simplex.node # A named volume takes this ownership; a bind mount must be owned by uid 1000. RUN mkdir -p /src/apps/simplex-calculator-bot/data && \