From 0cdbac5f9a3562d7015297d089cac70f642c805e Mon Sep 17 00:00:00 2001 From: peteryuqin Date: Thu, 26 Mar 2026 16:08:52 -0400 Subject: [PATCH 1/2] fix: symlink telegram state into openclaw-data --- Dockerfile | 5 ++++- test/dockerfile-telegram-state.test.js | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 test/dockerfile-telegram-state.test.js diff --git a/Dockerfile b/Dockerfile index 309ba1d8f..61171fc15 100644 --- a/Dockerfile +++ b/Dockerfile @@ -134,7 +134,10 @@ RUN openclaw doctor --fix > /dev/null 2>&1 || true \ # The writable state lives in .openclaw-data, reached via the symlinks. # hadolint ignore=DL3002 USER root -RUN chown root:root /sandbox/.openclaw \ +RUN mkdir -p /sandbox/.openclaw-data/telegram \ + && chown -R sandbox:sandbox /sandbox/.openclaw-data/telegram \ + && ln -sfn /sandbox/.openclaw-data/telegram /sandbox/.openclaw/telegram \ + && chown root:root /sandbox/.openclaw \ && find /sandbox/.openclaw -mindepth 1 -maxdepth 1 -exec chown -h root:root {} + \ && chmod 755 /sandbox/.openclaw \ && chmod 444 /sandbox/.openclaw/openclaw.json diff --git a/test/dockerfile-telegram-state.test.js b/test/dockerfile-telegram-state.test.js new file mode 100644 index 000000000..6efed6bb4 --- /dev/null +++ b/test/dockerfile-telegram-state.test.js @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 + +import { describe, it, expect } from "vitest"; +import fs from "node:fs"; +import path from "node:path"; + +const ROOT = path.resolve(import.meta.dirname, ".."); +const DOCKERFILE = fs.readFileSync(path.join(ROOT, "Dockerfile"), "utf-8"); + +describe("Dockerfile telegram state layout (#975)", () => { + it("precreates writable telegram state under .openclaw-data", () => { + expect(DOCKERFILE.includes("mkdir -p /sandbox/.openclaw-data/telegram")).toBeTruthy(); + expect(DOCKERFILE.includes("chown -R sandbox:sandbox /sandbox/.openclaw-data/telegram")).toBeTruthy(); + }); + + it("symlinks .openclaw/telegram into .openclaw-data before locking .openclaw", () => { + expect(DOCKERFILE.includes("ln -sfn /sandbox/.openclaw-data/telegram /sandbox/.openclaw/telegram")).toBeTruthy(); + }); +}); From b292eae5678a8b8c9ec92807f1617d9d405891d8 Mon Sep 17 00:00:00 2001 From: peteryuqin Date: Thu, 26 Mar 2026 19:53:18 -0400 Subject: [PATCH 2/2] Fix telegram state symlink replacement ordering --- Dockerfile | 1 + test/dockerfile-telegram-state.test.js | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 61171fc15..d25924e6f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -136,6 +136,7 @@ RUN openclaw doctor --fix > /dev/null 2>&1 || true \ USER root RUN mkdir -p /sandbox/.openclaw-data/telegram \ && chown -R sandbox:sandbox /sandbox/.openclaw-data/telegram \ + && rm -rf /sandbox/.openclaw/telegram \ && ln -sfn /sandbox/.openclaw-data/telegram /sandbox/.openclaw/telegram \ && chown root:root /sandbox/.openclaw \ && find /sandbox/.openclaw -mindepth 1 -maxdepth 1 -exec chown -h root:root {} + \ diff --git a/test/dockerfile-telegram-state.test.js b/test/dockerfile-telegram-state.test.js index 6efed6bb4..fcf148f95 100644 --- a/test/dockerfile-telegram-state.test.js +++ b/test/dockerfile-telegram-state.test.js @@ -15,6 +15,13 @@ describe("Dockerfile telegram state layout (#975)", () => { }); it("symlinks .openclaw/telegram into .openclaw-data before locking .openclaw", () => { - expect(DOCKERFILE.includes("ln -sfn /sandbox/.openclaw-data/telegram /sandbox/.openclaw/telegram")).toBeTruthy(); + const symlink = DOCKERFILE.indexOf("ln -sfn /sandbox/.openclaw-data/telegram /sandbox/.openclaw/telegram"); + const lockStep = DOCKERFILE.indexOf("chown root:root /sandbox/.openclaw"); + const cleanupBeforeSymlink = DOCKERFILE.indexOf("rm -rf /sandbox/.openclaw/telegram"); + + expect(symlink).toBeGreaterThan(-1); + expect(lockStep).toBeGreaterThan(symlink); + expect(cleanupBeforeSymlink).toBeGreaterThan(-1); + expect(cleanupBeforeSymlink).toBeLessThan(symlink); }); });