mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-08 21:09:23 +08:00
fix: stabilize docker e2e flows
This commit is contained in:
@@ -82,6 +82,7 @@ Docs: https://docs.openclaw.ai
|
||||
- Build: move TypeScript builds to `tsdown` + `tsgo` (faster builds, CI typechecks), update tsconfig target, and clean up lint rules.
|
||||
- Build: align npm tar override and bin metadata so the `openclaw` CLI entrypoint is preserved in npm publishes.
|
||||
- Docs: add pi/pi-dev docs and update OpenClaw branding + install links.
|
||||
- Docker E2E: stabilize gateway readiness, plugin installs/manifests, and cleanup/doctor switch entrypoint checks.
|
||||
|
||||
### Fixes
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ RUN apt-get update \
|
||||
WORKDIR /repo
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
||||
COPY scripts/postinstall.js ./scripts/postinstall.js
|
||||
COPY scripts/setup-git-hooks.js ./scripts/setup-git-hooks.js
|
||||
RUN corepack enable \
|
||||
&& pnpm install --frozen-lockfile
|
||||
|
||||
|
||||
@@ -6,6 +6,9 @@ cd /repo
|
||||
export OPENCLAW_STATE_DIR="/tmp/openclaw-test"
|
||||
export OPENCLAW_CONFIG_PATH="${OPENCLAW_STATE_DIR}/openclaw.json"
|
||||
|
||||
echo "==> Build"
|
||||
pnpm build
|
||||
|
||||
echo "==> Seed state"
|
||||
mkdir -p "${OPENCLAW_STATE_DIR}/credentials"
|
||||
mkdir -p "${OPENCLAW_STATE_DIR}/agents/main/sessions"
|
||||
|
||||
@@ -6,7 +6,7 @@ WORKDIR /app
|
||||
|
||||
ENV NODE_OPTIONS="--disable-warning=ExperimentalWarning"
|
||||
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json vitest.config.ts vitest.e2e.config.ts ./
|
||||
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml tsconfig.json vitest.config.ts vitest.e2e.config.ts openclaw.mjs ./
|
||||
COPY src ./src
|
||||
COPY test ./test
|
||||
COPY scripts ./scripts
|
||||
|
||||
@@ -81,8 +81,9 @@ LOGINCTL
|
||||
npm install -g --prefix /tmp/npm-prefix "/app/$pkg_tgz"
|
||||
|
||||
npm_bin="/tmp/npm-prefix/bin/openclaw"
|
||||
npm_entry="/tmp/npm-prefix/lib/node_modules/openclaw/openclaw.mjs"
|
||||
git_entry="/app/openclaw.mjs"
|
||||
npm_entry="/tmp/npm-prefix/lib/node_modules/openclaw/dist/index.js"
|
||||
git_entry="/app/dist/index.js"
|
||||
git_cli="/app/openclaw.mjs"
|
||||
|
||||
assert_entrypoint() {
|
||||
local unit_path="$1"
|
||||
@@ -135,12 +136,12 @@ LOGINCTL
|
||||
"npm-to-git" \
|
||||
"$npm_bin daemon install --force" \
|
||||
"$npm_entry" \
|
||||
"node $git_entry doctor --repair --force" \
|
||||
"node $git_cli doctor --repair --force" \
|
||||
"$git_entry"
|
||||
|
||||
run_flow \
|
||||
"git-to-npm" \
|
||||
"node $git_entry daemon install --force" \
|
||||
"node $git_cli daemon install --force" \
|
||||
"$git_entry" \
|
||||
"$npm_bin doctor --repair --force" \
|
||||
"$npm_entry"
|
||||
|
||||
@@ -34,13 +34,41 @@ echo "Starting gateway container..."
|
||||
bash -lc "node dist/index.js gateway --port $PORT --bind lan --allow-unconfigured > /tmp/gateway-net-e2e.log 2>&1"
|
||||
|
||||
echo "Waiting for gateway to come up..."
|
||||
for _ in $(seq 1 20); do
|
||||
ready=0
|
||||
for _ in $(seq 1 40); do
|
||||
if docker exec "$GW_NAME" bash -lc "node --input-type=module -e '
|
||||
import net from \"node:net\";
|
||||
const socket = net.createConnection({ host: \"127.0.0.1\", port: $PORT });
|
||||
const timeout = setTimeout(() => {
|
||||
socket.destroy();
|
||||
process.exit(1);
|
||||
}, 400);
|
||||
socket.on(\"connect\", () => {
|
||||
clearTimeout(timeout);
|
||||
socket.end();
|
||||
process.exit(0);
|
||||
});
|
||||
socket.on(\"error\", () => {
|
||||
clearTimeout(timeout);
|
||||
process.exit(1);
|
||||
});
|
||||
' >/dev/null 2>&1"; then
|
||||
ready=1
|
||||
break
|
||||
fi
|
||||
if docker exec "$GW_NAME" bash -lc "grep -q \"listening on ws://\" /tmp/gateway-net-e2e.log"; then
|
||||
ready=1
|
||||
break
|
||||
fi
|
||||
sleep 0.5
|
||||
done
|
||||
|
||||
if [ "$ready" -ne 1 ]; then
|
||||
echo "Gateway failed to start"
|
||||
docker exec "$GW_NAME" bash -lc "tail -n 80 /tmp/gateway-net-e2e.log" || true
|
||||
exit 1
|
||||
fi
|
||||
|
||||
docker exec "$GW_NAME" bash -lc "tail -n 50 /tmp/gateway-net-e2e.log"
|
||||
|
||||
echo "Running client container (connect + health)..."
|
||||
|
||||
@@ -280,7 +280,7 @@ TRASH
|
||||
--skip-health
|
||||
|
||||
# Assert config + workspace scaffolding.
|
||||
workspace_dir="$HOME/openclaw"
|
||||
workspace_dir="$HOME/.openclaw/workspace"
|
||||
config_path="$HOME/.openclaw/openclaw.json"
|
||||
sessions_dir="$HOME/.openclaw/agents/main/sessions"
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ docker run --rm -t "$IMAGE_NAME" bash -lc '
|
||||
|
||||
home_dir=$(mktemp -d "/tmp/openclaw-plugins-e2e.XXXXXX")
|
||||
export HOME="$home_dir"
|
||||
mkdir -p "$HOME/.openclaw/extensions"
|
||||
mkdir -p "$HOME/.openclaw/extensions/demo-plugin"
|
||||
|
||||
cat > "$HOME/.openclaw/extensions/demo-plugin.js" <<'"'"'JS'"'"'
|
||||
cat > "$HOME/.openclaw/extensions/demo-plugin/index.js" <<'"'"'JS'"'"'
|
||||
module.exports = {
|
||||
id: "demo-plugin",
|
||||
name: "Demo Plugin",
|
||||
@@ -28,6 +28,15 @@ module.exports = {
|
||||
},
|
||||
};
|
||||
JS
|
||||
cat > "$HOME/.openclaw/extensions/demo-plugin/openclaw.plugin.json" <<'"'"'JSON'"'"'
|
||||
{
|
||||
"id": "demo-plugin",
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
node dist/index.js plugins list --json > /tmp/plugins.json
|
||||
|
||||
@@ -79,6 +88,15 @@ module.exports = {
|
||||
},
|
||||
};
|
||||
JS
|
||||
cat > "$pack_dir/package/openclaw.plugin.json" <<'"'"'JSON'"'"'
|
||||
{
|
||||
"id": "demo-plugin-tgz",
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
tar -czf /tmp/demo-plugin-tgz.tgz -C "$pack_dir" package
|
||||
|
||||
node dist/index.js plugins install /tmp/demo-plugin-tgz.tgz
|
||||
@@ -117,6 +135,15 @@ module.exports = {
|
||||
},
|
||||
};
|
||||
JS
|
||||
cat > "$dir_plugin/openclaw.plugin.json" <<'"'"'JSON'"'"'
|
||||
{
|
||||
"id": "demo-plugin-dir",
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
node dist/index.js plugins install "$dir_plugin"
|
||||
node dist/index.js plugins list --json > /tmp/plugins3.json
|
||||
@@ -155,6 +182,15 @@ module.exports = {
|
||||
},
|
||||
};
|
||||
JS
|
||||
cat > "$file_pack_dir/package/openclaw.plugin.json" <<'"'"'JSON'"'"'
|
||||
{
|
||||
"id": "demo-plugin-file",
|
||||
"configSchema": {
|
||||
"type": "object",
|
||||
"properties": {}
|
||||
}
|
||||
}
|
||||
JSON
|
||||
|
||||
node dist/index.js plugins install "file:$file_pack_dir/package"
|
||||
node dist/index.js plugins list --json > /tmp/plugins4.json
|
||||
|
||||
Reference in New Issue
Block a user