diff --git a/Dockerfile b/Dockerfile index 8fc107f10..e63b25975 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,9 +8,14 @@ RUN corepack enable WORKDIR /app -COPY . . +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./ +COPY ui/package.json ./ui/package.json +COPY patches ./patches +COPY scripts ./scripts RUN pnpm install --frozen-lockfile + +COPY . . RUN pnpm build RUN pnpm ui:install RUN pnpm ui:build diff --git a/docs/install/docker.md b/docs/install/docker.md index facb45697..472c64e72 100644 --- a/docs/install/docker.md +++ b/docs/install/docker.md @@ -61,6 +61,40 @@ docker compose run --rm clawdbot-cli onboard docker compose up -d clawdbot-gateway ``` +### Faster rebuilds (recommended) + +To speed up rebuilds, order your Dockerfile so dependency layers are cached. +This avoids re-running `pnpm install` unless lockfiles change: + +```dockerfile +FROM node:22-bookworm + +# Install Bun (required for build scripts) +RUN curl -fsSL https://bun.sh/install | bash +ENV PATH="/root/.bun/bin:${PATH}" + +RUN corepack enable + +WORKDIR /app + +# Cache dependencies unless package metadata changes +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./ +COPY ui/package.json ./ui/package.json +COPY patches ./patches +COPY scripts ./scripts + +RUN pnpm install --frozen-lockfile + +COPY . . +RUN pnpm build +RUN pnpm ui:install +RUN pnpm ui:build + +ENV NODE_ENV=production + +CMD ["node","dist/index.js"] +``` + ### Provider setup (optional) Use the CLI container to configure providers, then restart the gateway if needed. diff --git a/docs/platforms/hetzner.md b/docs/platforms/hetzner.md index e8056c105..93d5e7321 100644 --- a/docs/platforms/hetzner.md +++ b/docs/platforms/hetzner.md @@ -214,9 +214,15 @@ RUN curl -L https://github.com/steipete/wacli/releases/latest/download/wacli_Lin # Add more binaries below using the same pattern WORKDIR /app -COPY . . +COPY package.json pnpm-lock.yaml pnpm-workspace.yaml .npmrc ./ +COPY ui/package.json ./ui/package.json +COPY patches ./patches +COPY scripts ./scripts + RUN corepack enable RUN pnpm install --frozen-lockfile + +COPY . . RUN pnpm build RUN pnpm ui:install RUN pnpm ui:build