diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml index 2cfbdb0..ebff621 100644 --- a/.github/workflows/docker-release.yml +++ b/.github/workflows/docker-release.yml @@ -10,6 +10,7 @@ on: - 'Dockerfile' - 'Dockerfile.alpine' - 'OPENCLAW_VERSION' + - 'scripts/install-openclaw.sh' - '.github/workflows/docker-release.yml' pull_request: branches: @@ -17,6 +18,7 @@ on: paths: - 'Dockerfile' - 'Dockerfile.alpine' + - 'scripts/install-openclaw.sh' - '.github/workflows/docker-release.yml' workflow_dispatch: diff --git a/Dockerfile b/Dockerfile index cce13f4..4e26e86 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,28 +7,8 @@ RUN apt-get update && apt-get install -y \ WORKDIR /build COPY OPENCLAW_VERSION /tmp/OPENCLAW_VERSION +COPY scripts/install-openclaw.sh /usr/local/bin/install-openclaw # Install openclaw globally, and backfill Control UI assets if upstream npm # package omitted dist/control-ui for this version. -RUN set -eux; \ - OPENCLAW_VERSION="$(tr -d '[:space:]' < /tmp/OPENCLAW_VERSION)"; \ - npm install -g "openclaw@${OPENCLAW_VERSION}"; \ - OPENCLAW_ROOT="$(npm root -g)/openclaw"; \ - CONTROL_UI_INDEX="${OPENCLAW_ROOT}/dist/control-ui/index.html"; \ - if [ ! -f "${CONTROL_UI_INDEX}" ]; then \ - echo "Control UI assets missing in openclaw@${OPENCLAW_VERSION}; building from source tag."; \ - corepack enable; \ - corepack prepare pnpm@10.23.0 --activate; \ - rm -rf /tmp/openclaw-src; \ - if ! git clone --depth 1 --branch "v${OPENCLAW_VERSION}" https://github.com/openclaw/openclaw.git /tmp/openclaw-src; then \ - git clone --depth 1 --branch "v${OPENCLAW_VERSION}-1" https://github.com/openclaw/openclaw.git /tmp/openclaw-src; \ - fi; \ - cd /tmp/openclaw-src; \ - CI=true pnpm --dir ui install --prod=false; \ - pnpm --dir ui build; \ - mkdir -p "${OPENCLAW_ROOT}/dist"; \ - rm -rf "${OPENCLAW_ROOT}/dist/control-ui"; \ - cp -R dist/control-ui "${OPENCLAW_ROOT}/dist/control-ui"; \ - test -f "${CONTROL_UI_INDEX}"; \ - rm -rf /tmp/openclaw-src /root/.local/share/pnpm /root/.cache/pnpm /root/.cache/node/corepack; \ - fi +RUN sh /usr/local/bin/install-openclaw diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 5a2c56a..9e37a11 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -10,28 +10,8 @@ RUN apk add --no-cache \ WORKDIR /build COPY OPENCLAW_VERSION /tmp/OPENCLAW_VERSION +COPY scripts/install-openclaw.sh /usr/local/bin/install-openclaw # Install openclaw globally, and backfill Control UI assets if upstream npm # package omitted dist/control-ui for this version. -RUN set -eux; \ - OPENCLAW_VERSION="$(tr -d '[:space:]' < /tmp/OPENCLAW_VERSION)"; \ - npm install -g "openclaw@${OPENCLAW_VERSION}"; \ - OPENCLAW_ROOT="$(npm root -g)/openclaw"; \ - CONTROL_UI_INDEX="${OPENCLAW_ROOT}/dist/control-ui/index.html"; \ - if [ ! -f "${CONTROL_UI_INDEX}" ]; then \ - echo "Control UI assets missing in openclaw@${OPENCLAW_VERSION}; building from source tag."; \ - corepack enable; \ - corepack prepare pnpm@10.23.0 --activate; \ - rm -rf /tmp/openclaw-src; \ - if ! git clone --depth 1 --branch "v${OPENCLAW_VERSION}" https://github.com/openclaw/openclaw.git /tmp/openclaw-src; then \ - git clone --depth 1 --branch "v${OPENCLAW_VERSION}-1" https://github.com/openclaw/openclaw.git /tmp/openclaw-src; \ - fi; \ - cd /tmp/openclaw-src; \ - CI=true pnpm --dir ui install --prod=false; \ - pnpm --dir ui build; \ - mkdir -p "${OPENCLAW_ROOT}/dist"; \ - rm -rf "${OPENCLAW_ROOT}/dist/control-ui"; \ - cp -R dist/control-ui "${OPENCLAW_ROOT}/dist/control-ui"; \ - test -f "${CONTROL_UI_INDEX}"; \ - rm -rf /tmp/openclaw-src /root/.local/share/pnpm /root/.cache/pnpm /root/.cache/node/corepack; \ - fi +RUN sh /usr/local/bin/install-openclaw diff --git a/README.md b/README.md index e4c117b..5e3caef 100644 --- a/README.md +++ b/README.md @@ -89,6 +89,7 @@ The main files to edit are: - `OPENCLAW_VERSION` (single source of truth for the openclaw npm version) - `Dockerfile` - `Dockerfile.alpine` +- `scripts/install-openclaw.sh` (shared openclaw install and Control UI backfill logic) Common changes include: - Bumping the `OPENCLAW_VERSION` to a newer npm release diff --git a/scripts/install-openclaw.sh b/scripts/install-openclaw.sh new file mode 100644 index 0000000..ae8b007 --- /dev/null +++ b/scripts/install-openclaw.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -eux + +OPENCLAW_VERSION="$(tr -d '[:space:]' < /tmp/OPENCLAW_VERSION)" +npm install -g "openclaw@${OPENCLAW_VERSION}" + +OPENCLAW_ROOT="$(npm root -g)/openclaw" +CONTROL_UI_INDEX="${OPENCLAW_ROOT}/dist/control-ui/index.html" + +if [ ! -f "${CONTROL_UI_INDEX}" ]; then + echo "Control UI assets missing in openclaw@${OPENCLAW_VERSION}; building from source tag." + corepack enable + corepack prepare pnpm@10.23.0 --activate + rm -rf /tmp/openclaw-src + if ! git clone --depth 1 --branch "v${OPENCLAW_VERSION}" https://github.com/openclaw/openclaw.git /tmp/openclaw-src; then + git clone --depth 1 --branch "v${OPENCLAW_VERSION}-1" https://github.com/openclaw/openclaw.git /tmp/openclaw-src + fi + cd /tmp/openclaw-src + CI=true pnpm --dir ui install --prod=false + pnpm --dir ui build + mkdir -p "${OPENCLAW_ROOT}/dist" + rm -rf "${OPENCLAW_ROOT}/dist/control-ui" + cp -R dist/control-ui "${OPENCLAW_ROOT}/dist/control-ui" + test -f "${CONTROL_UI_INDEX}" + rm -rf /tmp/openclaw-src /root/.local/share/pnpm /root/.cache/pnpm /root/.cache/node/corepack +fi